diff --git a/pkgs/os-specific/linux/minimal-bootstrap/default.nix b/pkgs/os-specific/linux/minimal-bootstrap/default.nix index 3b1b73ed8170..2e421222d5b1 100644 --- a/pkgs/os-specific/linux/minimal-bootstrap/default.nix +++ b/pkgs/os-specific/linux/minimal-bootstrap/default.nix @@ -187,6 +187,12 @@ lib.makeScope gnumakeBoot = gnumake; }; + gnumake-static = callPackage ./gnumake/static.nix { + gcc = gcc-latest; + gnumake = gnumake-musl; + gnutar = gnutar-latest; + }; + gnupatch = callPackage ./gnupatch { tinycc = tinycc-mes; }; gnused = callPackage ./gnused { @@ -354,6 +360,8 @@ lib.makeScope echo ${gnugrep.tests.get-version} echo ${gnugrep-static.tests.get-version} echo ${gnum4.tests.get-version} + echo ${gnumake-musl.tests.get-version} + echo ${gnumake-static.tests.get-version} echo ${gnused.tests.get-version} echo ${gnused-mes.tests.get-version} echo ${gnused-static.tests.get-version} diff --git a/pkgs/os-specific/linux/minimal-bootstrap/gnumake/common.nix b/pkgs/os-specific/linux/minimal-bootstrap/gnumake/common.nix new file mode 100644 index 000000000000..959fc2a63a32 --- /dev/null +++ b/pkgs/os-specific/linux/minimal-bootstrap/gnumake/common.nix @@ -0,0 +1,11 @@ +{ lib }: +{ + meta = { + description = "A tool to control the generation of non-source files from sources"; + homepage = "https://www.gnu.org/software/make"; + license = lib.licenses.gpl3Plus; + teams = [ lib.teams.minimal-bootstrap ]; + mainProgram = "make"; + platforms = lib.platforms.unix; + }; +} diff --git a/pkgs/os-specific/linux/minimal-bootstrap/gnumake/default.nix b/pkgs/os-specific/linux/minimal-bootstrap/gnumake/default.nix index 04690844d911..5297dacbd253 100644 --- a/pkgs/os-specific/linux/minimal-bootstrap/gnumake/default.nix +++ b/pkgs/os-specific/linux/minimal-bootstrap/gnumake/default.nix @@ -6,6 +6,7 @@ gnupatch, }: let + inherit (import ./common.nix { inherit lib; }) meta; pname = "gnumake"; version = "4.4.1"; @@ -156,21 +157,12 @@ let in kaem.runCommand "${pname}-${version}" { - inherit pname version; + inherit pname version meta; nativeBuildInputs = [ tinycc.compiler gnupatch ]; - - meta = { - description = "Tool to control the generation of non-source files from sources"; - homepage = "https://www.gnu.org/software/make"; - license = lib.licenses.gpl3Plus; - teams = [ lib.teams.minimal-bootstrap ]; - mainProgram = "make"; - platforms = lib.platforms.unix; - }; } '' # Unpack diff --git a/pkgs/os-specific/linux/minimal-bootstrap/gnumake/musl.nix b/pkgs/os-specific/linux/minimal-bootstrap/gnumake/musl.nix index b5d18e61e156..1af7ce5b0fd6 100644 --- a/pkgs/os-specific/linux/minimal-bootstrap/gnumake/musl.nix +++ b/pkgs/os-specific/linux/minimal-bootstrap/gnumake/musl.nix @@ -14,6 +14,7 @@ gzip, }: let + inherit (import ./common.nix { inherit lib; }) meta; pname = "gnumake-musl"; version = "4.4.1"; @@ -33,7 +34,7 @@ let in bash.runCommand "${pname}-${version}" { - inherit pname version; + inherit pname version meta; nativeBuildInputs = [ tinycc.compiler @@ -52,15 +53,6 @@ bash.runCommand "${pname}-${version}" ${result}/bin/make --version mkdir $out ''; - - meta = { - description = "Tool to control the generation of non-source files from sources"; - homepage = "https://www.gnu.org/software/make"; - license = lib.licenses.gpl3Plus; - teams = [ lib.teams.minimal-bootstrap ]; - mainProgram = "make"; - platforms = lib.platforms.unix; - }; } '' # Unpack diff --git a/pkgs/os-specific/linux/minimal-bootstrap/gnumake/static.nix b/pkgs/os-specific/linux/minimal-bootstrap/gnumake/static.nix new file mode 100644 index 000000000000..1a641352f2e0 --- /dev/null +++ b/pkgs/os-specific/linux/minimal-bootstrap/gnumake/static.nix @@ -0,0 +1,86 @@ +{ + lib, + buildPlatform, + hostPlatform, + fetchurl, + bash, + gcc, + musl, + binutils, + gnumake, + gnupatch, + gnused, + gnugrep, + gawk, + diffutils, + findutils, + gnutar, + gzip, +}: +let + inherit (import ./common.nix { inherit lib; }) meta; + pname = "gnumake-static"; + version = "4.4.1"; + + src = fetchurl { + url = "mirror://gnu/make/make-${version}.tar.gz"; + hash = "sha256-3Rb7HWe/q3mnL16DkHNcSePo5wtJRaFasfgd23hlj7M="; + }; + + patches = [ + # Replaces /bin/sh with sh, see patch file for reasoning + ./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. + ./0002-remove-impure-dirs.patch + ]; +in +bash.runCommand "${pname}-${version}" + { + inherit pname version meta; + + nativeBuildInputs = [ + gcc + musl + binutils + gnumake + gnupatch + gnused + gnugrep + gawk + diffutils + findutils + gnutar + gzip + ]; + + passthru.tests.get-version = + result: + bash.runCommand "${pname}-get-version-${version}" { } '' + ${result}/bin/make --version + mkdir $out + ''; + } + '' + # Unpack + tar xf ${src} + cd make-${version} + + # Patch + ${lib.concatMapStringsSep "\n" (f: "patch -Np1 -i ${f}") patches} + + # Configure + bash ./configure \ + --prefix=$out \ + --build=${buildPlatform.config} \ + --host=${hostPlatform.config} \ + CC=musl-gcc \ + CFLAGS=-static + + # Build + make -j $NIX_BUILD_CORES + + # Install + make -j $NIX_BUILD_CORES install + ''