From b707bde4ea0f55a65af4ce54c24bad912ac1b192 Mon Sep 17 00:00:00 2001 From: Emily Trau Date: Sun, 8 Oct 2023 21:58:32 -0700 Subject: [PATCH] minimal-bootstrap.coreutils-static: init at 9.4 --- .../minimal-bootstrap/coreutils/common.nix | 10 +++ .../minimal-bootstrap/coreutils/default.nix | 11 +-- .../minimal-bootstrap/coreutils/musl.nix | 11 +-- .../minimal-bootstrap/coreutils/static.nix | 78 ++++++++++++++++++ .../linux/minimal-bootstrap/default.nix | 81 ++++++++++--------- 5 files changed, 135 insertions(+), 56 deletions(-) create mode 100644 pkgs/os-specific/linux/minimal-bootstrap/coreutils/common.nix create mode 100644 pkgs/os-specific/linux/minimal-bootstrap/coreutils/static.nix diff --git a/pkgs/os-specific/linux/minimal-bootstrap/coreutils/common.nix b/pkgs/os-specific/linux/minimal-bootstrap/coreutils/common.nix new file mode 100644 index 000000000000..1f8ba9c08883 --- /dev/null +++ b/pkgs/os-specific/linux/minimal-bootstrap/coreutils/common.nix @@ -0,0 +1,10 @@ +{ lib }: +{ + meta = { + description = "The GNU Core Utilities"; + homepage = "https://www.gnu.org/software/coreutils"; + license = lib.licenses.gpl3Plus; + teams = [ lib.teams.minimal-bootstrap ]; + platforms = lib.platforms.unix; + }; +} diff --git a/pkgs/os-specific/linux/minimal-bootstrap/coreutils/default.nix b/pkgs/os-specific/linux/minimal-bootstrap/coreutils/default.nix index 2ddcbd247434..5f5c58c00a4d 100644 --- a/pkgs/os-specific/linux/minimal-bootstrap/coreutils/default.nix +++ b/pkgs/os-specific/linux/minimal-bootstrap/coreutils/default.nix @@ -7,6 +7,7 @@ gnupatch, }: let + inherit (import ./common.nix { inherit lib; }) meta; pname = "bootstrap-coreutils"; version = "5.0"; @@ -73,21 +74,13 @@ let in kaem.runCommand "${pname}-${version}" { - inherit pname version; + inherit pname version meta; nativeBuildInputs = [ tinycc.compiler gnumake gnupatch ]; - - meta = { - description = "GNU Core Utilities"; - homepage = "https://www.gnu.org/software/coreutils"; - license = lib.licenses.gpl3Plus; - teams = [ lib.teams.minimal-bootstrap ]; - platforms = lib.platforms.unix; - }; } '' # Unpack diff --git a/pkgs/os-specific/linux/minimal-bootstrap/coreutils/musl.nix b/pkgs/os-specific/linux/minimal-bootstrap/coreutils/musl.nix index 11778bb35833..bf6506d422ba 100644 --- a/pkgs/os-specific/linux/minimal-bootstrap/coreutils/musl.nix +++ b/pkgs/os-specific/linux/minimal-bootstrap/coreutils/musl.nix @@ -13,6 +13,7 @@ gzip, }: let + inherit (import ./common.nix { inherit lib; }) meta; pname = "bootstrap-coreutils-musl"; version = "9.4"; @@ -36,7 +37,7 @@ let in bash.runCommand "${pname}-${version}" { - inherit pname version; + inherit pname version meta; nativeBuildInputs = [ tinycc.compiler @@ -54,14 +55,6 @@ bash.runCommand "${pname}-${version}" ${result}/bin/cat --version mkdir $out ''; - - meta = { - description = "GNU Core Utilities"; - homepage = "https://www.gnu.org/software/coreutils"; - license = lib.licenses.gpl3Plus; - teams = [ lib.teams.minimal-bootstrap ]; - platforms = lib.platforms.unix; - }; } '' # Unpack diff --git a/pkgs/os-specific/linux/minimal-bootstrap/coreutils/static.nix b/pkgs/os-specific/linux/minimal-bootstrap/coreutils/static.nix new file mode 100644 index 000000000000..97dfa7642ce1 --- /dev/null +++ b/pkgs/os-specific/linux/minimal-bootstrap/coreutils/static.nix @@ -0,0 +1,78 @@ +{ + lib, + buildPlatform, + hostPlatform, + fetchurl, + bash, + gcc, + musl, + binutils, + gnumake, + gnused, + gnugrep, + gawk, + diffutils, + findutils, + gnutar, + gzip, +}: +let + inherit (import ./common.nix { inherit lib; }) meta; + pname = "coreutils-static"; + version = "9.4"; + + src = fetchurl { + url = "mirror://gnu/coreutils/coreutils-${version}.tar.gz"; + hash = "sha256-X2ANkJOXOwr+JTk9m8GMRPIjJlf0yg2V6jHHAutmtzk="; + }; + + configureFlags = [ + "--prefix=${placeholder "out"}" + "--build=${buildPlatform.config}" + "--host=${hostPlatform.config}" + # libstdbuf.so fails in static builds + "--enable-no-install-program=stdbuf" + "--enable-single-binary=symlinks" + "CC=musl-gcc" + "CFLAGS=-static" + ]; +in +bash.runCommand "${pname}-${version}" + { + inherit pname version meta; + + nativeBuildInputs = [ + gcc + musl + binutils + gnumake + gnused + gnugrep + gawk + diffutils + findutils + gnutar + gzip + ]; + + passthru.tests.get-version = + result: + bash.runCommand "${pname}-get-version-${version}" { } '' + ${result}/bin/coreutils --version + mkdir $out + ''; + } + '' + # Unpack + tar xzf ${src} + cd coreutils-${version} + + # Configure + bash ./configure ${lib.concatStringsSep " " configureFlags} + + # Build + make -j $NIX_BUILD_CORES + + # Install + make -j $NIX_BUILD_CORES install + '' diff --git a/pkgs/os-specific/linux/minimal-bootstrap/default.nix b/pkgs/os-specific/linux/minimal-bootstrap/default.nix index cc469eb20c24..c2d78e1e079e 100644 --- a/pkgs/os-specific/linux/minimal-bootstrap/default.nix +++ b/pkgs/os-specific/linux/minimal-bootstrap/default.nix @@ -52,13 +52,18 @@ lib.makeScope gnutar = gnutar-musl; }; - coreutils = callPackage ./coreutils { tinycc = tinycc-mes; }; - coreutils-musl = callPackage ./coreutils/musl.nix { - bash = bash_2_05; - tinycc = tinycc-musl; - gnumake = gnumake-musl; - gnutar = gnutar-musl; - }; + coreutils = callPackage ./coreutils { tinycc = tinycc-mes; }; + coreutils-musl = callPackage ./coreutils/musl.nix { + bash = bash_2_05; + tinycc = tinycc-musl; + gnumake = gnumake-musl; + gnutar = gnutar-musl; + }; + coreutils-static = callPackage ./coreutils/static.nix { + gcc = gcc-latest; + gnumake = gnumake-musl; + gnutar = gnutar-latest; + }; diffutils = callPackage ./diffutils { bash = bash_2_05; @@ -234,34 +239,34 @@ lib.makeScope inherit (callPackage ./utils.nix { }) derivationWithMeta writeTextFile writeText; - test = kaem.runCommand "minimal-bootstrap-test" { } '' - echo ${bash.tests.get-version} - echo ${bash_2_05.tests.get-version} - echo ${binutils.tests.get-version} - echo ${bzip2.tests.get-version} - echo ${coreutils-musl.tests.get-version} - echo ${diffutils.tests.get-version} - echo ${findutils.tests.get-version} - echo ${gawk-mes.tests.get-version} - echo ${gawk.tests.get-version} - echo ${gcc46.tests.get-version} - echo ${gcc46-cxx.tests.hello-world} - echo ${gcc8.tests.hello-world} - echo ${gcc-latest.tests.hello-world} - echo ${gnugrep.tests.get-version} - echo ${gnused.tests.get-version} - echo ${gnused-mes.tests.get-version} - echo ${gnutar.tests.get-version} - echo ${gnutar-musl.tests.get-version} - echo ${gnutar-latest.tests.get-version} - echo ${gzip.tests.get-version} - echo ${heirloom.tests.get-version} - echo ${mes.compiler.tests.get-version} - echo ${musl.tests.hello-world} - echo ${tinycc-mes.compiler.tests.chain} - echo ${tinycc-musl.compiler.tests.hello-world} - echo ${xz.tests.get-version} - mkdir ''${out} - ''; - } - ) + test = kaem.runCommand "minimal-bootstrap-test" {} '' + echo ${bash.tests.get-version} + echo ${bash_2_05.tests.get-version} + echo ${binutils.tests.get-version} + echo ${bzip2.tests.get-version} + echo ${coreutils-musl.tests.get-version} + echo ${coreutils-static.tests.get-version} + echo ${diffutils.tests.get-version} + echo ${findutils.tests.get-version} + echo ${gawk-mes.tests.get-version} + echo ${gawk.tests.get-version} + echo ${gcc46.tests.get-version} + echo ${gcc46-cxx.tests.hello-world} + echo ${gcc8.tests.hello-world} + echo ${gcc-latest.tests.hello-world} + echo ${gnugrep.tests.get-version} + echo ${gnused.tests.get-version} + echo ${gnused-mes.tests.get-version} + echo ${gnutar.tests.get-version} + echo ${gnutar-musl.tests.get-version} + echo ${gnutar-latest.tests.get-version} + echo ${gzip.tests.get-version} + echo ${heirloom.tests.get-version} + echo ${mes.compiler.tests.get-version} + echo ${musl.tests.hello-world} + echo ${tinycc-mes.compiler.tests.chain} + echo ${tinycc-musl.compiler.tests.hello-world} + echo ${xz.tests.get-version} + mkdir ''${out} + ''; + })