From 240b30723fc4a6d5f482d08b24a2c8026a539a04 Mon Sep 17 00:00:00 2001 From: Jake Hamilton Date: Fri, 7 Jun 2024 00:35:38 -0700 Subject: [PATCH] musl builds of gawk, gnumake, gnutar --- foundation/src/stages/stage1/bash/boot.nix | 2 +- .../src/stages/stage1/coreutils/boot.nix | 2 +- foundation/src/stages/stage1/default.nix | 12 +- foundation/src/stages/stage1/gawk/boot.nix | 2 +- foundation/src/stages/stage1/gawk/default.nix | 66 ++++- .../src/stages/stage1/gnugrep/default.nix | 2 +- foundation/src/stages/stage1/gnumake/boot.nix | 234 ++++++++++++++++++ .../src/stages/stage1/gnumake/default.nix | 190 ++------------ foundation/src/stages/stage1/gnused/boot.nix | 2 +- .../src/stages/stage1/gnused/default.nix | 67 ++++- foundation/src/stages/stage1/gnutar/boot.nix | 2 +- .../src/stages/stage1/gnutar/default.nix | 70 +++++- foundation/src/stages/stage1/gnutar/musl.nix | 79 ++++++ foundation/src/stages/stage1/gzip/default.nix | 8 +- foundation/src/stages/stage1/musl/boot.nix | 2 +- foundation/src/stages/stage1/musl/default.nix | 2 +- 16 files changed, 554 insertions(+), 188 deletions(-) create mode 100644 foundation/src/stages/stage1/gnumake/boot.nix create mode 100644 foundation/src/stages/stage1/gnutar/musl.nix diff --git a/foundation/src/stages/stage1/bash/boot.nix b/foundation/src/stages/stage1/bash/boot.nix index 589ed49..696b51f 100644 --- a/foundation/src/stages/stage1/bash/boot.nix +++ b/foundation/src/stages/stage1/bash/boot.nix @@ -118,7 +118,7 @@ in { deps.build.host = [ stage1.tinycc.mes.compiler.package - stage1.gnumake.package + stage1.gnumake.boot.package stage1.gnupatch.package stage1.coreutils.boot.package ]; diff --git a/foundation/src/stages/stage1/coreutils/boot.nix b/foundation/src/stages/stage1/coreutils/boot.nix index 7792c9a..f4e5d1e 100644 --- a/foundation/src/stages/stage1/coreutils/boot.nix +++ b/foundation/src/stages/stage1/coreutils/boot.nix @@ -98,7 +98,7 @@ in { deps.build.host = [ stage1.tinycc.mes.compiler.package - stage1.gnumake.package + stage1.gnumake.boot.package stage1.gnupatch.package ]; diff --git a/foundation/src/stages/stage1/default.nix b/foundation/src/stages/stage1/default.nix index cf92bc3..cb25e2f 100644 --- a/foundation/src/stages/stage1/default.nix +++ b/foundation/src/stages/stage1/default.nix @@ -7,17 +7,15 @@ stage1 = config.aux.foundation.stages.stage1; in { includes = [ - # These packages are built using Kaem. ./nyacc ./mes ./ln-boot - ./tinycc # With the exception of `tinycc-musl` which uses Bash. + ./tinycc ./gnupatch ./gnumake ./coreutils ./bash - # These packages are built using Bash v2. ./gnused ./gnugrep ./gnutar @@ -29,6 +27,7 @@ in { config = { exports = { packages = { + # These packages are built using Kaem. stage1-nyacc = stage1.nyacc.package; stage1-mes = stage1.mes.compiler.package; stage1-mes-libs = stage1.mes.libs.package; @@ -39,10 +38,11 @@ in { stage1-tinycc-mes = stage1.tinycc.mes.compiler.package; stage1-tinycc-mes-libs = stage1.tinycc.mes.libs.package; stage1-gnupatch = stage1.gnupatch.package; - stage1-gnumake = stage1.gnumake.package; + stage1-gnumake-boot = stage1.gnumake.boot.package; stage1-coreutils-boot = stage1.coreutils.boot.package; stage1-bash-boot = stage1.bash.boot.package; + # These packages are built using Bash v2. stage1-gnused-boot = stage1.gnused.boot.package; stage1-gnugrep = stage1.gnugrep.package; stage1-gnutar-boot = stage1.gnutar.boot.package; @@ -51,6 +51,10 @@ in { stage1-tinycc-musl = stage1.tinycc.musl.compiler.package; stage1-tinycc-musl-libs = stage1.tinycc.musl.libs.package; stage1-gawk-boot = stage1.gawk.boot.package; + stage1-gnused = stage1.gnused.package; + stage1-gnumake = stage1.gnumake.package; + stage1-gnutar-musl = stage1.gnutar.musl.package; + stage1-gawk = stage1.gawk.package; }; extras = { diff --git a/foundation/src/stages/stage1/gawk/boot.nix b/foundation/src/stages/stage1/gawk/boot.nix index 9c77e6b..d59b39a 100644 --- a/foundation/src/stages/stage1/gawk/boot.nix +++ b/foundation/src/stages/stage1/gawk/boot.nix @@ -48,7 +48,7 @@ in { deps.build.host = [ stage1.tinycc.mes.compiler.package - stage1.gnumake.package + stage1.gnumake.boot.package stage1.gnused.boot.package stage1.gnugrep.package stage1.gnupatch.package diff --git a/foundation/src/stages/stage1/gawk/default.nix b/foundation/src/stages/stage1/gawk/default.nix index 9b144bd..0049c3a 100644 --- a/foundation/src/stages/stage1/gawk/default.nix +++ b/foundation/src/stages/stage1/gawk/default.nix @@ -4,15 +4,31 @@ }: let cfg = config.aux.foundation.stages.stage1.gawk; + platform = config.aux.platform; builders = config.aux.foundation.builders; - stage1 = config.aux.foundation.stages.gawk; + stage1 = config.aux.foundation.stages.stage1; in { includes = [ ./boot.nix ]; options.aux.foundation.stages.stage1.gawk = { + package = lib.options.create { + type = lib.types.package; + description = "The package to use for gawk."; + }; + + version = lib.options.create { + type = lib.types.string; + description = "Version of the package."; + }; + + src = lib.options.create { + type = lib.types.package; + description = "Source for the package."; + }; + meta = { description = lib.options.create { type = lib.types.string; @@ -46,4 +62,52 @@ in { }; }; }; + + config = { + aux.foundation.stages.stage1.gawk = { + version = "5.2.2"; + + src = builtins.fetchurl { + url = "https://ftpmirror.gnu.org/gawk/gawk-${cfg.version}.tar.gz"; + sha256 = "lFrvfM/xAfILIqEIArwAXplKsrjqPnJMwaGXxi9B9lA="; + }; + + package = builders.bash.boot.build { + name = "gawk-${cfg.version}"; + + meta = cfg.meta; + + deps.build.host = [ + stage1.tinycc.musl.compiler.package + stage1.gnumake.package + stage1.gnused.package + stage1.gnugrep.package + stage1.gnutar.musl.package + stage1.gzip.package + stage1.gawk.boot.package + ]; + + script = '' + # Unpack + tar xzf ${cfg.src} + cd gawk-${cfg.version} + + # Configure + export CC="tcc -B ${stage1.tinycc.musl.libs.package}/lib" + export AR="tcc -ar" + export LD=tcc + bash ./configure \ + --prefix=$out \ + --build=${platform.build} \ + --host=${platform.host} + + # Build + make -j $NIX_BUILD_CORES + + # Install + make -j $NIX_BUILD_CORES install + ''; + }; + }; + }; } diff --git a/foundation/src/stages/stage1/gnugrep/default.nix b/foundation/src/stages/stage1/gnugrep/default.nix index a5af8d4..5e14b3f 100644 --- a/foundation/src/stages/stage1/gnugrep/default.nix +++ b/foundation/src/stages/stage1/gnugrep/default.nix @@ -81,7 +81,7 @@ in { deps.build.host = [ stage1.tinycc.mes.compiler.package - stage1.gnumake.package + stage1.gnumake.boot.package ]; script = '' diff --git a/foundation/src/stages/stage1/gnumake/boot.nix b/foundation/src/stages/stage1/gnumake/boot.nix new file mode 100644 index 0000000..119da1d --- /dev/null +++ b/foundation/src/stages/stage1/gnumake/boot.nix @@ -0,0 +1,234 @@ +{ + lib, + config, +}: let + cfg = config.aux.foundation.stages.stage1.gnumake.boot; + + builders = config.aux.foundation.builders; + + stage1 = config.aux.foundation.stages.stage1; +in { + options.aux.foundation.stages.stage1.gnumake.boot = { + package = lib.options.create { + type = lib.types.package; + description = "The package to use for gnumake."; + }; + + version = lib.options.create { + type = lib.types.string; + description = "Version of the package."; + }; + + src = lib.options.create { + type = lib.types.package; + description = "Source for the package."; + }; + }; + + config = { + aux.foundation.stages.stage1.gnumake.boot = { + version = "4.4.1"; + + src = builtins.fetchurl { + url = "https://ftpmirror.gnu.org/make/make-${cfg.version}.tar.gz"; + sha256 = "1cwgcmwdn7gqn5da2ia91gkyiqs9birr10sy5ykpkaxzcwfzn5nx"; + }; + + package = let + patches = [ + # Replaces /bin/sh with sh, see patch file for reasoning + ./patches/0001-No-impure-bin-sh.patch + # Purity: don't look for library dependencies (of the form `-lfoo') in /lib + # and /usr/lib. It's a stupid feature anyway. Likewise, when searching for + # included Makefiles, don't look in /usr/include and friends. + ./patches/0002-remove-impure-dirs.patch + # Fixes for tinycc. See comments in patch file for reasoning + ./patches/0003-tinycc-support.patch + ]; + + /* + Maintenance notes: + + Generated by + ./configure \ + --build i686-pc-linux-gnu \ + --host i686-pc-linux-gnu \ + CC="${tinycc.compiler}/bin/tcc -B ${tinycc.libs}/lib" \ + ac_cv_func_dup=no + - `ac_cv_func_dup` disabled as mes-libc doesn't implement tmpfile() + + The output src/config.h was then manually filtered, removing definitions that + didn't have uses in the source code + */ + config = [ + "-DFILE_TIMESTAMP_HI_RES=0" + "-DHAVE_ALLOCA" + "-DHAVE_ALLOCA_H" + "-DHAVE_ATEXIT" + "-DHAVE_DECL_BSD_SIGNAL=0" + "-DHAVE_DECL_GETLOADAVG=0" + "-DHAVE_DECL_SYS_SIGLIST=0" + "-DHAVE_DECL__SYS_SIGLIST=0" + "-DHAVE_DECL___SYS_SIGLIST=0" + "-DHAVE_DIRENT_H" + "-DHAVE_DUP2" + "-DHAVE_FCNTL_H" + "-DHAVE_FDOPEN" + "-DHAVE_GETCWD" + "-DHAVE_GETTIMEOFDAY" + "-DHAVE_INTTYPES_H" + "-DHAVE_ISATTY" + "-DHAVE_LIMITS_H" + "-DHAVE_LOCALE_H" + "-DHAVE_MEMORY_H" + "-DHAVE_MKTEMP" + "-DHAVE_SA_RESTART" + "-DHAVE_SETVBUF" + "-DHAVE_SIGACTION" + "-DHAVE_SIGSETMASK" + "-DHAVE_STDINT_H" + "-DHAVE_STDLIB_H" + "-DHAVE_STRDUP" + "-DHAVE_STRERROR" + "-DHAVE_STRINGS_H" + "-DHAVE_STRING_H" + "-DHAVE_STRTOLL" + "-DHAVE_SYS_FILE_H" + "-DHAVE_SYS_PARAM_H" + "-DHAVE_SYS_RESOURCE_H" + "-DHAVE_SYS_SELECT_H" + "-DHAVE_SYS_STAT_H" + "-DHAVE_SYS_TIMEB_H" + "-DHAVE_SYS_TIME_H" + "-DHAVE_SYS_WAIT_H" + "-DHAVE_TTYNAME" + "-DHAVE_UMASK" + "-DHAVE_UNISTD_H" + "-DHAVE_WAITPID" + "-DMAKE_JOBSERVER" + "-DMAKE_SYMLINKS" + "-DPATH_SEPARATOR_CHAR=':'" + "-DSCCS_GET=\\\"get\\\"" + "-DSTDC_HEADERS" + "-Dsig_atomic_t=int" + "-Dvfork=fork" + ]; + + cflags = + [ + "-I./src" + "-I./lib" + "-DHAVE_CONFIG_H" + "-DMAKE_MAINTAINER_MODE" + "-DLIBDIR=\\\"${builtins.placeholder "out"}/lib\\\"" + "-DLOCALEDIR=\\\"/fake-locale\\\"" + "-DPOSIX=1" + # mes-libc doesn't implement osync_* methods + "-DNO_OUTPUT_SYNC=1" + # mes-libc doesn't define O_TMPFILE + "-DO_TMPFILE=020000000" + ] + ++ config; + + sources = { + # Maintenance note: list of source files derived from Basic.mk + make = [ + "src/ar.c" + "src/arscan.c" + "src/commands.c" + "src/default.c" + "src/dir.c" + "src/expand.c" + "src/file.c" + "src/function.c" + "src/getopt.c" + "src/getopt1.c" + "src/guile.c" + "src/hash.c" + "src/implicit.c" + "src/job.c" + "src/load.c" + "src/loadapi.c" + "src/main.c" + "src/misc.c" + "src/output.c" + "src/read.c" + "src/remake.c" + "src/rule.c" + "src/shuffle.c" + "src/signame.c" + "src/strcache.c" + "src/variable.c" + "src/version.c" + "src/vpath.c" + ]; + glob = [ + "lib/fnmatch.c" + "lib/glob.c" + ]; + remote = [ + "src/remote-stub.c" + ]; + }; + + files = + sources.make + ++ sources.glob + ++ sources.remote + ++ [ + "src/posixos.c" + ]; + + objects = + builtins.map + ( + value: + builtins.replaceStrings [".c"] [".o"] + (builtins.baseNameOf value) + ) + files; + in + builders.kaem.build { + name = "gnumake-${cfg.version}"; + + meta = stage1.gnumake.meta; + + deps.build.host = [ + stage1.tinycc.mes.compiler.package + stage1.gnupatch.package + ]; + + script = '' + # Unpack + ungz --file ${cfg.src} --output make.tar + untar --file make.tar + rm make.tar + cd make-${cfg.version} + + # Patch + ${lib.strings.concatMapSep "\n" (file: "patch -Np1 -i ${file}") patches} + + # Configure + catm src/config.h src/mkconfig.h src/mkcustom.h + cp lib/glob.in.h lib/glob.h + cp lib/fnmatch.in.h lib/fnmatch.h + + # Compile + alias CC="tcc -B ${stage1.tinycc.mes.libs.package}/lib ${builtins.concatStringsSep " " cflags}" + ${lib.strings.concatMapSep "\n" (file: "CC -c ${file}") files} + + # Link + CC -o make ${builtins.concatStringsSep " " objects} + + # Check + ./make --version + + # Install + mkdir -p ''${out}/bin + cp ./make ''${out}/bin + chmod 555 ''${out}/bin/make + ''; + }; + }; + }; +} diff --git a/foundation/src/stages/stage1/gnumake/default.nix b/foundation/src/stages/stage1/gnumake/default.nix index a173050..3c5fb61 100644 --- a/foundation/src/stages/stage1/gnumake/default.nix +++ b/foundation/src/stages/stage1/gnumake/default.nix @@ -4,10 +4,15 @@ }: let cfg = config.aux.foundation.stages.stage1.gnumake; + platform = config.aux.platform; builders = config.aux.foundation.builders; stage1 = config.aux.foundation.stages.stage1; in { + includes = [ + ./boot.nix + ]; + options.aux.foundation.stages.stage1.gnumake = { package = lib.options.create { type = lib.types.package; @@ -58,7 +63,7 @@ in { src = builtins.fetchurl { url = "https://ftpmirror.gnu.org/make/make-${cfg.version}.tar.gz"; - sha256 = "1cwgcmwdn7gqn5da2ia91gkyiqs9birr10sy5ykpkaxzcwfzn5nx"; + sha256 = "3Rb7HWe/q3mnL16DkHNcSePo5wtJRaFasfgd23hlj7M="; }; package = let @@ -69,192 +74,45 @@ in { # and /usr/lib. It's a stupid feature anyway. Likewise, when searching for # included Makefiles, don't look in /usr/include and friends. ./patches/0002-remove-impure-dirs.patch - # Fixes for tinycc. See comments in patch file for reasoning - ./patches/0003-tinycc-support.patch ]; - - /* - Maintenance notes: - - Generated by - ./configure \ - --build i686-pc-linux-gnu \ - --host i686-pc-linux-gnu \ - CC="${tinycc.compiler}/bin/tcc -B ${tinycc.libs}/lib" \ - ac_cv_func_dup=no - - `ac_cv_func_dup` disabled as mes-libc doesn't implement tmpfile() - - The output src/config.h was then manually filtered, removing definitions that - didn't have uses in the source code - */ - config = [ - "-DFILE_TIMESTAMP_HI_RES=0" - "-DHAVE_ALLOCA" - "-DHAVE_ALLOCA_H" - "-DHAVE_ATEXIT" - "-DHAVE_DECL_BSD_SIGNAL=0" - "-DHAVE_DECL_GETLOADAVG=0" - "-DHAVE_DECL_SYS_SIGLIST=0" - "-DHAVE_DECL__SYS_SIGLIST=0" - "-DHAVE_DECL___SYS_SIGLIST=0" - "-DHAVE_DIRENT_H" - "-DHAVE_DUP2" - "-DHAVE_FCNTL_H" - "-DHAVE_FDOPEN" - "-DHAVE_GETCWD" - "-DHAVE_GETTIMEOFDAY" - "-DHAVE_INTTYPES_H" - "-DHAVE_ISATTY" - "-DHAVE_LIMITS_H" - "-DHAVE_LOCALE_H" - "-DHAVE_MEMORY_H" - "-DHAVE_MKTEMP" - "-DHAVE_SA_RESTART" - "-DHAVE_SETVBUF" - "-DHAVE_SIGACTION" - "-DHAVE_SIGSETMASK" - "-DHAVE_STDINT_H" - "-DHAVE_STDLIB_H" - "-DHAVE_STRDUP" - "-DHAVE_STRERROR" - "-DHAVE_STRINGS_H" - "-DHAVE_STRING_H" - "-DHAVE_STRTOLL" - "-DHAVE_SYS_FILE_H" - "-DHAVE_SYS_PARAM_H" - "-DHAVE_SYS_RESOURCE_H" - "-DHAVE_SYS_SELECT_H" - "-DHAVE_SYS_STAT_H" - "-DHAVE_SYS_TIMEB_H" - "-DHAVE_SYS_TIME_H" - "-DHAVE_SYS_WAIT_H" - "-DHAVE_TTYNAME" - "-DHAVE_UMASK" - "-DHAVE_UNISTD_H" - "-DHAVE_WAITPID" - "-DMAKE_JOBSERVER" - "-DMAKE_SYMLINKS" - "-DPATH_SEPARATOR_CHAR=':'" - "-DSCCS_GET=\\\"get\\\"" - "-DSTDC_HEADERS" - "-Dsig_atomic_t=int" - "-Dvfork=fork" - ]; - - cflags = - [ - "-I./src" - "-I./lib" - "-DHAVE_CONFIG_H" - "-DMAKE_MAINTAINER_MODE" - "-DLIBDIR=\\\"${builtins.placeholder "out"}/lib\\\"" - "-DLOCALEDIR=\\\"/fake-locale\\\"" - "-DPOSIX=1" - # mes-libc doesn't implement osync_* methods - "-DNO_OUTPUT_SYNC=1" - # mes-libc doesn't define O_TMPFILE - "-DO_TMPFILE=020000000" - ] - ++ config; - - sources = { - # Maintenance note: list of source files derived from Basic.mk - make = [ - "src/ar.c" - "src/arscan.c" - "src/commands.c" - "src/default.c" - "src/dir.c" - "src/expand.c" - "src/file.c" - "src/function.c" - "src/getopt.c" - "src/getopt1.c" - "src/guile.c" - "src/hash.c" - "src/implicit.c" - "src/job.c" - "src/load.c" - "src/loadapi.c" - "src/main.c" - "src/misc.c" - "src/output.c" - "src/read.c" - "src/remake.c" - "src/rule.c" - "src/shuffle.c" - "src/signame.c" - "src/strcache.c" - "src/variable.c" - "src/version.c" - "src/vpath.c" - ]; - glob = [ - "lib/fnmatch.c" - "lib/glob.c" - ]; - remote = [ - "src/remote-stub.c" - ]; - }; - - files = - sources.make - ++ sources.glob - ++ sources.remote - ++ [ - "src/posixos.c" - ]; - - objects = - builtins.map - ( - value: - builtins.replaceStrings [".c"] [".o"] - (builtins.baseNameOf value) - ) - files; in - builders.kaem.build { + builders.bash.boot.build { name = "gnumake-${cfg.version}"; meta = cfg.meta; - src = cfg.src; deps.build.host = [ - stage1.tinycc.mes.compiler.package + stage1.tinycc.musl.compiler.package + stage1.gnumake.boot.package stage1.gnupatch.package + stage1.gnused.package + stage1.gnugrep.package + stage1.gawk.boot.package + stage1.gnutar.boot.package + stage1.gzip.package ]; script = '' # Unpack - ungz --file ${cfg.src} --output make.tar - untar --file make.tar - rm make.tar + tar xzf ${cfg.src} cd make-${cfg.version} # Patch ${lib.strings.concatMapSep "\n" (file: "patch -Np1 -i ${file}") patches} # Configure - catm src/config.h src/mkconfig.h src/mkcustom.h - cp lib/glob.in.h lib/glob.h - cp lib/fnmatch.in.h lib/fnmatch.h + export CC="tcc -B ${stage1.tinycc.musl.libs.package}/lib" + export LD=tcc + bash ./configure \ + --prefix=$out \ + --build=${platform.build} \ + --host=${platform.host} - # Compile - alias CC="tcc -B ${stage1.tinycc.mes.libs.package}/lib ${builtins.concatStringsSep " " cflags}" - ${lib.strings.concatMapSep "\n" (file: "CC -c ${file}") files} - - # Link - CC -o make ${builtins.concatStringsSep " " objects} - - # Check - ./make --version + # Build + make AR="tcc -ar" # Install - mkdir -p ''${out}/bin - cp ./make ''${out}/bin - chmod 555 ''${out}/bin/make + make install ''; }; }; diff --git a/foundation/src/stages/stage1/gnused/boot.nix b/foundation/src/stages/stage1/gnused/boot.nix index 575ec39..4dbdfa4 100644 --- a/foundation/src/stages/stage1/gnused/boot.nix +++ b/foundation/src/stages/stage1/gnused/boot.nix @@ -49,7 +49,7 @@ in { deps.build.host = [ stage1.tinycc.mes.compiler.package - stage1.gnumake.package + stage1.gnumake.boot.package ]; script = '' diff --git a/foundation/src/stages/stage1/gnused/default.nix b/foundation/src/stages/stage1/gnused/default.nix index 60b564f..7e6b6f7 100644 --- a/foundation/src/stages/stage1/gnused/default.nix +++ b/foundation/src/stages/stage1/gnused/default.nix @@ -4,15 +4,31 @@ }: let cfg = config.aux.foundation.stages.stage1.gnused; + platform = config.aux.platform; builders = config.aux.foundation.builders; - stage1 = config.aux.foundation.stages.gnused; + stage1 = config.aux.foundation.stages.stage1; in { includes = [ ./boot.nix ]; options.aux.foundation.stages.stage1.gnused = { + package = lib.options.create { + type = lib.types.package; + description = "The package to use for gnumake."; + }; + + version = lib.options.create { + type = lib.types.string; + description = "Version of the package."; + }; + + src = lib.options.create { + type = lib.types.package; + description = "Source for the package."; + }; + meta = { description = lib.options.create { type = lib.types.string; @@ -46,4 +62,53 @@ in { }; }; }; + + config = { + aux.foundation.stages.stage1.gnused = { + version = "4.2"; + + src = builtins.fetchurl { + url = "https://ftpmirror.gnu.org/sed/sed-${cfg.version}.tar.gz"; + sha256 = "20XNY/0BDmUFN9ZdXfznaJplJ0UjZgbl5ceCk3Jn2YM="; + }; + + package = builders.bash.boot.build { + name = "gnused-${cfg.version}"; + + meta = cfg.meta; + + deps.build.host = [ + stage1.tinycc.musl.compiler.package + stage1.gnumake.boot.package + stage1.gnused.boot.package + stage1.gnugrep.package + stage1.gnutar.boot.package + stage1.gzip.package + ]; + + script = '' + # Unpack + tar xzf ${cfg.src} + cd sed-${cfg.version} + + # Configure + export CC="tcc -B ${stage1.tinycc.musl.libs.package}/lib" + export LD=tcc + ./configure \ + --build=${platform.build} \ + --host=${platform.host} \ + --disable-shared \ + --disable-nls \ + --disable-dependency-tracking \ + --prefix=$out + + # Build + make AR="tcc -ar" + + # Install + make install + ''; + }; + }; + }; } diff --git a/foundation/src/stages/stage1/gnutar/boot.nix b/foundation/src/stages/stage1/gnutar/boot.nix index 945c47c..47efba0 100644 --- a/foundation/src/stages/stage1/gnutar/boot.nix +++ b/foundation/src/stages/stage1/gnutar/boot.nix @@ -44,7 +44,7 @@ in { deps.build.host = [ stage1.tinycc.mes.compiler.package - stage1.gnumake.package + stage1.gnumake.boot.package stage1.gnused.boot.package stage1.gnugrep.package ]; diff --git a/foundation/src/stages/stage1/gnutar/default.nix b/foundation/src/stages/stage1/gnutar/default.nix index e577b8f..924b87c 100644 --- a/foundation/src/stages/stage1/gnutar/default.nix +++ b/foundation/src/stages/stage1/gnutar/default.nix @@ -4,15 +4,32 @@ }: let cfg = config.aux.foundation.stages.stage1.gnutar; + platform = config.aux.platform; builders = config.aux.foundation.builders; - stage1 = config.aux.foundation.stages.gnutar; + stage1 = config.aux.foundation.stages.stage1; in { includes = [ ./boot.nix + ./musl.nix ]; options.aux.foundation.stages.stage1.gnutar = { + package = lib.options.create { + type = lib.types.package; + description = "The package to use for gnutar."; + }; + + version = lib.options.create { + type = lib.types.string; + description = "Version of the package."; + }; + + src = lib.options.create { + type = lib.types.package; + description = "Source for the package."; + }; + meta = { description = lib.options.create { type = lib.types.string; @@ -46,4 +63,55 @@ in { }; }; }; + + config = { + aux.foundation.stages.stage1.gnutar = { + version = "1.12"; + + src = builtins.fetchurl { + url = "https://ftpmirror.gnu.org/tar/tar-${cfg.version}.tar.gz"; + sha256 = "xsN+iIsTbM76uQPFEUn0t71lnWnUrqISRfYQU6V6pgo="; + }; + + package = builders.bash.boot.build { + name = "gnutar-${cfg.version}"; + + meta = cfg.meta; + + deps.build.host = [ + stage1.tinycc.musl.compiler.package + stage1.gnumake.boot.package + stage1.gnused.boot.package + stage1.gnugrep.package + ]; + + script = '' + # Unpack + ungz --file ${cfg.src} --output tar.tar + untar --file tar.tar + rm tar.tar + cd tar-${cfg.version} + + # Configure + export CC="tcc -B ${stage1.tinycc.musl.libs.package}/lib" + export LD=tcc + export ac_cv_sizeof_unsigned_long=4 + export ac_cv_sizeof_long_long=8 + export ac_cv_header_netdb_h=no + bash ./configure \ + --prefix=$out \ + --build=${platform.build} \ + --host=${platform.host} \ + --disable-nls + + # Build + make AR="tcc -ar" + + # Install + make install + + ''; + }; + }; + }; } diff --git a/foundation/src/stages/stage1/gnutar/musl.nix b/foundation/src/stages/stage1/gnutar/musl.nix new file mode 100644 index 0000000..0a4127f --- /dev/null +++ b/foundation/src/stages/stage1/gnutar/musl.nix @@ -0,0 +1,79 @@ +{ + lib, + config, +}: let + cfg = config.aux.foundation.stages.stage1.gnutar.musl; + + platform = config.aux.platform; + builders = config.aux.foundation.builders; + + stage1 = config.aux.foundation.stages.stage1; +in { + options.aux.foundation.stages.stage1.gnutar.musl = { + package = lib.options.create { + type = lib.types.package; + description = "The package to use for gnutar-musl."; + }; + + version = lib.options.create { + type = lib.types.string; + description = "Version of the package."; + }; + + src = lib.options.create { + type = lib.types.package; + description = "Source for the package."; + }; + }; + + config = { + aux.foundation.stages.stage1.gnutar.musl = { + version = "1.12"; + + src = builtins.fetchurl { + url = "https://ftpmirror.gnu.org/tar/tar-${cfg.version}.tar.gz"; + sha256 = "xsN+iIsTbM76uQPFEUn0t71lnWnUrqISRfYQU6V6pgo="; + }; + + package = builders.bash.boot.build { + name = "gnutar-musl-${cfg.version}"; + + meta = stage1.gnutar.meta; + + deps.build.host = [ + stage1.tinycc.musl.compiler.package + stage1.gnumake.boot.package + stage1.gnused.boot.package + stage1.gnugrep.package + ]; + + script = '' + # Unpack + ungz --file ${cfg.src} --output tar.tar + untar --file tar.tar + rm tar.tar + cd tar-${cfg.version} + + # Configure + export CC="tcc -B ${stage1.tinycc.musl.libs.package}/lib" + export LD=tcc + export ac_cv_sizeof_unsigned_long=4 + export ac_cv_sizeof_long_long=8 + export ac_cv_header_netdb_h=no + bash ./configure \ + --prefix=$out \ + --build=${platform.build} \ + --host=${platform.host} \ + --disable-nls + + # Build + make AR="tcc -ar" + + # Install + make install + + ''; + }; + }; + }; +} diff --git a/foundation/src/stages/stage1/gzip/default.nix b/foundation/src/stages/stage1/gzip/default.nix index ef34fd1..e596d8b 100644 --- a/foundation/src/stages/stage1/gzip/default.nix +++ b/foundation/src/stages/stage1/gzip/default.nix @@ -49,12 +49,6 @@ in { description = "Platforms the package supports."; default.value = ["x86_64-linux" "aarch64-linux" "i686-linux"]; }; - - mainProgram = lib.options.create { - type = lib.types.string; - description = "The main program of the package."; - default.value = "grep"; - }; }; }; @@ -75,7 +69,7 @@ in { deps.build.host = [ stage1.tinycc.mes.compiler.package - stage1.gnumake.package + stage1.gnumake.boot.package stage1.gnused.boot.package stage1.gnugrep.package ]; diff --git a/foundation/src/stages/stage1/musl/boot.nix b/foundation/src/stages/stage1/musl/boot.nix index ee56243..1bdf2c3 100644 --- a/foundation/src/stages/stage1/musl/boot.nix +++ b/foundation/src/stages/stage1/musl/boot.nix @@ -88,7 +88,7 @@ in { deps.build.host = [ stage1.tinycc.mes.compiler.package - stage1.gnumake.package + stage1.gnumake.boot.package stage1.gnused.boot.package stage1.gnugrep.package stage1.gnupatch.package diff --git a/foundation/src/stages/stage1/musl/default.nix b/foundation/src/stages/stage1/musl/default.nix index 54c1017..2ebfde9 100644 --- a/foundation/src/stages/stage1/musl/default.nix +++ b/foundation/src/stages/stage1/musl/default.nix @@ -6,7 +6,7 @@ builders = config.aux.foundation.builders; - stage1 = config.aux.foundation.stages.musl; + stage1 = config.aux.foundation.stages.stage1; in { includes = [ ./boot.nix