minimal-bootstrap: add static packages (#459002)

This commit is contained in:
Jo
2026-01-12 12:29:38 +00:00
committed by GitHub
39 changed files with 2012 additions and 124 deletions
@@ -11,6 +11,7 @@
bash_2_05,
}:
let
inherit (import ./common.nix { inherit lib; }) meta;
pname = "bash";
version = "2.05b";
@@ -69,7 +70,7 @@ let
in
kaem.runCommand "${pname}-${version}"
{
inherit pname version;
inherit pname version meta;
nativeBuildInputs = [
tinycc.compiler
@@ -124,14 +125,6 @@ kaem.runCommand "${pname}-${version}"
${result}/bin/bash --version
mkdir ''${out}
'';
meta = {
description = "GNU Bourne-Again Shell, the de facto standard shell on Linux";
homepage = "https://www.gnu.org/software/bash";
license = lib.licenses.gpl3Plus;
teams = [ lib.teams.minimal-bootstrap ];
platforms = lib.platforms.unix;
};
}
''
# Unpack
@@ -0,0 +1,10 @@
{ lib }:
{
meta = {
description = "GNU Bourne-Again Shell, the de facto standard shell on Linux";
homepage = "https://www.gnu.org/software/bash";
license = lib.licenses.gpl3Plus;
teams = [ lib.teams.minimal-bootstrap ];
platforms = lib.platforms.unix;
};
}
@@ -18,6 +18,7 @@
coreutils,
}:
let
inherit (import ./common.nix { inherit lib; }) meta;
pname = "bash";
version = "5.2.37";
@@ -33,7 +34,7 @@ let
in
bootBash.runCommand "${pname}-${version}"
{
inherit pname version;
inherit pname version meta;
nativeBuildInputs = [
coreutils
@@ -85,24 +86,15 @@ bootBash.runCommand "${pname}-${version}"
}
// (removeAttrs env [ "nativeBuildInputs" ])
);
passthru.tests.get-version =
result:
bootBash.runCommand "${pname}-get-version-${version}" { } ''
${result}/bin/bash --version
mkdir $out
'';
meta = {
description = "GNU Bourne-Again Shell, the de facto standard shell on Linux";
homepage = "https://www.gnu.org/software/bash";
license = lib.licenses.gpl3Plus;
teams = [ lib.teams.minimal-bootstrap ];
platforms = lib.platforms.unix;
};
}
''
# Unpack
# unpack
tar xzf ${src}
cd bash-${version}
@@ -0,0 +1,75 @@
{
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 = "bash-static";
version = "5.2.15";
src = fetchurl {
url = "mirror://gnu/bash/bash-${version}.tar.gz";
sha256 = "132qng0jy600mv1fs95ylnlisx2wavkkgpb19c6kmz7lnmjhjwhk";
};
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/bash --version
mkdir $out
'';
}
''
# Unpack
tar xf ${src}
cd bash-${version}
# Configure
bash ./configure \
--prefix=$out \
--build=${buildPlatform.config} \
--host=${hostPlatform.config} \
--without-bash-malloc \
--enable-static-link \
bash_cv_func_strtoimax=y \
CC=musl-gcc
# Build
make -j $NIX_BUILD_CORES
# Install
make -j $NIX_BUILD_CORES install-strip
rm $out/bin/bashbug
''
@@ -0,0 +1,10 @@
{ lib }:
{
meta = {
description = "Tools for manipulating binaries (linker, assembler, etc.)";
homepage = "https://www.gnu.org/software/binutils";
license = lib.licenses.gpl3Plus;
teams = [ lib.teams.minimal-bootstrap ];
platforms = lib.platforms.unix;
};
}
@@ -18,6 +18,7 @@
let
# Based on https://github.com/ZilchOS/bootstrap-from-tcc/blob/2e0c68c36b3437386f786d619bc9a16177f2e149/using-nix/2a1-static-binutils.nix
inherit (import ./common.nix { inherit lib; }) meta;
pname = "binutils";
version = "2.41";
@@ -53,7 +54,7 @@ let
in
bash.runCommand "${pname}-${version}"
{
inherit pname version;
inherit pname version meta;
nativeBuildInputs = [
tinycc.compiler
@@ -73,14 +74,6 @@ bash.runCommand "${pname}-${version}"
${result}/bin/ld --version
mkdir $out
'';
meta = {
description = "Tools for manipulating binaries (linker, assembler, etc.)";
homepage = "https://www.gnu.org/software/binutils";
license = lib.licenses.gpl3Plus;
teams = [ lib.teams.minimal-bootstrap ];
platforms = lib.platforms.unix;
};
}
''
# Unpack
@@ -0,0 +1,101 @@
{
lib,
buildPlatform,
hostPlatform,
fetchurl,
bash,
gcc,
musl,
binutils,
gnumake,
gnupatch,
gnused,
gnugrep,
gawk,
diffutils,
findutils,
gnutar,
xz,
}:
let
inherit (import ./common.nix { inherit lib; }) meta;
pname = "binutils-static";
version = "2.41";
src = fetchurl {
url = "mirror://gnu/binutils/binutils-${version}.tar.xz";
hash = "sha256-rppXieI0WeWWBuZxRyPy0//DHAMXQZHvDQFb3wYAdFA=";
};
patches = [
# Make binutils output deterministic by default.
./deterministic.patch
];
configureFlags = [
"CC=musl-gcc"
"LDFLAGS=--static"
"--prefix=${placeholder "out"}"
"--build=${buildPlatform.config}"
"--host=${hostPlatform.config}"
"--with-sysroot=/"
"--enable-deterministic-archives"
# depends on bison
"--disable-gprofng"
# Turn on --enable-new-dtags by default to make the linker set
# RUNPATH instead of RPATH on binaries. This is important because
# RUNPATH can be overridden using LD_LIBRARY_PATH at runtime.
"--enable-new-dtags"
# By default binutils searches $libdir for libraries. This brings in
# libbfd and libopcodes into a default visibility. Drop default lib
# path to force users to declare their use of these libraries.
"--with-lib-path=:"
];
in
bash.runCommand "${pname}-${version}"
{
inherit pname version meta;
nativeBuildInputs = [
gcc
musl
binutils
gnumake
gnupatch
gnused
gnugrep
gawk
diffutils
findutils
gnutar
xz
];
passthru.tests.get-version =
result:
bash.runCommand "${pname}-get-version-${version}" { } ''
${result}/bin/ld --version
mkdir $out
'';
}
''
# Unpack
tar xf ${src}
cd binutils-${version}
# Patch
${lib.concatMapStringsSep "\n" (f: "patch -Np1 -i ${f}") patches}
# Configure
bash ./configure ${lib.concatStringsSep " " configureFlags}
# Build
make -j $NIX_BUILD_CORES
# Install
# strip to remove build dependency store path references
make -j $NIX_BUILD_CORES install-strip
''
@@ -0,0 +1,80 @@
{
lib,
buildPlatform,
hostPlatform,
fetchurl,
bash,
gcc,
musl,
binutils,
gnumake,
gnused,
gnugrep,
gawk,
diffutils,
findutils,
gnutar,
xz,
gnum4,
}:
let
pname = "bison";
version = "3.8.2";
src = fetchurl {
url = "mirror://gnu/bison/bison-${version}.tar.xz";
hash = "sha256-m7oCFMz38QecXVkhAEUie89hlRmEDr+oDNOEnP9aW/I=";
};
in
bash.runCommand "${pname}-${version}"
{
inherit pname version;
nativeBuildInputs = [
gcc
musl
binutils
gnumake
gnused
gnugrep
gawk
diffutils
findutils
gnutar
xz
gnum4
];
passthru.tests.get-version =
result:
bash.runCommand "${pname}-get-version-${version}" { } ''
${result}/bin/bison --version
mkdir $out
'';
meta = {
description = "Yacc-compatible parser generator";
homepage = "https://www.gnu.org/software/bison/";
license = lib.licenses.gpl3Plus;
platforms = lib.platforms.unix;
teams = [ lib.teams.minimal-bootstrap ];
};
}
''
# Unpack
tar xf ${src}
cd bison-${version}
# Configure
bash ./configure \
--prefix=$out \
--build=${buildPlatform.config} \
--host=${hostPlatform.config} \
CC=musl-gcc
# Build
make -j $NIX_BUILD_CORES
# Install
make -j $NIX_BUILD_CORES install
''
@@ -0,0 +1,23 @@
Allow BusyBox to be invoked as "<something>-busybox". This is
necessary when it's run from the Nix store as <hash>-busybox during
stdenv bootstrap.
--- a/libbb/appletlib.c
+++ b/libbb/appletlib.c
@@ -947,7 +947,7 @@ void FAST_FUNC run_applet_no_and_exit(int applet_no, const char *name, char **ar
static NORETURN void run_applet_and_exit(const char *name, char **argv)
{
# if ENABLE_BUSYBOX
- if (is_prefixed_with(name, "busybox"))
+ if (strstr(name, "busybox") != 0)
exit(busybox_main(/*unused:*/ 0, argv));
# endif
# if NUM_APPLETS > 0
@@ -1045,7 +1045,7 @@ int main(int argc UNUSED_PARAM, char **argv)
lbb_prepare("busybox" IF_FEATURE_INDIVIDUAL(, argv));
# if !ENABLE_BUSYBOX
- if (argv[1] && is_prefixed_with(bb_basename(argv[0]), "busybox"))
+ if (argv[1] && strstr(bb_basename(argv[0]), "busybox") != 0)
argv++;
# endif
applet_name = argv[0];
@@ -0,0 +1,92 @@
{
lib,
fetchurl,
bash,
gcc,
musl,
binutils,
linux-headers,
gnumake,
gnupatch,
gnused,
gnugrep,
gawk,
diffutils,
findutils,
gnutar,
bzip2,
}:
let
pname = "busybox-static";
version = "1.36.1";
src = fetchurl {
url = "https://busybox.net/downloads/busybox-${version}.tar.bz2";
hash = "sha256-uMwkyVdNgJ5yecO+NJeVxdXOtv3xnKcJ+AzeUOR94xQ=";
};
patches = [
./busybox-in-store.patch
];
busyboxConfig = [
"CC=musl-gcc"
"HOSTCC=musl-gcc"
"CFLAGS=-I${linux-headers}/include"
"KCONFIG_NOTIMESTAMP=y"
"CONFIG_PREFIX=${placeholder "out"}"
"CONFIG_STATIC=y"
];
in
bash.runCommand "${pname}-${version}"
{
inherit pname version;
nativeBuildInputs = [
gcc
musl
binutils
gnumake
gnupatch
gnused
gnugrep
gawk
diffutils
findutils
gnutar
bzip2
];
passthru.tests.get-version =
result:
bash.runCommand "${pname}-get-version-${version}" { } ''
${result}
mkdir $out
'';
meta = {
description = "Tiny versions of common UNIX utilities in a single small executable";
homepage = "https://busybox.net/";
license = lib.licenses.gpl2Only;
platforms = lib.platforms.linux;
teams = [ lib.teams.minimal-bootstrap ];
};
}
''
# Unpack
tar xf ${src}
cd busybox-${version}
# Patch
${lib.concatMapStringsSep "\n" (f: "patch -Np1 -i ${f}") patches}
# Configure
BUSYBOX_FLAGS="${lib.concatStringsSep " " busyboxConfig}"
make -j $NIX_BUILD_CORES $BUSYBOX_FLAGS defconfig
# Build
make -j $NIX_BUILD_CORES $BUSYBOX_FLAGS
# Install
cp busybox $out
''
@@ -0,0 +1,63 @@
{
lib,
fetchurl,
bash,
gcc,
musl,
binutils,
gnumake,
gnutar,
gzip,
}:
let
pname = "bzip2-static";
version = "1.0.8";
src = fetchurl {
url = "https://sourceware.org/pub/bzip2/bzip2-${version}.tar.gz";
sha256 = "0s92986cv0p692icqlw1j42y9nld8zd83qwhzbqd61p1dqbh6nmb";
};
in
bash.runCommand "${pname}-${version}"
{
inherit pname version;
nativeBuildInputs = [
gcc
musl
binutils
gnumake
gnutar
gzip
];
passthru.tests.get-version =
result:
bash.runCommand "${pname}-get-version-${version}" { } ''
${result}/bin/bzip2 --help
mkdir $out
'';
meta = {
description = "High-quality data compression program";
homepage = "https://www.sourceware.org/bzip2";
license = lib.licenses.bsdOriginal;
platforms = lib.platforms.unix;
teams = [ lib.teams.minimal-bootstrap ];
};
}
''
# Unpack
tar xf ${src}
cd bzip2-${version}
# Build
make \
-j $NIX_BUILD_CORES \
CC=musl-gcc \
CFLAGS=-static \
bzip2 bzip2recover
# Install
make install -j $NIX_BUILD_CORES PREFIX=$out
''
@@ -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;
};
}
@@ -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
@@ -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
@@ -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
''
@@ -40,25 +40,61 @@ lib.makeScope
gnutar = gnutar-musl;
};
bash-static = callPackage ./bash/static.nix {
gcc = gcc-latest;
gnumake = gnumake-musl;
gnutar = gnutar-latest;
};
binutils = callPackage ./binutils {
tinycc = tinycc-musl;
gnumake = gnumake-musl;
gnutar = gnutar-musl;
};
binutils-static = callPackage ./binutils/static.nix {
gcc = gcc-latest;
gnumake = gnumake-musl;
gnutar = gnutar-latest;
};
bison = callPackage ./bison {
gcc = gcc-latest;
gnumake = gnumake-musl;
gnutar = gnutar-latest;
};
busybox-static = callPackage ./busybox/static.nix {
gcc = gcc-latest;
gnumake = gnumake-musl;
gnutar = gnutar-latest;
};
bzip2 = callPackage ./bzip2 {
tinycc = tinycc-musl;
gnumake = gnumake-musl;
gnutar = gnutar-musl;
};
bzip2-static = callPackage ./bzip2/static.nix {
gcc = gcc-latest;
gnumake = gnumake-musl;
gnutar = gnutar-latest;
};
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;
@@ -67,6 +103,12 @@ lib.makeScope
gnutar = gnutar-musl;
};
diffutils-static = callPackage ./diffutils/static.nix {
gcc = gcc-latest;
gnumake = gnumake-musl;
gnutar = gnutar-latest;
};
findutils = callPackage ./findutils {
tinycc = tinycc-musl;
gnumake = gnumake-musl;
@@ -78,6 +120,11 @@ lib.makeScope
tinycc = tinycc-mes;
gnused = gnused-mes;
};
findutils-static = callPackage ./findutils/static.nix {
gcc = gcc-latest;
gnumake = gnumake-musl;
gnutar = gnutar-latest;
};
gawk = callPackage ./gawk {
bash = bash_2_05;
@@ -94,6 +141,7 @@ lib.makeScope
# FIXME: not sure why new gawk doesn't work
gawk = gawk-mes;
};
gcc46-cxx = callPackage ./gcc/4.6.cxx.nix {
gcc = gcc46;
gnumake = gnumake-musl;
@@ -118,11 +166,31 @@ lib.makeScope
gawk = gawk-mes;
};
glibc = callPackage ./glibc {
gcc = gcc-latest;
gnumake = gnumake-musl;
gnutar = gnutar-latest;
gnugrep = gnugrep-static;
gawk = gawk-static;
};
gnugrep = callPackage ./gnugrep {
bash = bash_2_05;
tinycc = tinycc-mes;
};
gnugrep-static = callPackage ./gnugrep/static.nix {
gcc = gcc-latest;
gnumake = gnumake-musl;
gnutar = gnutar-latest;
};
gnum4 = callPackage ./gnum4 {
gcc = gcc-latest;
gnumake = gnumake-musl;
gnutar = gnutar-latest;
};
gnumake = callPackage ./gnumake { tinycc = tinycc-bootstrappable; };
gnumake-musl = callPackage ./gnumake/musl.nix {
@@ -132,35 +200,66 @@ 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; };
gnupatch-static = callPackage ./gnupatch/static.nix {
gcc = gcc-latest;
gnumake = gnumake-musl;
gnutar = gnutar-latest;
};
gnused = callPackage ./gnused {
bash = bash_2_05;
tinycc = tinycc-musl;
gnused = gnused-mes;
};
gnused-mes = callPackage ./gnused/mes.nix {
bash = bash_2_05;
tinycc = tinycc-bootstrappable;
};
gnused-static = callPackage ./gnused/static.nix {
gcc = gcc-latest;
gnumake = gnumake-musl;
gnutar = gnutar-latest;
};
gnutar = callPackage ./gnutar/mes.nix {
bash = bash_2_05;
tinycc = tinycc-mes;
gnused = gnused-mes;
};
# FIXME: better package naming scheme
gnutar-latest = callPackage ./gnutar/latest.nix {
gcc = gcc46;
gnumake = gnumake-musl;
gnutarBoot = gnutar-musl;
};
gnutar-musl = callPackage ./gnutar/musl.nix {
bash = bash_2_05;
tinycc = tinycc-musl;
gnused = gnused-mes;
};
# FIXME: better package naming scheme
gnutar-latest = callPackage ./gnutar/latest.nix {
gcc = gcc46;
gnutar-static = callPackage ./gnutar/static.nix {
gcc = gcc-latest;
gnumake = gnumake-musl;
gnutarBoot = gnutar-musl;
gnutarBoot = gnutar-latest;
};
gzip-static = callPackage ./gzip/static.nix {
gcc = gcc-latest;
gnumake = gnumake-musl;
gnutar = gnutar-latest;
};
gzip = callPackage ./gzip {
@@ -176,11 +275,16 @@ lib.makeScope
heirloom-devtools = callPackage ./heirloom-devtools { tinycc = tinycc-mes; };
linux-headers = callPackage ./linux-headers { bash = bash_2_05; };
linux-headers = callPackage ./linux-headers {
gcc = gcc-latest;
gnumake = gnumake-musl;
gnutar = gnutar-latest;
};
ln-boot = callPackage ./ln-boot { };
mes = callPackage ./mes { };
mes-libc = callPackage ./mes/libc.nix { };
musl11-intermediate = callPackage ./musl/1.1.nix {
@@ -188,6 +292,7 @@ lib.makeScope
tinycc = tinycc-mes;
gnused = gnused-mes;
};
musl11 = callPackage ./musl/1.1.nix {
bash = bash_2_05;
tinycc = tinycc-musl-intermediate;
@@ -199,6 +304,18 @@ lib.makeScope
gnumake = gnumake-musl;
};
patchelf-static = callPackage ./patchelf/static.nix {
gcc = gcc-latest;
gnumake = gnumake-musl;
gnutar = gnutar-latest;
};
python = callPackage ./python {
gcc = gcc-latest;
gnumake = gnumake-musl;
gnutar = gnutar-latest;
};
stage0-posix = callPackage ./stage0-posix { };
inherit (self.stage0-posix)
@@ -209,7 +326,9 @@ lib.makeScope
;
tinycc-bootstrappable = lib.recurseIntoAttrs (callPackage ./tinycc/bootstrappable.nix { });
tinycc-mes = lib.recurseIntoAttrs (callPackage ./tinycc/mes.nix { });
tinycc-musl-intermediate = lib.recurseIntoAttrs (
callPackage ./tinycc/musl.nix {
bash = bash_2_05;
@@ -217,6 +336,7 @@ lib.makeScope
tinycc = tinycc-mes;
}
);
tinycc-musl = lib.recurseIntoAttrs (
callPackage ./tinycc/musl.nix {
bash = bash_2_05;
@@ -225,6 +345,12 @@ lib.makeScope
}
);
gawk-static = callPackage ./gawk/static.nix {
gcc = gcc-latest;
gnumake = gnumake-musl;
gnutar = gnutar-latest;
};
xz = callPackage ./xz {
bash = bash_2_05;
tinycc = tinycc-musl;
@@ -232,32 +358,57 @@ lib.makeScope
gnutar = gnutar-musl;
};
inherit (callPackage ./utils.nix { }) derivationWithMeta writeTextFile writeText;
zlib = callPackage ./zlib {
gcc = gcc-latest;
gnumake = gnumake-musl;
gnutar = gnutar-latest;
};
inherit (callPackage ./utils.nix { }) derivationWithMeta writeTextFile writeText;
test = kaem.runCommand "minimal-bootstrap-test" { } ''
echo ${bash.tests.get-version}
echo ${bash-static.tests.get-version}
echo ${bash_2_05.tests.get-version}
echo ${binutils.tests.get-version}
echo ${binutils-static.tests.get-version}
echo ${bison.tests.get-version}
echo ${busybox-static.tests.get-version}
echo ${bzip2.tests.get-version}
echo ${bzip2-static.tests.get-version}
echo ${coreutils-musl.tests.get-version}
echo ${coreutils-static.tests.get-version}
echo ${diffutils.tests.get-version}
echo ${diffutils-static.tests.get-version}
echo ${findutils.tests.get-version}
echo ${gawk-mes.tests.get-version}
echo ${findutils-static.tests.get-version}
echo ${gawk.tests.get-version}
echo ${gawk-mes.tests.get-version}
echo ${gawk-static.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 ${glibc.tests.hello-world}
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 ${gnupatch-static.tests.get-version}
echo ${gnused.tests.get-version}
echo ${gnused-mes.tests.get-version}
echo ${gnused-static.tests.get-version}
echo ${gnutar.tests.get-version}
echo ${gnutar-musl.tests.get-version}
echo ${gnutar-latest.tests.get-version}
echo ${gnutar-musl.tests.get-version}
echo ${gnutar-static.tests.get-version}
echo ${gzip.tests.get-version}
echo ${gzip-static.tests.get-version}
echo ${heirloom.tests.get-version}
echo ${mes.compiler.tests.get-version}
echo ${musl.tests.hello-world}
echo ${patchelf-static.tests.get-version}
echo ${python.tests.get-version}
echo ${tinycc-mes.compiler.tests.chain}
echo ${tinycc-musl.compiler.tests.hello-world}
echo ${xz.tests.get-version}
@@ -0,0 +1,80 @@
{
lib,
buildPlatform,
hostPlatform,
fetchurl,
bash,
gcc,
musl,
binutils,
gnumake,
gnused,
gnugrep,
gawk,
diffutils,
findutils,
gnutar,
xz,
}:
let
pname = "diffutils-static";
version = "3.12";
src = fetchurl {
url = "mirror://gnu/diffutils/diffutils-${version}.tar.xz";
hash = "sha256-fIt/n8hgkUH96pzs6FJJ0whiQ5H/Yd7a9Sj8szdyff0=";
};
in
bash.runCommand "${pname}-${version}"
{
inherit pname version;
nativeBuildInputs = [
gcc
musl
binutils
gnumake
gnused
gnugrep
gawk
diffutils
findutils
gnutar
xz
];
passthru.tests.get-version =
result:
bash.runCommand "${pname}-get-version-${version}" { } ''
${result}/bin/diff --version
mkdir $out
'';
meta = {
description = "Commands for showing the differences between files (diff, cmp, etc.)";
homepage = "https://www.gnu.org/software/diffutils/diffutils.html";
license = lib.licenses.gpl3Only;
platforms = lib.platforms.unix;
teams = [ lib.teams.minimal-bootstrap ];
};
}
''
# Unpack
tar xf ${src}
cd diffutils-${version}
# Configure
bash ./configure \
--prefix=$out \
--build=${buildPlatform.config} \
--host=${hostPlatform.config} \
CC=musl-gcc \
CFLAGS=-static \
ac_cv_path_PR_PROGRAM=pr
# Build
make -j $NIX_BUILD_CORES
# Install
make -j $NIX_BUILD_CORES install
''
@@ -0,0 +1,80 @@
{
lib,
buildPlatform,
hostPlatform,
fetchurl,
bash,
gcc,
musl,
binutils,
gnumake,
gnused,
gnugrep,
gawk,
diffutils,
findutils,
gnutar,
xz,
}:
let
pname = "findutils-static";
version = "4.9.0";
src = fetchurl {
url = "mirror://gnu/findutils/findutils-${version}.tar.xz";
hash = "sha256-or+4wJ1DZ3DtxZ9Q+kg+eFsWGjt7nVR1c8sIBl/UYv4=";
};
in
bash.runCommand "${pname}-${version}"
{
inherit pname version;
nativeBuildInputs = [
gcc
musl
binutils
gnumake
gnused
gnugrep
gawk
diffutils
findutils
gnutar
xz
];
passthru.tests.get-version =
result:
bash.runCommand "${pname}-get-version-${version}" { } ''
${result}/bin/find --version
mkdir $out
'';
meta = {
description = "GNU Find Utilities, the basic directory searching utilities of the GNU operating system";
homepage = "https://www.gnu.org/software/findutils";
license = lib.licenses.gpl3Plus;
platforms = lib.platforms.unix;
teams = [ lib.teams.minimal-bootstrap ];
};
}
''
# Unpack
tar xf ${src}
cd findutils-${version}
# 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
rm $out/bin/updatedb
''
@@ -0,0 +1,73 @@
{
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 = "gawk-static";
version = "5.3.2";
src = fetchurl {
url = "mirror://gnu/gawk/gawk-${version}.tar.gz";
hash = "sha256-hjmhqI+0EaG+AmY3OdA+kCptMTtcb+Ak0L/rM0GhmhE=";
};
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/awk --version
mkdir $out
'';
}
''
# Unpack
tar xf ${src}
cd gawk-${version}
# 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
rm $out/bin/gawkbug
''
@@ -0,0 +1,112 @@
{
lib,
buildPlatform,
hostPlatform,
fetchurl,
bash,
gcc,
binutils,
linux-headers,
gnumake,
gnused,
gnugrep,
gawk,
diffutils,
findutils,
python,
bison,
gnutar,
xz,
}:
let
pname = "glibc";
version = "2.38";
src = fetchurl {
url = "mirror://gnu/libc/glibc-${version}.tar.xz";
hash = "sha256-+4KZiZiyspllRnvBtp0VLpwwfSzzAcnq+0VVt3DvP9I=";
};
linkerFile =
{
x86_64-linux = "ld-linux-x86-64";
i686-linux = "ld-linux";
}
.${buildPlatform.system};
in
bash.runCommand "${pname}-${version}"
{
inherit pname version;
nativeBuildInputs = [
gcc
binutils
gnumake
gnused
gnugrep
gawk
diffutils
findutils
python
bison
gnutar
xz
];
passthru.tests.hello-world =
result:
bash.runCommand "${pname}-simple-program-${version}"
{
nativeBuildInputs = [
gcc
binutils
];
}
''
cat <<EOF >> test.c
#include <stdio.h>
int main() {
printf("Hello World!\n");
return 0;
}
EOF
gcc \
-Wl,--dynamic-linker=${result}/lib/${linkerFile}.so.2 \
-B${result}/lib \
-I${result}/include \
-o test test.c
./test
mkdir $out
'';
meta = {
description = "The GNU C Library";
homepage = "https://www.gnu.org/software/libc/";
license = lib.licenses.lgpl2Plus;
platforms = lib.platforms.linux;
teams = [ lib.teams.minimal-bootstrap ];
};
}
''
# Unpack
tar xf ${src}
cd glibc-${version}
# Configure
mkdir build
cd build
# libstdc++.so is built against musl and fails to link
export CXX=false
bash ../configure \
--prefix=$out \
--build=${buildPlatform.config} \
--host=${hostPlatform.config} \
--with-headers=${linux-headers}/include
# Build
make -j $NIX_BUILD_CORES
# Install
make -j $NIX_BUILD_CORES INSTALL_UNCOMPRESSED=yes install
find $out/{bin,sbin,lib,libexec} -type f -exec strip --strip-unneeded {} + || true
''
@@ -0,0 +1,81 @@
{
lib,
buildPlatform,
hostPlatform,
fetchurl,
bash,
gcc,
musl,
binutils,
gnumake,
gnused,
gnugrep,
gawk,
diffutils,
findutils,
gnutar,
xz,
}:
let
pname = "gnugrep-static";
version = "3.11";
src = fetchurl {
url = "mirror://gnu/grep/grep-${version}.tar.xz";
hash = "sha256-HbKu3eidDepCsW2VKPiUyNFdrk4ZC1muzHj1qVEnbqs=";
};
in
bash.runCommand "${pname}-${version}"
{
inherit pname version;
nativeBuildInputs = [
gcc
musl
binutils
gnumake
gnused
gnugrep
gawk
diffutils
findutils
gnutar
xz
];
passthru.tests.get-version =
result:
bash.runCommand "${pname}-get-version-${version}" { } ''
${result}/bin/grep --version
mkdir $out
'';
meta = {
description = "GNU implementation of the Unix grep command";
homepage = "https://www.gnu.org/software/grep";
license = lib.licenses.gpl3Plus;
mainProgram = "grep";
platforms = lib.platforms.unix;
teams = [ lib.teams.minimal-bootstrap ];
};
}
''
# Unpack
tar xf ${src}
cd grep-${version}
# 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
rm $out/bin/{egrep,fgrep}
''
@@ -0,0 +1,79 @@
{
lib,
buildPlatform,
hostPlatform,
fetchurl,
bash,
gcc,
musl,
binutils,
gnumake,
gnused,
gnugrep,
gawk,
diffutils,
findutils,
gnutar,
xz,
}:
let
pname = "gnum4";
version = "1.4.20";
src = fetchurl {
url = "mirror://gnu/m4/m4-${version}.tar.xz";
hash = "sha256-4jbqOhzPX2wnCxxLtgcm83H6SUWajqrryQshazKNrys=";
};
in
bash.runCommand "${pname}-${version}"
{
inherit pname version;
nativeBuildInputs = [
gcc
musl
binutils
gnumake
gnused
gnugrep
gawk
diffutils
findutils
gnutar
xz
];
passthru.tests.get-version =
result:
bash.runCommand "${pname}-get-version-${version}" { } ''
${result}/bin/m4 --version
mkdir $out
'';
meta = {
description = "GNU M4, a macro processor";
homepage = "https://www.gnu.org/software/m4/";
license = lib.licenses.gpl3Plus;
platforms = lib.platforms.unix;
mainProgram = "m4";
teams = [ lib.teams.minimal-bootstrap ];
};
}
''
# Unpack
tar xf ${src}
cd m4-${version}
# Configure
bash ./configure \
--prefix=$out \
--build=${buildPlatform.config} \
--host=${hostPlatform.config} \
CC=musl-gcc
# Build
make -j $NIX_BUILD_CORES
# Install
make -j $NIX_BUILD_CORES install
''
@@ -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;
};
}
@@ -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
@@ -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
@@ -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
''
@@ -0,0 +1,80 @@
{
lib,
buildPlatform,
hostPlatform,
fetchurl,
bash,
gcc,
musl,
binutils,
gnumake,
gnused,
gnugrep,
gawk,
diffutils,
findutils,
gnutar,
xz,
}:
let
pname = "gnupatch-static";
version = "2.8";
src = fetchurl {
url = "mirror://gnu/patch/patch-${version}.tar.xz";
hash = "sha256-+Hzuae7CtPy/YKOWsDCtaqNBXxkqpffuhMrV4R9/WuM=";
};
in
bash.runCommand "${pname}-${version}"
{
inherit pname version;
nativeBuildInputs = [
gcc
musl
binutils
gnumake
gnused
gnugrep
gawk
diffutils
findutils
gnutar
xz
];
passthru.tests.get-version =
result:
bash.runCommand "${pname}-get-version-${version}" { } ''
${result}/bin/patch --version
mkdir $out
'';
meta = {
description = "GNU Patch, a program to apply differences to files";
homepage = "https://www.gnu.org/software/patch";
license = lib.licenses.gpl3Plus;
mainProgram = "patch";
platforms = lib.platforms.unix;
teams = [ lib.teams.minimal-bootstrap ];
};
}
''
# Unpack
tar xf ${src}
cd patch-${version}
# 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
''
@@ -0,0 +1,72 @@
{
lib,
buildPlatform,
hostPlatform,
fetchurl,
bash,
gcc,
musl,
binutils,
gnumake,
gnused,
gnugrep,
gawk,
diffutils,
findutils,
gnutar,
xz,
}:
let
inherit (import ./common.nix { inherit lib; }) meta;
pname = "gnused-static";
version = "4.9";
src = fetchurl {
url = "mirror://gnu/sed/sed-${version}.tar.xz";
hash = "sha256-biJrcy4c1zlGStaGK9Ghq6QteYKSLaelNRljHSSXUYE=";
};
in
bash.runCommand "${pname}-${version}"
{
inherit pname version meta;
nativeBuildInputs = [
gcc
musl
binutils
gnumake
gnused
gnugrep
gawk
diffutils
findutils
gnutar
xz
];
passthru.tests.get-version =
result:
bash.runCommand "${pname}-get-version-${version}" { } ''
${result}/bin/sed --version
mkdir $out
'';
}
''
# Unpack
tar xf ${src}
cd sed-${version}
# 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
''
@@ -0,0 +1,11 @@
{ lib }:
{
meta = {
description = "GNU implementation of the `tar' archiver";
homepage = "https://www.gnu.org/software/tar";
license = lib.licenses.gpl3Plus;
teams = [ lib.teams.minimal-bootstrap ];
mainProgram = "tar";
platforms = lib.platforms.unix;
};
}
@@ -15,6 +15,7 @@
gnutarBoot,
}:
let
inherit (import ./common.nix { inherit lib; }) meta;
pname = "gnutar";
version = "1.35";
@@ -25,7 +26,7 @@ let
in
bash.runCommand "${pname}-${version}"
{
inherit pname version;
inherit pname version meta;
nativeBuildInputs = [
gcc
@@ -45,15 +46,6 @@ bash.runCommand "${pname}-${version}"
${result}/bin/tar --version
mkdir $out
'';
meta = {
description = "GNU implementation of the `tar' archiver";
homepage = "https://www.gnu.org/software/tar";
license = lib.licenses.gpl3Plus;
teams = [ lib.teams.minimal-bootstrap ];
mainProgram = "tar";
platforms = lib.platforms.unix;
};
}
''
# Unpack
@@ -10,6 +10,7 @@
gnugrep,
}:
let
inherit (import ./common.nix { inherit lib; }) meta;
pname = "gnutar";
# >= 1.13 is incompatible with mes-libc
version = "1.12";
@@ -21,7 +22,7 @@ let
in
bash.runCommand "${pname}-${version}"
{
inherit pname version;
inherit pname version meta;
nativeBuildInputs = [
tinycc.compiler
@@ -36,15 +37,6 @@ bash.runCommand "${pname}-${version}"
${result}/bin/tar --version
mkdir $out
'';
meta = {
description = "GNU implementation of the `tar' archiver";
homepage = "https://www.gnu.org/software/tar";
license = lib.licenses.gpl3Plus;
teams = [ lib.teams.minimal-bootstrap ];
mainProgram = "tar";
platforms = lib.platforms.unix;
};
}
''
# Unpack
@@ -12,6 +12,7 @@
let
# gnutar with musl preserves modify times, allowing make to not try
# rebuilding pregenerated files
inherit (import ./common.nix { inherit lib; }) meta;
pname = "gnutar-musl";
version = "1.12";
@@ -22,7 +23,7 @@ let
in
bash.runCommand "${pname}-${version}"
{
inherit pname version;
inherit pname version meta;
nativeBuildInputs = [
tinycc.compiler
@@ -37,15 +38,6 @@ bash.runCommand "${pname}-${version}"
${result}/bin/tar --version
mkdir $out
'';
meta = {
description = "GNU implementation of the `tar' archiver";
homepage = "https://www.gnu.org/software/tar";
license = lib.licenses.gpl3Plus;
teams = [ lib.teams.minimal-bootstrap ];
mainProgram = "tar";
platforms = lib.platforms.unix;
};
}
''
# Unpack
@@ -0,0 +1,72 @@
{
lib,
buildPlatform,
hostPlatform,
fetchurl,
bash,
gcc,
musl,
binutils,
gnumake,
gnused,
gnugrep,
gawk,
diffutils,
findutils,
gnutarBoot,
gzip,
}:
let
inherit (import ./common.nix { inherit lib; }) meta;
pname = "gnutar-static";
version = "1.35";
src = fetchurl {
url = "mirror://gnu/tar/tar-${version}.tar.gz";
hash = "sha256-FNVeMgY+qVJuBX+/Nfyr1TN452l4fv95GcN1WwLStX4=";
};
in
bash.runCommand "${pname}-${version}"
{
inherit pname version meta;
nativeBuildInputs = [
gcc
musl
binutils
gnumake
gnused
gnugrep
gawk
diffutils
findutils
gnutarBoot
gzip
];
passthru.tests.get-version =
result:
bash.runCommand "${pname}-get-version-${version}" { } ''
${result}/bin/tar --version
mkdir $out
'';
}
''
# Unpack
tar xzf ${src}
cd tar-${version}
# 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
''
@@ -0,0 +1,79 @@
{
lib,
buildPlatform,
hostPlatform,
fetchurl,
bash,
gcc,
musl,
binutils,
gnumake,
gnused,
gnugrep,
gawk,
diffutils,
findutils,
gnutar,
xz,
}:
let
pname = "gzip-static";
version = "1.13";
src = fetchurl {
url = "mirror://gnu/gzip/gzip-${version}.tar.xz";
hash = "sha256-dFTraTXbF8ZlVXbC4bD6vv04tNCTbg+H9IzQYs6RoFc=";
};
in
bash.runCommand "${pname}-${version}"
{
inherit pname version;
nativeBuildInputs = [
gcc
musl
binutils
gnumake
gnused
gnugrep
gawk
diffutils
findutils
gnutar
xz
];
passthru.tests.get-version =
result:
bash.runCommand "${pname}-get-version-${version}" { } ''
${result}/bin/gzip --version
mkdir $out
'';
meta = {
description = "GNU zip compression program";
homepage = "https://www.gnu.org/software/gzip";
license = lib.licenses.gpl3Plus;
platforms = lib.platforms.unix;
teams = [ lib.teams.minimal-bootstrap ];
};
}
''
# Unpack
tar xf ${src}
cd gzip-${version}
# Configure
bash ./configure \
--prefix=$out \
--build=${buildPlatform.config} \
--host=${hostPlatform.config} \
CC=musl-gcc \
CFLAGS=-static
# Build
make -j $NIX_BUILD_CORES bin_SCRIPTS=
# Install
make -j $NIX_BUILD_CORES bin_SCRIPTS= install
''
@@ -2,26 +2,25 @@
lib,
fetchurl,
bash,
gcc,
musl,
binutils,
gnumake,
gnused,
gnugrep,
gawk,
diffutils,
findutils,
gnutar,
xz,
}:
let
# WARNING: You probably don't want to use this package outside minimal-bootstrap
#
# We need some set of Linux kernel headers to build our bootstrap packages
# (gcc/binutils/glibc etc.) against. As long as it compiles it is "good enough".
# Therefore the requirement for correctness, completeness, platform-specific
# features, and being up-to-date, are very loose.
#
# Rebuilding the Linux headers from source correctly is something we can defer
# till we have access to gcc/binutils/perl. For now we can use Guix's assembled
# kernel header distribution and assume it's good enough.
pname = "linux-headers";
version = "4.14.67";
version = "6.5.6";
src = fetchurl {
url = "mirror://gnu/gnu/guix/bootstrap/i686-linux/20190815/linux-libre-headers-stripped-4.14.67-i686-linux.tar.xz";
sha256 = "0sm2z9x4wk45bh6qfs94p0w1d6hsy6dqx9sw38qsqbvxwa1qzk8s";
url = "mirror://kernel/linux/kernel/v${lib.versions.major version}.x/linux-${version}.tar.xz";
hash = "sha256-eONtQhRUcFHCTfIUD0zglCjWxRWtmnGziyjoCUqV0vY=";
};
in
bash.runCommand "${pname}-${version}"
@@ -29,6 +28,15 @@ bash.runCommand "${pname}-${version}"
inherit pname version;
nativeBuildInputs = [
gcc
musl
binutils
gnumake
gnused
gnugrep
gawk
diffutils
findutils
gnutar
xz
];
@@ -36,17 +44,20 @@ bash.runCommand "${pname}-${version}"
meta = {
description = "Header files and scripts for Linux kernel";
license = lib.licenses.gpl2Only;
teams = [ lib.teams.minimal-bootstrap ];
platforms = lib.platforms.linux;
teams = [ lib.teams.minimal-bootstrap ];
};
}
''
# Unpack
cp ${src} linux-headers.tar.xz
unxz linux-headers.tar.xz
tar xf linux-headers.tar
tar xf ${src}
cd linux-${version}
# Build
make -j $NIX_BUILD_CORES CC=musl-gcc HOSTCC=musl-gcc ARCH=x86 headers
# Install
mkdir $out
cp -r include $out
find usr/include -name '.*' -exec rm {} +
mkdir -p $out
cp -rv usr/include $out/
''
@@ -0,0 +1,79 @@
{
lib,
buildPlatform,
hostPlatform,
fetchurl,
bash,
gcc,
musl,
binutils,
gnumake,
gnused,
gnugrep,
gawk,
diffutils,
findutils,
gnutar,
gzip,
}:
let
pname = "patchelf-static";
version = "0.18.0";
src = fetchurl {
url = "https://github.com/NixOS/patchelf/releases/download/${version}/patchelf-${version}.tar.gz";
sha256 = "sha256-ZN4Q5Ma4uDedt+h/WAMPM26nR8BRXzgRMugQ2/hKhuc=";
};
in
bash.runCommand "${pname}-${version}"
{
inherit pname version;
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/patchelf --version
mkdir $out
'';
meta = {
description = "A small utility to modify the dynamic linker and RPATH of ELF executables";
homepage = "https://github.com/NixOS/patchelf";
license = lib.licenses.gpl3Plus;
platforms = lib.platforms.unix;
teams = [ lib.teams.minimal-bootstrap ];
};
}
''
# Unpack
tar xf ${src}
cd patchelf-${version}
# Configure
bash ./configure \
--prefix=$out \
--build=${buildPlatform.config} \
--host=${hostPlatform.config} \
CC=musl-gcc \
CXXFLAGS=-static
# Build
make -j $NIX_BUILD_CORES
# Install
make -j $NIX_BUILD_CORES install-strip
''
@@ -0,0 +1,98 @@
{
lib,
buildPlatform,
hostPlatform,
fetchurl,
bash,
gcc,
musl,
binutils,
gnumake,
gnupatch,
gnused,
gnugrep,
gawk,
diffutils,
findutils,
gnutar,
xz,
zlib,
}:
let
pname = "python";
version = "3.13.7";
src = fetchurl {
url = "https://www.python.org/ftp/python/${version}/Python-${version}.tar.xz";
hash = "sha256-VGL5CZ39MOI43vg8cdkYl9jKpf9uvHpQ8U1IAs2qp5o=";
};
patches = [
# Disable the use of ldconfig in ctypes.util.find_library (since
# ldconfig doesn't work on NixOS), and don't use
# ctypes.util.find_library during the loading of the uuid module
# (since it will do a futile invocation of gcc (!) to find
# libuuid, slowing down program startup a lot).
./no-ldconfig.patch
];
in
bash.runCommand "${pname}-${version}"
{
inherit pname version;
nativeBuildInputs = [
gcc
musl
binutils
gnumake
gnupatch
gnused
gnugrep
gawk
diffutils
findutils
gnutar
xz
];
passthru.tests.get-version =
result:
bash.runCommand "${pname}-get-version-${version}" { } ''
${result}/bin/python3 --version
mkdir $out
'';
meta = {
description = "A high-level dynamically-typed programming language";
homepage = "https://www.python.org";
license = lib.licenses.psfl;
mainProgram = "python3";
platforms = lib.platforms.linux;
teams = [ lib.teams.minimal-bootstrap ];
};
}
''
# Unpack
tar xf ${src}
cd Python-${version}
# Patch
${lib.concatMapStringsSep "\n" (f: "patch -Np1 -i ${f}") patches}
# Configure
export CC=musl-gcc
export C_INCLUDE_PATH="${zlib}/include"
export LIBRARY_PATH="${zlib}/lib"
export LDFLAGS="-Wl,-rpath,${zlib}/lib -L${zlib}/lib"
export LD_LIBRARY_PATH="$LIBRARY_PATH"
bash ./configure \
--prefix=$out \
--build=${buildPlatform.config} \
--host=${hostPlatform.config}
# Build
make -j $NIX_BUILD_CORES
# Install
make -j $NIX_BUILD_CORES install
''
@@ -0,0 +1,107 @@
From 5330b6af9f832af59aa5c61d9ef6971053a8e709 Mon Sep 17 00:00:00 2001
From: Jonathan Ringer <jonringer117@gmail.com>
Date: Mon, 9 Nov 2020 10:24:35 -0800
Subject: [PATCH] CPython: Don't use ldconfig
---
Lib/ctypes/util.py | 77 ++--------------------------------------------
1 file changed, 2 insertions(+), 75 deletions(-)
diff --git a/Lib/ctypes/util.py b/Lib/ctypes/util.py
index 0c2510e161..7fb98af308 100644
--- a/Lib/ctypes/util.py
+++ b/Lib/ctypes/util.py
@@ -100,53 +100,7 @@ def _is_elf(filename):
return thefile.read(4) == elf_header
def _findLib_gcc(name):
- # Run GCC's linker with the -t (aka --trace) option and examine the
- # library name it prints out. The GCC command will fail because we
- # haven't supplied a proper program with main(), but that does not
- # matter.
- expr = os.fsencode(r'[^\(\)\s]*lib%s\.[^\(\)\s]*' % re.escape(name))
-
- c_compiler = shutil.which('gcc')
- if not c_compiler:
- c_compiler = shutil.which('cc')
- if not c_compiler:
- # No C compiler available, give up
- return None
-
- temp = tempfile.NamedTemporaryFile()
- try:
- args = [c_compiler, '-Wl,-t', '-o', temp.name, '-l' + name]
-
- env = dict(os.environ)
- env['LC_ALL'] = 'C'
- env['LANG'] = 'C'
- try:
- proc = subprocess.Popen(args,
- stdout=subprocess.PIPE,
- stderr=subprocess.STDOUT,
- env=env)
- except OSError: # E.g. bad executable
- return None
- with proc:
- trace = proc.stdout.read()
- finally:
- try:
- temp.close()
- except FileNotFoundError:
- # Raised if the file was already removed, which is the normal
- # behaviour of GCC if linking fails
- pass
- res = re.findall(expr, trace)
- if not res:
- return None
-
- for file in res:
- # Check if the given file is an elf file: gcc can report
- # some files that are linker scripts and not actual
- # shared objects. See bpo-41976 for more details
- if not _is_elf(file):
- continue
- return os.fsdecode(file)
+ return None
if sys.platform == "sunos5":
@@ -268,34 +222,7 @@ def find_library(name, is64 = False):
else:
def _findSoname_ldconfig(name):
- import struct
- if struct.calcsize('l') == 4:
- machine = os.uname().machine + '-32'
- else:
- machine = os.uname().machine + '-64'
- mach_map = {
- 'x86_64-64': 'libc6,x86-64',
- 'ppc64-64': 'libc6,64bit',
- 'sparc64-64': 'libc6,64bit',
- 's390x-64': 'libc6,64bit',
- 'ia64-64': 'libc6,IA-64',
- }
- abi_type = mach_map.get(machine, 'libc6')
-
- # XXX assuming GLIBC's ldconfig (with option -p)
- regex = r'\s+(lib%s\.[^\s]+)\s+\(%s'
- regex = os.fsencode(regex % (re.escape(name), abi_type))
- try:
- with subprocess.Popen(['/sbin/ldconfig', '-p'],
- stdin=subprocess.DEVNULL,
- stderr=subprocess.DEVNULL,
- stdout=subprocess.PIPE,
- env={'LC_ALL': 'C', 'LANG': 'C'}) as p:
- res = re.search(regex, p.stdout.read())
- if res:
- return os.fsdecode(res.group(1))
- except OSError:
- pass
+ return None
def _findLib_ld(name):
# See issue #9998 for why this is needed
--
2.33.1
@@ -0,0 +1,60 @@
{
lib,
fetchurl,
bash,
gcc,
musl,
binutils,
gnumake,
gnused,
gnugrep,
gnutar,
xz,
}:
let
pname = "zlib";
version = "1.3.1";
src = fetchurl {
url = "https://github.com/madler/zlib/releases/download/v${version}/zlib-${version}.tar.xz";
hash = "sha256-OO+WuN/lENQnB9nHgYd5FHklQRM+GHCEFGO/pz+IPjI=";
};
in
bash.runCommand "${pname}-${version}"
{
inherit pname version;
nativeBuildInputs = [
gcc
musl
binutils
gnumake
gnused
gnugrep
gnutar
xz
];
meta = {
description = "Lossless data-compression library";
homepage = "https://zlib.net";
license = lib.licenses.zlib;
platforms = lib.platforms.unix;
teams = [ lib.teams.minimal-bootstrap ];
};
}
''
# Unpack
tar xf ${src}
cd zlib-${version}
# Configure
export CC=musl-gcc
bash ./configure --prefix=$out
# Build
make -j $NIX_BUILD_CORES
# Install
make -j $NIX_BUILD_CORES install
''