Compare commits

..

3 commits

100 changed files with 1203 additions and 2179 deletions

View file

@ -1,5 +1,5 @@
#!/usr/bin/env nix-shell #!/usr/bin/env nix-shell
#!nix-shell -i bash -I "nixpkgs=https://github.com/nixos/nixpkgs/archive/nixos-unstable.tar.gz" -p nixfmt-rfc-style #!nix-shell -i bash -I "nixpkgs=https://github.com/nixos/nixpkgs/archive/nixos-24.05.tar.gz" -p nixfmt-rfc-style
files=$(find . -name "*.nix" -type f) files=$(find . -name "*.nix" -type f)

View file

@ -3,18 +3,17 @@
"lib": { "lib": {
"locked": { "locked": {
"dir": "lib", "dir": "lib",
"lastModified": 1723737980, "dirtyRev": "9850da8aa9dc9be22e237c9b424a18e801e53ecb-dirty",
"narHash": "sha256-1WnFatW5kSuO2jjt62hvSbH84TSYyO+VmvkJ0d5e/ZY=", "dirtyShortRev": "9850da8-dirty",
"ref": "master", "lastModified": 1718529861,
"rev": "cadfaabc853d20f2bc20bad794fcbe520ea48f13", "narHash": "sha256-tv/0C7ixH+9Ij+r+5nua48OlXXXnbdEsnenxX4eG/Sk=",
"revCount": 82,
"type": "git", "type": "git",
"url": "file:../" "url": "file:../?dir=lib"
}, },
"original": { "original": {
"dir": "lib", "dir": "lib",
"type": "git", "type": "git",
"url": "file:../" "url": "file:../?dir=lib"
} }
}, },
"root": { "root": {

View file

@ -14,7 +14,10 @@
modules = import ./src; modules = import ./src;
forEachSystem = lib.attrs.generate [ "i686-linux" ]; forEachSystem = lib.attrs.generate [
"i686-linux"
"x86_64-linux"
];
in in
{ {
extras = extras =

View file

@ -34,7 +34,10 @@ in
platforms = lib.options.create { platforms = lib.options.create {
type = lib.types.list.of lib.types.string; type = lib.types.list.of lib.types.string;
description = "Platforms the package supports."; description = "Platforms the package supports.";
default.value = [ "i686-linux" ]; default.value = [
"i686-linux"
"x86_64-linux"
];
}; };
}; };

View file

@ -42,7 +42,10 @@ in
platforms = lib.options.create { platforms = lib.options.create {
type = lib.types.list.of lib.types.string; type = lib.types.list.of lib.types.string;
description = "Platforms the package supports."; description = "Platforms the package supports.";
default.value = [ "i686-linux" ]; default.value = [
"i686-linux"
"x86_64-linux"
];
}; };
}; };

View file

@ -125,7 +125,10 @@ in
platforms = lib.options.create { platforms = lib.options.create {
type = lib.types.list.of lib.types.string; type = lib.types.list.of lib.types.string;
description = "Platforms the package supports."; description = "Platforms the package supports.";
default.value = [ "i686-linux" ]; default.value = [
"i686-linux"
"x86_64-linux"
];
}; };
}; };

View file

@ -41,7 +41,10 @@ in
platforms = lib.options.create { platforms = lib.options.create {
type = lib.types.list.of lib.types.string; type = lib.types.list.of lib.types.string;
description = "Platforms the package supports."; description = "Platforms the package supports.";
default.value = [ "i686-linux" ]; default.value = [
"i686-linux"
"x86_64-linux"
];
}; };
}; };

View file

@ -33,7 +33,10 @@ in
platforms = lib.options.create { platforms = lib.options.create {
type = lib.types.list.of lib.types.string; type = lib.types.list.of lib.types.string;
description = "Platforms the package supports."; description = "Platforms the package supports.";
default.value = [ "i686-linux" ]; default.value = [
"i686-linux"
"x86_64-linux"
];
}; };
}; };

View file

@ -34,7 +34,10 @@ in
platforms = lib.options.create { platforms = lib.options.create {
type = lib.types.list.of lib.types.string; type = lib.types.list.of lib.types.string;
description = "Platforms the package supports."; description = "Platforms the package supports.";
default.value = [ "i686-linux" ]; default.value = [
"i686-linux"
"x86_64-linux"
];
}; };
}; };

View file

@ -35,7 +35,10 @@ in
platforms = lib.options.create { platforms = lib.options.create {
type = lib.types.list.of lib.types.string; type = lib.types.list.of lib.types.string;
description = "Platforms the package supports."; description = "Platforms the package supports.";
default.value = [ "i686-linux" ]; default.value = [
"i686-linux"
"x86_64-linux"
];
}; };
}; };

View file

@ -35,7 +35,10 @@ in
platforms = lib.options.create { platforms = lib.options.create {
type = lib.types.list.of lib.types.string; type = lib.types.list.of lib.types.string;
description = "Platforms the package supports."; description = "Platforms the package supports.";
default.value = [ "i686-linux" ]; default.value = [
"i686-linux"
"x86_64-linux"
];
}; };
}; };

View file

@ -36,7 +36,10 @@ in
platforms = lib.options.create { platforms = lib.options.create {
type = lib.types.list.of lib.types.string; type = lib.types.list.of lib.types.string;
description = "Platforms the package supports."; description = "Platforms the package supports.";
default.value = [ "i686-linux" ]; default.value = [
"i686-linux"
"x86_64-linux"
];
}; };
}; };

View file

@ -37,7 +37,10 @@ in
platforms = lib.options.create { platforms = lib.options.create {
type = lib.types.list.of lib.types.string; type = lib.types.list.of lib.types.string;
description = "Platforms the package supports."; description = "Platforms the package supports.";
default.value = [ "i686-linux" ]; default.value = [
"i686-linux"
"x86_64-linux"
];
}; };
}; };

View file

@ -38,7 +38,10 @@ in
platforms = lib.options.create { platforms = lib.options.create {
type = lib.types.list.of lib.types.string; type = lib.types.list.of lib.types.string;
description = "Platforms the package supports."; description = "Platforms the package supports.";
default.value = [ "i686-linux" ]; default.value = [
"i686-linux"
"x86_64-linux"
];
}; };
}; };

View file

@ -39,7 +39,10 @@ in
platforms = lib.options.create { platforms = lib.options.create {
type = lib.types.list.of lib.types.string; type = lib.types.list.of lib.types.string;
description = "Platforms the package supports."; description = "Platforms the package supports.";
default.value = [ "i686-linux" ]; default.value = [
"i686-linux"
"x86_64-linux"
];
}; };
}; };

View file

@ -40,7 +40,10 @@ in
platforms = lib.options.create { platforms = lib.options.create {
type = lib.types.list.of lib.types.string; type = lib.types.list.of lib.types.string;
description = "Platforms the package supports."; description = "Platforms the package supports.";
default.value = [ "i686-linux" ]; default.value = [
"i686-linux"
"x86_64-linux"
];
}; };
}; };

View file

@ -41,7 +41,10 @@ in
platforms = lib.options.create { platforms = lib.options.create {
type = lib.types.list.of lib.types.string; type = lib.types.list.of lib.types.string;
description = "Platforms the package supports."; description = "Platforms the package supports.";
default.value = [ "i686-linux" ]; default.value = [
"i686-linux"
"x86_64-linux"
];
}; };
}; };

View file

@ -40,7 +40,10 @@ in
platforms = lib.options.create { platforms = lib.options.create {
type = lib.types.list.of lib.types.string; type = lib.types.list.of lib.types.string;
description = "Platforms the package supports."; description = "Platforms the package supports.";
default.value = [ "i686-linux" ]; default.value = [
"i686-linux"
"x86_64-linux"
];
}; };
}; };

View file

@ -40,7 +40,10 @@ in
platforms = lib.options.create { platforms = lib.options.create {
type = lib.types.list.of lib.types.string; type = lib.types.list.of lib.types.string;
description = "Platforms the package supports."; description = "Platforms the package supports.";
default.value = [ "i686-linux" ]; default.value = [
"i686-linux"
"x86_64-linux"
];
}; };
}; };

View file

@ -31,7 +31,10 @@ in
platforms = lib.options.create { platforms = lib.options.create {
type = lib.types.list.of lib.types.string; type = lib.types.list.of lib.types.string;
description = "Platforms the package supports."; description = "Platforms the package supports.";
default.value = [ "i686-linux" ]; default.value = [
"i686-linux"
"x86_64-linux"
];
}; };
}; };

View file

@ -34,7 +34,10 @@ in
platforms = lib.options.create { platforms = lib.options.create {
type = lib.types.list.of lib.types.string; type = lib.types.list.of lib.types.string;
description = "Platforms the package supports."; description = "Platforms the package supports.";
default.value = [ "i686-linux" ]; default.value = [
"i686-linux"
"x86_64-linux"
];
}; };
mainProgram = lib.options.create { mainProgram = lib.options.create {
@ -106,7 +109,8 @@ in
export CC="tcc -B ${stage1.tinycc.musl.libs.package}/lib" export CC="tcc -B ${stage1.tinycc.musl.libs.package}/lib"
export AR="tcc -ar" export AR="tcc -ar"
export LD=tcc export LD=tcc
bash ./configure \ chmod +x ./configure
./configure \
--prefix=$out \ --prefix=$out \
--build=${platform.build} \ --build=${platform.build} \
--host=${platform.host} \ --host=${platform.host} \

View file

@ -32,7 +32,10 @@ in
platforms = lib.options.create { platforms = lib.options.create {
type = lib.types.list.of lib.types.string; type = lib.types.list.of lib.types.string;
description = "Platforms the package supports."; description = "Platforms the package supports.";
default.value = [ "i686-linux" ]; default.value = [
"i686-linux"
"x86_64-linux"
];
}; };
}; };
@ -130,7 +133,8 @@ in
export AR="tcc -ar" export AR="tcc -ar"
export lt_cv_sys_max_cmd_len=32768 export lt_cv_sys_max_cmd_len=32768
export CFLAGS="-D__LITTLE_ENDIAN__=1" export CFLAGS="-D__LITTLE_ENDIAN__=1"
bash ./configure ${builtins.concatStringsSep " " configureFlags} chmod +x ./configure
./configure ${builtins.concatStringsSep " " configureFlags}
# Build # Build
make -j $NIX_BUILD_CORES all-libiberty all-gas all-bfd all-libctf all-zlib all-gprof make -j $NIX_BUILD_CORES all-libiberty all-gas all-bfd all-libctf all-zlib all-gprof

View file

@ -32,7 +32,10 @@ in
platforms = lib.options.create { platforms = lib.options.create {
type = lib.types.list.of lib.types.string; type = lib.types.list.of lib.types.string;
description = "Platforms the package supports."; description = "Platforms the package supports.";
default.value = [ "i686-linux" ]; default.value = [
"i686-linux"
"x86_64-linux"
];
}; };
}; };
@ -86,7 +89,8 @@ in
cd bison-${cfg.version} cd bison-${cfg.version}
# Configure # Configure
bash ./configure \ chmod +x ./configure
./configure \
--prefix=$out \ --prefix=$out \
--build=${platform.build} \ --build=${platform.build} \
--host=${platform.host} \ --host=${platform.host} \

View file

@ -33,7 +33,10 @@ in
type = lib.types.list.of lib.types.string; type = lib.types.list.of lib.types.string;
description = "Platforms the package supports."; description = "Platforms the package supports.";
# TODO: Support more platforms. # TODO: Support more platforms.
default.value = [ "i686-linux" ]; default.value = [
"i686-linux"
"x86_64-linux"
];
}; };
}; };

View file

@ -34,7 +34,10 @@ in
platforms = lib.options.create { platforms = lib.options.create {
type = lib.types.list.of lib.types.string; type = lib.types.list.of lib.types.string;
description = "Platforms the package supports."; description = "Platforms the package supports.";
default.value = [ "i686-linux" ]; default.value = [
"i686-linux"
"x86_64-linux"
];
}; };
}; };
@ -98,7 +101,8 @@ in
# Configure # Configure
export CC="tcc -B ${stage1.tinycc.musl.libs.package}/lib" export CC="tcc -B ${stage1.tinycc.musl.libs.package}/lib"
export LD=tcc export LD=tcc
bash ./configure ${builtins.concatStringsSep " " configureFlags} chmod +x ./configure
./configure ${builtins.concatStringsSep " " configureFlags}
# Build # Build
make -j $NIX_BUILD_CORES AR="tcc -ar" MAKEINFO="true" make -j $NIX_BUILD_CORES AR="tcc -ar" MAKEINFO="true"

View file

@ -32,7 +32,10 @@ in
platforms = lib.options.create { platforms = lib.options.create {
type = lib.types.list.of lib.types.string; type = lib.types.list.of lib.types.string;
description = "Platforms the package supports."; description = "Platforms the package supports.";
default.value = [ "i686-linux" ]; default.value = [
"i686-linux"
"x86_64-linux"
];
}; };
}; };
@ -87,7 +90,8 @@ in
# Configure # Configure
export CC="tcc -B ${stage1.tinycc.musl.libs.package}/lib" export CC="tcc -B ${stage1.tinycc.musl.libs.package}/lib"
export LD=tcc export LD=tcc
bash ./configure \ chmod +x ./configure
./configure \
--prefix=$out \ --prefix=$out \
--build=${platform.build} \ --build=${platform.build} \
--host=${platform.host} --host=${platform.host}

View file

@ -32,7 +32,10 @@ in
platforms = lib.options.create { platforms = lib.options.create {
type = lib.types.list.of lib.types.string; type = lib.types.list.of lib.types.string;
description = "Platforms the package supports."; description = "Platforms the package supports.";
default.value = [ "i686-linux" ]; default.value = [
"i686-linux"
"x86_64-linux"
];
}; };
}; };
@ -92,7 +95,8 @@ in
export CC="tcc -B ${stage1.tinycc.musl.libs.package}/lib" export CC="tcc -B ${stage1.tinycc.musl.libs.package}/lib"
export AR="tcc -ar" export AR="tcc -ar"
export LD=tcc export LD=tcc
bash ./configure \ chmod +x ./configure
./configure \
--prefix=$out \ --prefix=$out \
--build=${platform.build} \ --build=${platform.build} \
--host=${platform.host} --host=${platform.host}

View file

@ -68,8 +68,8 @@ in
export CC="tcc -B ${stage1.tinycc.mes.libs.package}/lib" export CC="tcc -B ${stage1.tinycc.mes.libs.package}/lib"
export ac_cv_func_getpgrp_void=yes export ac_cv_func_getpgrp_void=yes
export ac_cv_func_tzset=yes export ac_cv_func_tzset=yes
chmod 0755 missing chmod +x ./configure
bash ./configure \ ./configure \
--build=${platform.build} \ --build=${platform.build} \
--host=${platform.host} \ --host=${platform.host} \
--disable-nls \ --disable-nls \

View file

@ -34,7 +34,10 @@ in
platforms = lib.options.create { platforms = lib.options.create {
type = lib.types.list.of lib.types.string; type = lib.types.list.of lib.types.string;
description = "Platforms the package supports."; description = "Platforms the package supports.";
default.value = [ "i686-linux" ]; default.value = [
"i686-linux"
"x86_64-linux"
];
}; };
mainProgram = lib.options.create { mainProgram = lib.options.create {
@ -93,7 +96,8 @@ in
export CC="tcc -B ${stage1.tinycc.musl.libs.package}/lib" export CC="tcc -B ${stage1.tinycc.musl.libs.package}/lib"
export AR="tcc -ar" export AR="tcc -ar"
export LD=tcc export LD=tcc
bash ./configure \ chmod +x ./configure
./configure \
--prefix=$out \ --prefix=$out \
--build=${platform.build} \ --build=${platform.build} \
--host=${platform.host} --host=${platform.host}

View file

@ -38,7 +38,10 @@ in
platforms = lib.options.create { platforms = lib.options.create {
type = lib.types.list.of lib.types.string; type = lib.types.list.of lib.types.string;
description = "Platforms the package supports."; description = "Platforms the package supports.";
default.value = [ "i686-linux" ]; default.value = [
"i686-linux"
"x86_64-linux"
];
}; };
}; };
@ -197,7 +200,8 @@ in
export CFLAGS_FOR_TARGET="-Wl,-dynamic-linker -Wl,${stage1.musl.package}/lib/libc.so" export CFLAGS_FOR_TARGET="-Wl,-dynamic-linker -Wl,${stage1.musl.package}/lib/libc.so"
export LIBRARY_PATH="${stage1.musl.package}/lib" export LIBRARY_PATH="${stage1.musl.package}/lib"
bash ./configure \ chmod +x ./configure
./configure \
--prefix=$out \ --prefix=$out \
--build=${platform.build} \ --build=${platform.build} \
--host=${platform.host} \ --host=${platform.host} \

View file

@ -162,7 +162,8 @@ in
export CPLUS_INCLUDE_PATH="$C_INCLUDE_PATH" export CPLUS_INCLUDE_PATH="$C_INCLUDE_PATH"
export LIBRARY_PATH="${stage1.musl.package}/lib" export LIBRARY_PATH="${stage1.musl.package}/lib"
bash ./configure \ chmod +x ./configure
./configure \
--prefix=$out \ --prefix=$out \
--build=${platform.build} \ --build=${platform.build} \
--host=${platform.host} \ --host=${platform.host} \

View file

@ -163,7 +163,8 @@ in
export ac_cv_func_memcpy=yes export ac_cv_func_memcpy=yes
export ac_cv_func_strerror=yes export ac_cv_func_strerror=yes
bash ./configure \ chmod +x ./configure
./configure \
--prefix=$out \ --prefix=$out \
--build=${platform.build} \ --build=${platform.build} \
--host=${platform.host} \ --host=${platform.host} \

View file

@ -167,7 +167,8 @@ in
export CPLUS_INCLUDE_PATH="$C_INCLUDE_PATH" export CPLUS_INCLUDE_PATH="$C_INCLUDE_PATH"
export LIBRARY_PATH="${stage1.musl.package}/lib" export LIBRARY_PATH="${stage1.musl.package}/lib"
bash ./configure \ chmod +x ./configure
./configure \
--prefix=$out \ --prefix=$out \
--build=${platform.build} \ --build=${platform.build} \
--host=${platform.host} \ --host=${platform.host} \

View file

@ -31,7 +31,10 @@ in
platforms = lib.options.create { platforms = lib.options.create {
type = lib.types.list.of lib.types.string; type = lib.types.list.of lib.types.string;
description = "Platforms the package supports."; description = "Platforms the package supports.";
default.value = [ "i686-linux" ]; default.value = [
"i686-linux"
"x86_64-linux"
];
}; };
mainProgram = lib.options.create { mainProgram = lib.options.create {

View file

@ -32,7 +32,10 @@ in
platforms = lib.options.create { platforms = lib.options.create {
type = lib.types.list.of lib.types.string; type = lib.types.list.of lib.types.string;
description = "Platforms the package supports."; description = "Platforms the package supports.";
default.value = [ "i686-linux" ]; default.value = [
"i686-linux"
"x86_64-linux"
];
}; };
}; };
@ -85,7 +88,8 @@ in
cd m4-${cfg.version} cd m4-${cfg.version}
# Configure # Configure
bash ./configure \ chmod +x ./configure
./configure \
--prefix=$out \ --prefix=$out \
--build=${platform.build} \ --build=${platform.build} \
--host=${platform.host} \ --host=${platform.host} \

View file

@ -34,7 +34,10 @@ in
platforms = lib.options.create { platforms = lib.options.create {
type = lib.types.list.of lib.types.string; type = lib.types.list.of lib.types.string;
description = "Platforms the package supports."; description = "Platforms the package supports.";
default.value = [ "i686-linux" ]; default.value = [
"i686-linux"
"x86_64-linux"
];
}; };
}; };
@ -101,7 +104,8 @@ in
# Configure # Configure
export CC="tcc -B ${stage1.tinycc.musl.libs.package}/lib" export CC="tcc -B ${stage1.tinycc.musl.libs.package}/lib"
export LD=tcc export LD=tcc
bash ./configure \ chmod +x ./configure
./configure \
--prefix=$out \ --prefix=$out \
--build=${platform.build} \ --build=${platform.build} \
--host=${platform.host} --host=${platform.host}

View file

@ -31,7 +31,10 @@ in
platforms = lib.options.create { platforms = lib.options.create {
type = lib.types.list.of lib.types.string; type = lib.types.list.of lib.types.string;
description = "Platforms the package supports."; description = "Platforms the package supports.";
default.value = [ "i686-linux" ]; default.value = [
"i686-linux"
"x86_64-linux"
];
}; };
}; };

View file

@ -34,7 +34,10 @@ in
platforms = lib.options.create { platforms = lib.options.create {
type = lib.types.list.of lib.types.string; type = lib.types.list.of lib.types.string;
description = "Platforms the package supports."; description = "Platforms the package supports.";
default.value = [ "i686-linux" ]; default.value = [
"i686-linux"
"x86_64-linux"
];
}; };
mainProgram = lib.options.create { mainProgram = lib.options.create {

View file

@ -34,10 +34,7 @@ in
sha256 = "02m6gajm647n8l9a5bnld6fnbgdpyi4i3i83p7xcwv0kif47xhy6"; sha256 = "02m6gajm647n8l9a5bnld6fnbgdpyi4i3i83p7xcwv0kif47xhy6";
}; };
package = package = builders.bash.boot.build {
let
in
builders.bash.boot.build {
name = "gnutar-boot-${cfg.version}"; name = "gnutar-boot-${cfg.version}";
meta = stage1.gnutar.meta; meta = stage1.gnutar.meta;
@ -56,10 +53,13 @@ in
rm tar.tar rm tar.tar
cd tar-${cfg.version} cd tar-${cfg.version}
# Fix source permissions
chmod -R +r .
chmod +x ./configure
# Configure # Configure
export CC="tcc -B ${stage1.tinycc.mes.libs.package}/lib" export CC="tcc -B ${stage1.tinycc.mes.libs.package}/lib"
chmod 0755 missing ./configure \
bash ./configure \
--build=${platform.build} \ --build=${platform.build} \
--host=${platform.host} \ --host=${platform.host} \
--disable-nls \ --disable-nls \

View file

@ -37,7 +37,10 @@ in
platforms = lib.options.create { platforms = lib.options.create {
type = lib.types.list.of lib.types.string; type = lib.types.list.of lib.types.string;
description = "Platforms the package supports."; description = "Platforms the package supports.";
default.value = [ "i686-linux" ]; default.value = [
"i686-linux"
"x86_64-linux"
];
}; };
mainProgram = lib.options.create { mainProgram = lib.options.create {
@ -95,7 +98,8 @@ in
cd tar-${cfg.version} cd tar-${cfg.version}
# Configure # Configure
bash ./configure \ chmod +x ./configure
./configure \
--prefix=$out \ --prefix=$out \
--build=${platform.build} \ --build=${platform.build} \
--host=${platform.host} \ --host=${platform.host} \

View file

@ -59,8 +59,8 @@ in
export ac_cv_sizeof_unsigned_long=4 export ac_cv_sizeof_unsigned_long=4
export ac_cv_sizeof_long_long=8 export ac_cv_sizeof_long_long=8
export ac_cv_header_netdb_h=no export ac_cv_header_netdb_h=no
chmod 0755 missing chmod +x ./configure
bash ./configure \ ./configure \
--prefix=$out \ --prefix=$out \
--build=${platform.build} \ --build=${platform.build} \
--host=${platform.host} \ --host=${platform.host} \

View file

@ -31,7 +31,10 @@ in
platforms = lib.options.create { platforms = lib.options.create {
type = lib.types.list.of lib.types.string; type = lib.types.list.of lib.types.string;
description = "Platforms the package supports."; description = "Platforms the package supports.";
default.value = [ "i686-linux" ]; default.value = [
"i686-linux"
"x86_64-linux"
];
}; };
}; };
@ -60,10 +63,7 @@ in
sha256 = "0ryr5b00qz3xcdcv03qwjdfji8pasp0007ay3ppmk71wl8c1i90w"; sha256 = "0ryr5b00qz3xcdcv03qwjdfji8pasp0007ay3ppmk71wl8c1i90w";
}; };
package = package = builders.bash.boot.build {
let
in
builders.bash.boot.build {
name = "gzip-${cfg.version}"; name = "gzip-${cfg.version}";
meta = cfg.meta; meta = cfg.meta;
@ -83,7 +83,8 @@ in
# Configure # Configure
export CC="tcc -B ${stage1.tinycc.mes.libs.package}/lib -Dstrlwr=unused" export CC="tcc -B ${stage1.tinycc.mes.libs.package}/lib -Dstrlwr=unused"
bash ./configure --prefix=$out chmod +x ./configure
./configure --prefix=$out
# Build # Build
make make

View file

@ -45,7 +45,10 @@ in
platforms = lib.options.create { platforms = lib.options.create {
type = lib.types.list.of lib.types.string; type = lib.types.list.of lib.types.string;
description = "Platforms the package supports."; description = "Platforms the package supports.";
default.value = [ "i686-linux" ]; default.value = [
"i686-linux"
"x86_64-linux"
];
}; };
}; };

View file

@ -53,7 +53,10 @@ in
platforms = lib.options.create { platforms = lib.options.create {
type = lib.types.list.of lib.types.string; type = lib.types.list.of lib.types.string;
description = "Platforms the package supports."; description = "Platforms the package supports.";
default.value = [ "i686-linux" ]; default.value = [
"i686-linux"
"x86_64-linux"
];
}; };
}; };
}; };

View file

@ -26,7 +26,10 @@ in
platforms = lib.options.create { platforms = lib.options.create {
type = lib.types.list.of lib.types.string; type = lib.types.list.of lib.types.string;
description = "Platforms the package supports."; description = "Platforms the package supports.";
default.value = [ "i686-linux" ]; default.value = [
"i686-linux"
"x86_64-linux"
];
}; };
}; };

View file

@ -32,7 +32,10 @@ in
platforms = lib.options.create { platforms = lib.options.create {
type = lib.types.list.of lib.types.string; type = lib.types.list.of lib.types.string;
description = "Platforms the package supports."; description = "Platforms the package supports.";
default.value = [ "i686-linux" ]; default.value = [
"i686-linux"
"x86_64-linux"
];
}; };
}; };

View file

@ -33,7 +33,10 @@ in
platforms = lib.options.create { platforms = lib.options.create {
type = lib.types.list.of lib.types.string; type = lib.types.list.of lib.types.string;
description = "Platforms the package supports."; description = "Platforms the package supports.";
default.value = [ "i686-linux" ]; default.value = [
"i686-linux"
"x86_64-linux"
];
}; };
}; };

View file

@ -31,7 +31,10 @@ in
platforms = lib.options.create { platforms = lib.options.create {
type = lib.types.list.of lib.types.string; type = lib.types.list.of lib.types.string;
description = "Platforms the package supports."; description = "Platforms the package supports.";
default.value = [ "i686-linux" ]; default.value = [
"i686-linux"
"x86_64-linux"
];
}; };
}; };

View file

@ -33,7 +33,10 @@ in
platforms = lib.options.create { platforms = lib.options.create {
type = lib.types.list.of lib.types.string; type = lib.types.list.of lib.types.string;
description = "Platforms the package supports."; description = "Platforms the package supports.";
default.value = [ "i686-linux" ]; default.value = [
"i686-linux"
"x86_64-linux"
];
}; };
}; };

View file

@ -118,7 +118,8 @@ in
src/misc/wordexp.c src/misc/wordexp.c
# Configure # Configure
bash ./configure \ chmod +x configure
./configure \
--prefix=$out \ --prefix=$out \
--build=${platform.build} \ --build=${platform.build} \
--host=${platform.host} \ --host=${platform.host} \
@ -131,7 +132,6 @@ in
# Install # Install
make install make install
cp ${stage1.tinycc.mes.libs.package}/lib/libtcc1.a $out/lib cp ${stage1.tinycc.mes.libs.package}/lib/libtcc1.a $out/lib
''; '';
}; };
}; };

View file

@ -35,7 +35,10 @@ in
type = lib.types.list.of lib.types.string; type = lib.types.list.of lib.types.string;
description = "Platforms the package supports."; description = "Platforms the package supports.";
# TODO: Support more platforms. # TODO: Support more platforms.
default.value = [ "i686-linux" ]; default.value = [
"i686-linux"
"x86_64-linux"
];
}; };
}; };
@ -95,7 +98,8 @@ in
src/misc/wordexp.c src/misc/wordexp.c
# Configure # Configure
bash ./configure \ chmod +x ./configure
./configure \
--prefix=$out \ --prefix=$out \
--build=${platform.build} \ --build=${platform.build} \
--host=${platform.host} \ --host=${platform.host} \

View file

@ -34,7 +34,10 @@ in
platforms = lib.options.create { platforms = lib.options.create {
type = lib.types.list.of lib.types.string; type = lib.types.list.of lib.types.string;
description = "Platforms the package supports."; description = "Platforms the package supports.";
default.value = [ "i686-linux" ]; default.value = [
"i686-linux"
"x86_64-linux"
];
}; };
}; };

View file

@ -32,7 +32,10 @@ in
platforms = lib.options.create { platforms = lib.options.create {
type = lib.types.list.of lib.types.string; type = lib.types.list.of lib.types.string;
description = "Platforms the package supports."; description = "Platforms the package supports.";
default.value = [ "i686-linux" ]; default.value = [
"i686-linux"
"x86_64-linux"
];
}; };
}; };
@ -104,7 +107,8 @@ in
export C_INCLUDE_PATH="${stage1.zlib.package}/include" export C_INCLUDE_PATH="${stage1.zlib.package}/include"
export LIBRARY_PATH="${stage1.zlib.package}/lib" export LIBRARY_PATH="${stage1.zlib.package}/lib"
export LD_LIBRARY_PATH="$LIBRARY_PATH" export LD_LIBRARY_PATH="$LIBRARY_PATH"
bash ./configure \ chmod +x ./configure
./configure \
--prefix=$out \ --prefix=$out \
--build=${platform.build} \ --build=${platform.build} \
--host=${platform.host} --host=${platform.host}

View file

@ -38,6 +38,7 @@ in
default.value = [ default.value = [
"x86_64-linux" "x86_64-linux"
"i686-linux" "i686-linux"
"x86_64-linux"
]; ];
}; };
}; };

View file

@ -37,7 +37,10 @@ in
platforms = lib.options.create { platforms = lib.options.create {
type = lib.types.list.of lib.types.string; type = lib.types.list.of lib.types.string;
description = "Platforms the package supports."; description = "Platforms the package supports.";
default.value = [ "i686-linux" ]; default.value = [
"i686-linux"
"x86_64-linux"
];
}; };
}; };

View file

@ -35,7 +35,10 @@ in
platforms = lib.options.create { platforms = lib.options.create {
type = lib.types.list.of lib.types.string; type = lib.types.list.of lib.types.string;
description = "Platforms the package supports."; description = "Platforms the package supports.";
default.value = [ "i686-linux" ]; default.value = [
"i686-linux"
"x86_64-linux"
];
}; };
}; };
@ -88,7 +91,8 @@ in
export CC="tcc -B ${stage1.tinycc.musl.libs.package}/lib" export CC="tcc -B ${stage1.tinycc.musl.libs.package}/lib"
export AR="tcc -ar" export AR="tcc -ar"
export LD=tcc export LD=tcc
bash ./configure \ chmod +x configure
./configure \
--prefix=$out \ --prefix=$out \
--build=${platform.build} \ --build=${platform.build} \
--host=${platform.host} \ --host=${platform.host} \

View file

@ -32,7 +32,10 @@ in
platforms = lib.options.create { platforms = lib.options.create {
type = lib.types.list.of lib.types.string; type = lib.types.list.of lib.types.string;
description = "Platforms the package supports."; description = "Platforms the package supports.";
default.value = [ "i686-linux" ]; default.value = [
"i686-linux"
"x86_64-linux"
];
}; };
}; };
@ -83,7 +86,8 @@ in
# Configure # Configure
export CC=musl-gcc export CC=musl-gcc
bash ./configure --prefix=$out chmod +x configure
./configure --prefix=$out
# Build # Build
make -j $NIX_BUILD_CORES make -j $NIX_BUILD_CORES

View file

@ -32,7 +32,10 @@ in
platforms = lib.options.create { platforms = lib.options.create {
type = lib.types.list.of lib.types.string; type = lib.types.list.of lib.types.string;
description = "Platforms the package supports."; description = "Platforms the package supports.";
default.value = [ "i686-linux" ]; default.value = [
"i686-linux"
"x86_64-linux"
];
}; };
mainProgram = lib.options.create { mainProgram = lib.options.create {
@ -94,7 +97,8 @@ in
cd bash-${cfg.version} cd bash-${cfg.version}
# Configure # Configure
bash ./configure \ chmod +x ./configure
./configure \
--prefix=$out \ --prefix=$out \
--build=${platform.build} \ --build=${platform.build} \
--host=${platform.host} \ --host=${platform.host} \

View file

@ -32,7 +32,10 @@ in
platforms = lib.options.create { platforms = lib.options.create {
type = lib.types.list.of lib.types.string; type = lib.types.list.of lib.types.string;
description = "Platforms the package supports."; description = "Platforms the package supports.";
default.value = [ "i686-linux" ]; default.value = [
"i686-linux"
"x86_64-linux"
];
}; };
}; };
@ -120,7 +123,8 @@ in
${lib.strings.concatMapSep "\n" (file: "patch -Np1 -i ${file}") patches} ${lib.strings.concatMapSep "\n" (file: "patch -Np1 -i ${file}") patches}
# Configure # Configure
bash ./configure ${builtins.concatStringsSep " " configureFlags} chmod +x ./configure
./configure ${builtins.concatStringsSep " " configureFlags}
# Build # Build
make -j $NIX_BUILD_CORES make -j $NIX_BUILD_CORES

View file

@ -33,7 +33,10 @@ in
platforms = lib.options.create { platforms = lib.options.create {
type = lib.types.list.of lib.types.string; type = lib.types.list.of lib.types.string;
description = "Platforms the package supports."; description = "Platforms the package supports.";
default.value = [ "i686-linux" ]; default.value = [
"i686-linux"
"x86_64-linux"
];
}; };
}; };

View file

@ -33,7 +33,10 @@ in
type = lib.types.list.of lib.types.string; type = lib.types.list.of lib.types.string;
description = "Platforms the package supports."; description = "Platforms the package supports.";
# TODO: Support more platforms. # TODO: Support more platforms.
default.value = [ "i686-linux" ]; default.value = [
"i686-linux"
"x86_64-linux"
];
}; };
}; };

View file

@ -32,7 +32,10 @@ in
platforms = lib.options.create { platforms = lib.options.create {
type = lib.types.list.of lib.types.string; type = lib.types.list.of lib.types.string;
description = "Platforms the package supports."; description = "Platforms the package supports.";
default.value = [ "i686-linux" ]; default.value = [
"i686-linux"
"x86_64-linux"
];
}; };
}; };
@ -99,7 +102,8 @@ in
cd coreutils-${cfg.version} cd coreutils-${cfg.version}
# Configure # Configure
bash ./configure ${builtins.concatStringsSep " " configureFlags} chmod +x ./configure
./configure ${builtins.concatStringsSep " " configureFlags}
# Build # Build
make -j $NIX_BUILD_CORES make -j $NIX_BUILD_CORES

View file

@ -32,7 +32,10 @@ in
platforms = lib.options.create { platforms = lib.options.create {
type = lib.types.list.of lib.types.string; type = lib.types.list.of lib.types.string;
description = "Platforms the package supports."; description = "Platforms the package supports.";
default.value = [ "i686-linux" ]; default.value = [
"i686-linux"
"x86_64-linux"
];
}; };
}; };
@ -86,7 +89,8 @@ in
cd diffutils-${cfg.version} cd diffutils-${cfg.version}
# Configure # Configure
bash ./configure \ chmod +x ./configure
./configure \
--prefix=$out \ --prefix=$out \
--build=${platform.build} \ --build=${platform.build} \
--host=${platform.host} \ --host=${platform.host} \

View file

@ -32,7 +32,10 @@ in
platforms = lib.options.create { platforms = lib.options.create {
type = lib.types.list.of lib.types.string; type = lib.types.list.of lib.types.string;
description = "Platforms the package supports."; description = "Platforms the package supports.";
default.value = [ "i686-linux" ]; default.value = [
"i686-linux"
"x86_64-linux"
];
}; };
}; };
@ -86,7 +89,8 @@ in
cd findutils-${cfg.version} cd findutils-${cfg.version}
# Configure # Configure
bash ./configure \ chmod +x ./configure
./configure \
--prefix=$out \ --prefix=$out \
--build=${platform.build} \ --build=${platform.build} \
--host=${platform.host} \ --host=${platform.host} \

View file

@ -32,7 +32,10 @@ in
platforms = lib.options.create { platforms = lib.options.create {
type = lib.types.list.of lib.types.string; type = lib.types.list.of lib.types.string;
description = "Platforms the package supports."; description = "Platforms the package supports.";
default.value = [ "i686-linux" ]; default.value = [
"i686-linux"
"x86_64-linux"
];
}; };
mainProgram = lib.options.create { mainProgram = lib.options.create {
@ -92,7 +95,8 @@ in
cd gawk-${cfg.version} cd gawk-${cfg.version}
# Configure # Configure
bash ./configure \ chmod +x ./configure
./configure \
--prefix=$out \ --prefix=$out \
--build=${platform.build} \ --build=${platform.build} \
--host=${platform.host} \ --host=${platform.host} \

View file

@ -32,7 +32,10 @@ in
platforms = lib.options.create { platforms = lib.options.create {
type = lib.types.list.of lib.types.string; type = lib.types.list.of lib.types.string;
description = "Platforms the package supports."; description = "Platforms the package supports.";
default.value = [ "i686-linux" ]; default.value = [
"i686-linux"
"x86_64-linux"
];
}; };
}; };
@ -191,7 +194,8 @@ in
export CFLAGS_FOR_TARGET="-Wl,-dynamic-linker -Wl,${stage1.musl.package}/lib/libc.so" export CFLAGS_FOR_TARGET="-Wl,-dynamic-linker -Wl,${stage1.musl.package}/lib/libc.so"
export LIBRARY_PATH="${stage1.musl.package}/lib" export LIBRARY_PATH="${stage1.musl.package}/lib"
bash ./configure \ chmod +x ./configure
./configure \
--prefix=$out \ --prefix=$out \
--build=${platform.build} \ --build=${platform.build} \
--host=${platform.host} \ --host=${platform.host} \

View file

@ -33,7 +33,10 @@ in
platforms = lib.options.create { platforms = lib.options.create {
type = lib.types.list.of lib.types.string; type = lib.types.list.of lib.types.string;
description = "Platforms the package supports."; description = "Platforms the package supports.";
default.value = [ "i686-linux" ]; default.value = [
"i686-linux"
"x86_64-linux"
];
}; };
}; };
@ -91,7 +94,8 @@ in
cd build cd build
# libstdc++.so is built against musl and fails to link # libstdc++.so is built against musl and fails to link
export CXX=false export CXX=false
bash ../configure \ chmod +x ../configure
../configure \
--prefix=$out \ --prefix=$out \
--build=${platform.build} \ --build=${platform.build} \
--host=${platform.host} \ --host=${platform.host} \

View file

@ -32,7 +32,10 @@ in
platforms = lib.options.create { platforms = lib.options.create {
type = lib.types.list.of lib.types.string; type = lib.types.list.of lib.types.string;
description = "Platforms the package supports."; description = "Platforms the package supports.";
default.value = [ "i686-linux" ]; default.value = [
"i686-linux"
"x86_64-linux"
];
}; };
mainProgram = lib.options.create { mainProgram = lib.options.create {
@ -91,7 +94,8 @@ in
cd grep-${cfg.version} cd grep-${cfg.version}
# Configure # Configure
bash ./configure \ chmod +x ./configure
./configure \
--prefix=$out \ --prefix=$out \
--build=${platform.build} \ --build=${platform.build} \
--host=${platform.host} \ --host=${platform.host} \

View file

@ -33,7 +33,10 @@ in
platforms = lib.options.create { platforms = lib.options.create {
type = lib.types.list.of lib.types.string; type = lib.types.list.of lib.types.string;
description = "Platforms the package supports."; description = "Platforms the package supports.";
default.value = [ "i686-linux" ]; default.value = [
"i686-linux"
"x86_64-linux"
];
}; };
}; };
@ -102,7 +105,8 @@ in
${lib.strings.concatMapSep "\n" (file: "patch -Np1 -i ${file}") patches} ${lib.strings.concatMapSep "\n" (file: "patch -Np1 -i ${file}") patches}
# Configure # Configure
bash ./configure \ chmod +x ./configure
./configure \
--prefix=$out \ --prefix=$out \
--build=${platform.build} \ --build=${platform.build} \
--host=${platform.host} \ --host=${platform.host} \

View file

@ -32,7 +32,10 @@ in
platforms = lib.options.create { platforms = lib.options.create {
type = lib.types.list.of lib.types.string; type = lib.types.list.of lib.types.string;
description = "Platforms the package supports."; description = "Platforms the package supports.";
default.value = [ "i686-linux" ]; default.value = [
"i686-linux"
"x86_64-linux"
];
}; };
}; };
@ -87,7 +90,8 @@ in
cd patch-${cfg.version} cd patch-${cfg.version}
# Configure # Configure
bash ./configure \ chmod +x ./configure
./configure \
--prefix=$out \ --prefix=$out \
--build=${platform.build} \ --build=${platform.build} \
--host=${platform.host} \ --host=${platform.host} \

View file

@ -32,7 +32,10 @@ in
platforms = lib.options.create { platforms = lib.options.create {
type = lib.types.list.of lib.types.string; type = lib.types.list.of lib.types.string;
description = "Platforms the package supports."; description = "Platforms the package supports.";
default.value = [ "i686-linux" ]; default.value = [
"i686-linux"
"x86_64-linux"
];
}; };
mainProgram = lib.options.create { mainProgram = lib.options.create {
@ -93,7 +96,8 @@ in
cd sed-${cfg.version} cd sed-${cfg.version}
# Configure # Configure
bash ./configure \ chmod +x ./configure
./configure \
--prefix=$out \ --prefix=$out \
--build=${platform.build} \ --build=${platform.build} \
--host=${platform.host} \ --host=${platform.host} \

View file

@ -32,7 +32,10 @@ in
platforms = lib.options.create { platforms = lib.options.create {
type = lib.types.list.of lib.types.string; type = lib.types.list.of lib.types.string;
description = "Platforms the package supports."; description = "Platforms the package supports.";
default.value = [ "i686-linux" ]; default.value = [
"i686-linux"
"x86_64-linux"
];
}; };
mainProgram = lib.options.create { mainProgram = lib.options.create {
@ -92,7 +95,8 @@ in
cd tar-${cfg.version} cd tar-${cfg.version}
# Configure # Configure
bash ./configure \ chmod +x ./configure
./configure \
--prefix=$out \ --prefix=$out \
--build=${platform.build} \ --build=${platform.build} \
--host=${platform.host} \ --host=${platform.host} \

View file

@ -32,7 +32,10 @@ in
platforms = lib.options.create { platforms = lib.options.create {
type = lib.types.list.of lib.types.string; type = lib.types.list.of lib.types.string;
description = "Platforms the package supports."; description = "Platforms the package supports.";
default.value = [ "i686-linux" ]; default.value = [
"i686-linux"
"x86_64-linux"
];
}; };
}; };
@ -85,7 +88,8 @@ in
cd gzip-${cfg.version} cd gzip-${cfg.version}
# Configure # Configure
bash ./configure \ chmod +x ./configure
./configure \
--prefix=$out \ --prefix=$out \
--build=${platform.build} \ --build=${platform.build} \
--host=${platform.host} \ --host=${platform.host} \

View file

@ -33,7 +33,10 @@ in
platforms = lib.options.create { platforms = lib.options.create {
type = lib.types.list.of lib.types.string; type = lib.types.list.of lib.types.string;
description = "Platforms the package supports."; description = "Platforms the package supports.";
default.value = [ "i686-linux" ]; default.value = [
"i686-linux"
"x86_64-linux"
];
}; };
}; };
@ -86,7 +89,8 @@ in
cd patchelf-${cfg.version} cd patchelf-${cfg.version}
# Configure # Configure
bash ./configure \ chmod +x ./configure
./configure \
--prefix=$out \ --prefix=$out \
--build=${platform.build} \ --build=${platform.build} \
--host=${platform.host} \ --host=${platform.host} \

View file

@ -3,7 +3,7 @@
options.aux = { options.aux = {
system = lib.options.create { system = lib.options.create {
type = lib.types.string; type = lib.types.string;
default.value = "i686-linux"; default.value = "x86_64-linux";
description = '' description = ''
The system to build packages for. This value can be provided as either The system to build packages for. This value can be provided as either
`config.aux.system` or by setting the `system` argument for modules. `config.aux.system` or by setting the `system` argument for modules.

View file

@ -21,7 +21,7 @@ lib: {
## Apply a topological sort to a DAG. ## Apply a topological sort to a DAG.
## ##
## @type Dag a -> { result :: List a } | { cycle :: List a, loops :: List a } ## @type Dag a -> { result :: List a } | { cycle :: List a, loops :: List a }
topological = topographic =
graph: graph:
let let
getEntriesBefore = getEntriesBefore =
@ -43,7 +43,7 @@ lib: {
isBefore = a: b: builtins.elem a.name b.after; isBefore = a: b: builtins.elem a.name b.after;
sorted = lib.lists.sort.topological isBefore entries; sorted = lib.lists.sort.topographic isBefore entries;
in in
if sorted ? result then if sorted ? result then
{ {
@ -95,7 +95,7 @@ lib: {
## Create a new DAG entry. ## Create a new DAG entry.
## ##
## @type List String -> List String -> a -> { before :: List String, after :: List String, value :: a } ## @type List String -> List String -> a -> { before :: List String, after :: List String, value :: a }
between = after: before: value: { inherit before after value; }; between = before: after: value: { inherit before after value; };
## Create a new DAG entry with no dependencies. ## Create a new DAG entry with no dependencies.
## ##
@ -105,12 +105,12 @@ lib: {
## Create a new DAG entry that occurs before other entries. ## Create a new DAG entry that occurs before other entries.
## ##
## @type List String -> a -> { before :: List String, after :: List String, value :: a } ## @type List String -> a -> { before :: List String, after :: List String, value :: a }
before = before: lib.dag.entry.between [ ] before; before = before: lib.dag.entry.between before [ ];
## Create a new DAG entry that occurs after other entries. ## Create a new DAG entry that occurs after other entries.
## ##
## @type List String -> a -> { before :: List String, after :: List String, value :: a } ## @type List String -> a -> { before :: List String, after :: List String, value :: a }
after = after: lib.dag.entry.between after [ ]; after = lib.dag.entry.between [ ];
}; };
entries = { entries = {
@ -121,7 +121,7 @@ lib: {
tag: tag:
let let
process = process =
i: after: before: entries: i: before: after: entries:
let let
name = "${tag}-${builtins.toString i}"; name = "${tag}-${builtins.toString i}";
entry = builtins.head entries; entry = builtins.head entries;
@ -130,7 +130,7 @@ lib: {
if builtins.length entries == 0 then if builtins.length entries == 0 then
{ } { }
else if builtins.length entries == 1 then else if builtins.length entries == 1 then
{ "${name}" = lib.dag.entry.between after before entry; } { "${name}" = lib.dag.entry.between before after entry; }
else else
{ "${name}" = lib.dag.entry.after after entry; } // (process (i + 1) before [ name ] rest); { "${name}" = lib.dag.entry.after after entry; } // (process (i + 1) before [ name ] rest);
in in
@ -144,12 +144,12 @@ lib: {
## Create a DAG from a list of entries, prefixed with a tag, that occurs before other entries. ## Create a DAG from a list of entries, prefixed with a tag, that occurs before other entries.
## ##
## @type String -> List String -> List a -> Dag a ## @type String -> List String -> List a -> Dag a
before = tag: before: lib.dag.entries.between tag [ ] before; before = tag: before: lib.dag.entries.between tag before [ ];
## Create a DAG from a list of entries, prefixed with a tag, that occurs after other entries. ## Create a DAG from a list of entries, prefixed with a tag, that occurs after other entries.
## ##
## @type String -> List String -> List a -> Dag a ## @type String -> List String -> List a -> Dag a
after = tag: after: lib.dag.entries.between tag after [ ]; after = tag: lib.dag.entries.between tag [ ];
}; };
}; };
} }

View file

@ -119,11 +119,11 @@ in
}; };
"sort" = { "sort" = {
"topological" = { "topographic" = {
"handles an empty graph" = "handles an empty graph" =
let let
expected = [ ]; expected = [ ];
actual = lib.dag.sort.topological { }; actual = lib.dag.sort.topographic { };
in in
actual.result == expected; actual.result == expected;
@ -147,7 +147,7 @@ in
value = "d"; value = "d";
} }
]; ];
actual = lib.dag.sort.topological { actual = lib.dag.sort.topographic {
a = lib.dag.entry.anywhere "a"; a = lib.dag.entry.anywhere "a";
b = lib.dag.entry.between [ "c" ] [ "a" ] "b"; b = lib.dag.entry.between [ "c" ] [ "a" ] "b";
c = lib.dag.entry.before [ "c" ] "c"; c = lib.dag.entry.before [ "c" ] "c";

View file

@ -31,15 +31,15 @@ lib: {
in in
builtins.map (x: builtins.elemAt x 1) (builtins.sort isLess prepared); builtins.map (x: builtins.elemAt x 1) (builtins.sort isLess prepared);
## Perform a topological sort on a list of items. The predicate function determines whether ## Perform a topographic sort on a list of items. The predicate function determines whether
## its first argument comes before the second argument. ## its first argument comes before the second argument.
## ##
## @type (a -> a -> Bool) -> List a -> List a ## @type (a -> a -> Bool) -> List a -> List a
topological = topographic =
predicate: list: predicate: list:
let let
searched = lib.lists.search.depthFirst true predicate list; searched = lib.lists.search.depthFirst true predicate list;
results = lib.lists.sort.topological predicate (searched.visited ++ searched.rest); results = lib.lists.sort.topographic predicate (searched.visited ++ searched.rest);
in in
if builtins.length list < 2 then if builtins.length list < 2 then
{ result = list; } { result = list; }
@ -224,11 +224,5 @@ lib: {
filter = result: value: if builtins.elem value result then result else result ++ [ value ]; filter = result: value: if builtins.elem value result then result else result ++ [ value ];
in in
builtins.foldl' filter [ ] list; builtins.foldl' filter [ ] list;
## Flatten a list of lists into a single list.
##
## @type List (List a) -> List a
flatten =
value: if builtins.isList value then builtins.concatMap lib.lists.flatten value else [ value ];
}; };
} }

View file

@ -43,7 +43,7 @@ lib: {
resolve = resolve =
definition: definition:
let let
properties = builtins.addErrorContext "while evaluating definitions from `${definition.__file__ or "<unknown>"}`:" ( properties = builtins.addErrorContext "while evaluating definitions from `${definition.__file__}`:" (
lib.modules.apply.properties definition.value lib.modules.apply.properties definition.value
); );
normalize = value: { normalize = value: {

View file

@ -49,18 +49,18 @@ lib: {
## ##
## @type Attrs -> Attrs ## @type Attrs -> Attrs
create = create =
settings@{ name settings@{
, description ? name name,
, fallback ? { } description ? name,
, check ? lib.fp.const true fallback ? { },
, merge ? lib.options.merge.default check ? lib.fp.const true,
, functor ? lib.types.functor name merge ? lib.options.merge.default,
, mergeType ? lib.types.merge functor functor ? lib.types.functor name,
, getSubOptions ? lib.fp.const { } mergeType ? lib.types.merge functor,
, getSubModules ? null getSubOptions ? lib.fp.const { },
, withSubModules ? lib.fp.const null getSubModules ? null,
, children ? { } withSubModules ? lib.fp.const null,
, children ? { },
}: }:
{ {
__type__ = "type"; __type__ = "type";
@ -108,7 +108,7 @@ lib: {
identifier = lib.options.getIdentifier location; identifier = lib.options.getIdentifier location;
first = builtins.elemAt definitions 0; first = builtins.elemAt definitions 0;
files = lib.modules.getFiles definitions; files = builtins.map lib.modules.getFiles definitions;
serializedFiles = builtins.concatStringsSep " and " files; serializedFiles = builtins.concatStringsSep " and " files;
getType = getType =
@ -118,16 +118,13 @@ lib: {
else else
builtins.typeOf value; builtins.typeOf value;
commonType = builtins.foldl' commonType = builtins.foldl' (
(
type: definition: type: definition:
if getType definition.value != type then if getType definition.value != type then
builtins.throw "The option `${identifier}` has conflicting definitions in ${serializedFiles}" builtins.throw "The option `${identifier}` has conflicting definitions in ${files}"
else else
type type
) ) (getType first.value) definitions;
(getType first.value)
definitions;
mergeStringifiableAttrs = lib.options.merge.one; mergeStringifiableAttrs = lib.options.merge.one;
@ -135,7 +132,7 @@ lib: {
mergeList = mergeList =
if builtins.length definitions > 1 then if builtins.length definitions > 1 then
builtins.throw "The option `${identifier}` has conflicting definitions in ${serializedFiles}" builtins.throw "The option `${identifier}` has conflicting definitions in ${files}"
else else
(lib.types.list.of lib.types.any).merge; (lib.types.list.of lib.types.any).merge;
@ -143,12 +140,10 @@ lib: {
location: definitions: x: location: definitions: x:
let let
resolvedLocation = location ++ [ "<function body>" ]; resolvedLocation = location ++ [ "<function body>" ];
resolvedDefinitions = builtins.map resolvedDefinitions = builtins.map (definition: {
(definition: {
__file__ = definition.__file__; __file__ = definition.__file__;
value = definition.value x; value = definition.value x;
}) }) definitions;
definitions;
in in
lib.types.any.merge resolvedLocation resolvedDefinitions; lib.types.any.merge resolvedLocation resolvedDefinitions;
@ -205,8 +200,7 @@ lib: {
## @type Int -> Int -> Attrs ## @type Int -> Int -> Attrs
between = between =
start: end: start: end:
assert lib.errors.trace assert lib.errors.trace (
(
start <= end start <= end
) "lib.types.ints.between start must be less than or equal to end"; ) "lib.types.ints.between start must be less than or equal to end";
lib.types.withCheck lib.types.int (value: value >= start && value <= end) lib.types.withCheck lib.types.int (value: value >= start && value <= end)
@ -323,8 +317,7 @@ lib: {
## @type Int -> Int -> Attrs ## @type Int -> Int -> Attrs
between = between =
start: end: start: end:
assert lib.errors.trace assert lib.errors.trace (
(
start <= end start <= end
) "lib.types.numbers.between start must be less than or equal to end"; ) "lib.types.numbers.between start must be less than or equal to end";
lib.types.withCheck lib.types.number (value: value >= start && value <= end) lib.types.withCheck lib.types.number (value: value >= start && value <= end)
@ -454,7 +447,8 @@ lib: {
}; };
attrs = { attrs = {
## A type that allows an attribute set containing any type of value. ## A type that allows an attribute set containing any type of value. The merged
## definitions must all be.
## ##
## @type Attrs ## @type Attrs
any = lib.types.create { any = lib.types.create {
@ -486,12 +480,10 @@ lib: {
let let
normalize = normalize =
definition: definition:
builtins.mapAttrs builtins.mapAttrs (name: value: {
(name: value: {
__file__ = definition.__file__; __file__ = definition.__file__;
value = value; value = value;
}) }) definition.value;
definition.value;
normalized = builtins.map normalize definitions; normalized = builtins.map normalize definitions;
zipper = zipper =
name: definitions: (lib.options.merge.definitions (location ++ [ name ]) type definitions).optional; name: definitions: (lib.options.merge.definitions (location ++ [ name ]) type definitions).optional;
@ -528,12 +520,10 @@ lib: {
let let
normalize = normalize =
definition: definition:
builtins.mapAttrs builtins.mapAttrs (name: value: {
(name: value: {
__file__ = definition.__file__; __file__ = definition.__file__;
value = value; value = value;
}) }) definition.value;
definition.value;
normalized = builtins.map normalize definitions; normalized = builtins.map normalize definitions;
zipper = zipper =
name: definitions: name: definitions:
@ -579,7 +569,7 @@ lib: {
## ##
## @type Attrs ## @type Attrs
shell = lib.types.derivation // { shell = lib.types.derivation // {
check = value: lib.packages.isDerivation value && builtins.hasAttr "shellPath" value; check = value: lib.packages.isDerivation && builtins.hasAttr "shellPath" value;
}; };
}; };
@ -616,11 +606,9 @@ lib: {
merge = merge =
location: definitions: location: definitions:
let let
result = lib.lists.mapWithIndex1 result = lib.lists.mapWithIndex1 (
(
i: definition: i: definition:
lib.lists.mapWithIndex1 lib.lists.mapWithIndex1 (
(
j: value: j: value:
let let
resolved = resolved =
@ -634,12 +622,9 @@ lib: {
]; ];
in in
resolved.optional resolved.optional
) ) definition.value
definition.value ) definitions;
) merged = builtins.concatLists result;
definitions;
merged = lib.lists.flatten result;
filtered = builtins.filter (definition: definition ? value) merged; filtered = builtins.filter (definition: definition ? value) merged;
values = lib.options.getDefinitionValues filtered; values = lib.options.getDefinitionValues filtered;
in in
@ -792,11 +777,11 @@ lib: {
## ##
## @type { modules :: List Module, args? :: Attrs, description? :: String | Null, shorthand? :: Bool } -> Attrs ## @type { modules :: List Module, args? :: Attrs, description? :: String | Null, shorthand? :: Bool } -> Attrs
of = of =
settings@{ modules settings@{
, args ? { } modules,
, description ? null args ? { },
, shorthand ? true description ? null,
, shorthand ? true,
}: }:
let let
getModules = builtins.map ( getModules = builtins.map (
@ -805,12 +790,9 @@ lib: {
let let
# TODO: Figure out if we can apply additional attributes to the generated module. # TODO: Figure out if we can apply additional attributes to the generated module.
# Currently this causes issues to do with redefined options. # Currently this causes issues to do with redefined options.
rest = builtins.removeAttrs rest = builtins.removeAttrs (lib.attrs.filter (
(lib.attrs.filter
(
name: value: builtins.elem name lib.modules.VALID_KEYS name: value: builtins.elem name lib.modules.VALID_KEYS
) ) definition.value) [ "freeform" ];
definition.value) [ "freeform" ];
in in
if definition.value ? config then if definition.value ? config then
rest rest
@ -940,12 +922,10 @@ lib: {
merge = location: definitions: { merge = location: definitions: {
includes = includes =
modules modules
++ builtins.map ++ builtins.map (definition: {
(definition: {
__file__ = "${definition.__file__}; via ${lib.options.getIdentifier location}"; __file__ = "${definition.__file__}; via ${lib.options.getIdentifier location}";
includes = [ definition.value ]; includes = [ definition.value ];
}) }) definitions;
definitions;
}; };
getSubOptions = submodule.getSubOptions; getSubOptions = submodule.getSubOptions;
getSubModules = submodule.getSubModules; getSubModules = submodule.getSubModules;
@ -981,12 +961,10 @@ lib: {
location: definitions: location: definitions:
let let
first = builtins.elemAt definitions 0; first = builtins.elemAt definitions 0;
modules = builtins.map modules = builtins.map (definition: {
(definition: {
__file__ = definition.__file__; __file__ = definition.__file__;
options = lib.options.create { type = definition.value; }; options = lib.options.create { type = definition.value; };
}) }) definitions;
definitions;
merged = lib.modules.fixup location (lib.options.merge.declarations location modules); merged = lib.modules.fixup location (lib.options.merge.declarations location modules);
in in
if builtins.length definitions == 1 then first.value else merged.type; if builtins.length definitions == 1 then first.value else merged.type;
@ -1122,43 +1100,6 @@ lib: {
}; };
}; };
## Create a type that allows a value which is either the final type or is transformable
## to the final type.
##
## @type Attrs -> (Any -> Any) -> Attrs -> Attrs
coerceWithLocation =
initial: transform: final:
let
in
if initial.getSubModules != null then
builtins.throw "lib.types.coerceWithLocation's first argument may not have submodules, but got ${initial.description}"
else
lib.types.create {
name = "Coerce";
description = "${initial.description} that is transformed to ${final.description}";
fallback = final.fallback;
check = value: final.check value || (initial.check value && final.check (transform [ ] value));
merge =
location: definitions:
let
process = value: if initial.check value then transform location value else value;
normalize = definition: definition // { value = process definition.value; };
normalized = builtins.map normalize definitions;
in
final.merge location normalized;
getSubOptions = final.getSubOptions;
getSubModules = final.getSubModules;
withSubModules =
modules: lib.types.coerceWithLocation initial transform (final.withSubModules modules);
mergeType = x: y: null;
functor = lib.types.functor "coerceWithLocation" // {
wrapped = final;
};
children = {
inherit initial final;
};
};
dag = { dag = {
## Create a type that allows a DAG (Directed Acyclic Graph) of a given type. ## Create a type that allows a DAG (Directed Acyclic Graph) of a given type.
## ##
@ -1219,12 +1160,10 @@ lib: {
merge = merge =
location: definitions: location: definitions:
submodule.merge location ( submodule.merge location (
builtins.map builtins.map (definition: {
(definition: {
__file__ = definition.__file__; __file__ = definition.__file__;
value = normalize definition; value = normalize definition;
}) }) definitions
definitions
); );
}; };
}; };

View file

@ -8,35 +8,33 @@
}, },
"locked": { "locked": {
"dir": "foundation", "dir": "foundation",
"lastModified": 1724190751, "dirtyRev": "9850da8aa9dc9be22e237c9b424a18e801e53ecb-dirty",
"narHash": "sha256-e8sOmeXS9YWuQqjW6gvtS3PIueazkf4S1iiJ/94eXv4=", "dirtyShortRev": "9850da8-dirty",
"ref": "master", "lastModified": 1718529861,
"rev": "4b36a5a0133f5481840bdfaf693c971215a7ef1f", "narHash": "sha256-X1Wd6mDz8GTaoxt1ylkvZfrJOcZtspJrEjXMtJ2ZyG0=",
"revCount": 84,
"type": "git", "type": "git",
"url": "file:../" "url": "file:../?dir=foundation"
}, },
"original": { "original": {
"dir": "foundation", "dir": "foundation",
"type": "git", "type": "git",
"url": "file:../" "url": "file:../?dir=foundation"
} }
}, },
"lib": { "lib": {
"locked": { "locked": {
"dir": "lib", "dir": "lib",
"lastModified": 1724190751, "dirtyRev": "9850da8aa9dc9be22e237c9b424a18e801e53ecb-dirty",
"narHash": "sha256-e8sOmeXS9YWuQqjW6gvtS3PIueazkf4S1iiJ/94eXv4=", "dirtyShortRev": "9850da8-dirty",
"ref": "master", "lastModified": 1718529861,
"rev": "4b36a5a0133f5481840bdfaf693c971215a7ef1f", "narHash": "sha256-X1Wd6mDz8GTaoxt1ylkvZfrJOcZtspJrEjXMtJ2ZyG0=",
"revCount": 84,
"type": "git", "type": "git",
"url": "file:../" "url": "file:../?dir=lib"
}, },
"original": { "original": {
"dir": "lib", "dir": "lib",
"type": "git", "type": "git",
"url": "file:../" "url": "file:../?dir=lib"
} }
}, },
"root": { "root": {

View file

@ -1,8 +1,10 @@
{ config }: { lib, config }:
let let
cfg = config.builders.basic; cfg = config.builders.basic;
inherit (config) lib foundation; lib' = config.lib;
inherit (config) foundation;
in in
{ {
config.builders = { config.builders = {
@ -12,46 +14,15 @@ in
build = build =
package: package:
let let
phases = package.phases;
sorted = lib.dag.sort.topographic phases;
script = lib.strings.concatMapSep "\n" (
entry: if builtins.isFunction entry.value then entry.value package else entry.value
) sorted.result;
system = package.platform.build.double; system = package.platform.build.double;
dependencies = lib.packages.dependencies.collect package;
context = lib.packages.context.create dependencies { };
hooks = lib.packages.hooks.create dependencies context;
phasesWithHooks =
let
all = lib.lists.flatten [
hooks.build.only
hooks.build.build
hooks.build.host
hooks.build.target
hooks.host.only
hooks.host.host
hooks.host.target
hooks.target.only
hooks.target.target
];
in
builtins.foldl' (final: defaults: lib.dag.apply.defaults final defaults) package.phases all;
phases = lib.dag.apply.defaults phasesWithHooks {
unpack = lib.dag.entry.before [ "patch" ] "";
patch = lib.dag.entry.between [ "unpack" ] [ "configure" ] "";
configure = lib.dag.entry.between [ "patch" ] [ "build" ] "";
build = lib.dag.entry.between [ "configure" ] [ "install" ] "";
install = lib.dag.entry.after [ "build" ] "";
};
sorted = lib.dag.sort.topological phases;
script = lib.strings.concatMapSep "\n" (entry: entry.value) sorted.result;
built = builtins.derivation ( built = builtins.derivation (
package.env package.env
// { // {
@ -65,15 +36,7 @@ in
PATH = PATH =
let let
bins = lib.paths.bin ( bins = lib.paths.bin (
(lib.packages.dependencies.get dependencies.build.only) (lib'.packages.dependencies.getPackages package.deps.build.host)
++ (lib.packages.dependencies.get dependencies.build.build)
++ (lib.packages.dependencies.get dependencies.build.host)
++ (lib.packages.dependencies.get dependencies.build.target)
++ (lib.packages.dependencies.get dependencies.host.only)
++ (lib.packages.dependencies.get dependencies.host.host)
++ (lib.packages.dependencies.get dependencies.host.target)
++ (lib.packages.dependencies.get dependencies.target.only)
++ (lib.packages.dependencies.get dependencies.target.target)
++ [ ++ [
foundation.stage2-bash foundation.stage2-bash
foundation.stage2-coreutils foundation.stage2-coreutils
@ -107,15 +70,7 @@ in
} }
); );
in in
# (builtins.trace "build: ${package.name} -> build=${package.platform.build.triple} host=${package.platform.host.triple} target=${package.platform.target.triple}") built // { inherit (package) meta; };
built
// {
inherit (package) meta;
extras = {
inherit package context;
phases = builtins.listToAttrs sorted.result;
} // package.extras;
};
}; };
}; };
} }

View file

@ -1,39 +1,37 @@
# This file handles creating all of the exports for this project and is not # This file handles creating all of the exports for this project and is not
# exported itself. # exported itself.
{ config }: { lib, config }:
let let
inherit (config) lib; lib' = config.lib;
in in
{ {
# freeform = lib.types.any; freeform = lib.types.any;
config = { config = {
exports = { exports = {
inherit lib; lib = config.lib;
modules = import ./modules.nix; modules = import ./modules.nix;
packages = { packages = {
aux-a = config.packages.aux.a; # foundation-gcc-x86_64 =
aux-b = config.packages.aux.b; # (config.packages.foundation.gcc.versions."13.2.0".extend (args: {
# config = {
# platform = {
# target = lib.modules.overrides.force "x86_64-linux";
# };
# };
# }))
# .config;
foundation-gcc = config.packages.foundation.gcc; foundation-gcc = config.packages.foundation.gcc;
foundation-glibc = config.packages.foundation.glibc;
foundation-binutils = config.packages.foundation.binutils; foundation-binutils = config.packages.foundation.binutils;
foundation-linux-headers = config.packages.foundation.linux-headers; foundation-linux-headers = config.packages.foundation.linux-headers.versions.latest.extend {
platform.host = lib.modules.overrides.force "x86_64-linux";
};
# example-x = config.packages.example.x;
# cross-example-x-x86_64-linux = config.packages.cross.x86_64-linux.example.x;
};
};
cross-foundation-glibc-x86_64-linux = config.packages.cross.x86_64-linux.foundation.glibc; # exported.packages.i686-linux.cross-foundation-gcc-x86_64-linux = config.packages.cross.x86_64-linux.foundation.gcc.package;
cross-foundation-binutils-x86_64-linux = config.packages.cross.x86_64-linux.foundation.binutils;
cross-tool-foundation-gcc-newlib-x86_64-linux = config.packages.cross-tools.x86_64-linux.foundation.gcc-newlib;
cross-tool-foundation-gcc-x86_64-linux = config.packages.cross-tools.x86_64-linux.foundation.gcc-cross;
cross-foundation-gcc-x86_64-linux = config.packages.cross.x86_64-linux.foundation.gcc-bootstrap;
example-a = config.packages.foundation.gcc.versions.latest.extend {
platform = {
target = lib.modules.override 0 "x86_64-linux";
};
};
};
};
}; };
} }

View file

@ -5,7 +5,7 @@ in
config = { config = {
lib.options = { lib.options = {
package = lib.options.create { package = lib.options.create {
type = config.lib.types.package.base; type = config.lib.types.package;
description = "A package definition."; description = "A package definition.";
}; };
}; };

View file

@ -1,272 +1,20 @@
{ lib, config }: {
let lib,
lib' = config.lib; lib',
in config,
}:
{ {
config = { config = {
lib.packages = { lib.packages = {
dependencies = { dependencies = {
get = getPackages =
dependencies: dependencies:
let let
exists = value: !(builtins.isNull value); available = builtins.filter (dependency: !(builtins.isNull dependency)) (
available = builtins.filter exists dependencies; builtins.attrValues dependencies
);
in in
builtins.map (dependency: dependency.package) available; builtins.map (dependency: dependency.package) available;
build =
build': host': target':
builtins.mapAttrs (name: dep: lib'.packages.build dep build' host' target');
collect =
package:
let
isPropagated = name: package: package.propagate or false;
getPropagatedDependencies = target: builtins.attrValues (lib.attrs.filter isPropagated target);
process =
dependencies:
let
getDeps =
name: dependency:
let
deps = {
build = {
only = getPropagatedDependencies dependency.deps.build.only ++ process dependency.deps.build.only;
build =
getPropagatedDependencies dependency.deps.build.build
++ process dependency.deps.build.build;
host = getPropagatedDependencies dependency.deps.build.host ++ process dependency.deps.build.host;
target =
getPropagatedDependencies dependency.deps.build.target
++ process dependency.deps.build.target;
};
host = {
only = getPropagatedDependencies dependency.deps.host.only ++ process dependency.deps.host.only;
host = getPropagatedDependencies dependency.deps.host.host ++ process dependency.deps.host.host;
target =
getPropagatedDependencies dependency.deps.host.target
++ process dependency.deps.host.target;
};
target = {
only = getPropagatedDependencies dependency.deps.target.only ++ process dependency.deps.target.only;
target =
getPropagatedDependencies dependency.deps.target.target
++ process dependency.deps.target.target;
};
};
in
lib.lists.flatten [
deps.build.only
deps.build.build
deps.build.host
deps.build.target
deps.host.only
deps.host.host
deps.host.target
deps.target.only
deps.target.target
];
propagated = lib.attrs.mapToList getDeps dependencies;
in
lib.lists.flatten propagated;
in
{
build = {
only = builtins.attrValues package.deps.build.only ++ process package.deps.build.only;
build = builtins.attrValues package.deps.build.build ++ process package.deps.build.build;
host = builtins.attrValues package.deps.build.host ++ process package.deps.build.host;
target = builtins.attrValues package.deps.build.target ++ process package.deps.build.target;
};
host = {
only = builtins.attrValues package.deps.host.only ++ process package.deps.host.only;
host = builtins.attrValues package.deps.host.host ++ process package.deps.host.host;
target = builtins.attrValues package.deps.host.target ++ process package.deps.host.target;
};
target = {
only = builtins.attrValues package.deps.target.only ++ process package.deps.target.only;
target = builtins.attrValues package.deps.target.target ++ process package.deps.target.target;
};
};
};
context = {
create =
collected: ctx:
let
process =
path:
let
dependencies = lib.attrs.selectOrThrow path collected;
contexts = builtins.map (dependency: dependency.context or { }) dependencies;
result = lib.modules.run {
prefix = [ "<package>" ];
modules = builtins.map (context: { config = context; }) contexts ++ [
{
freeform = lib.types.any;
options = config.packages.context.options // {
target = lib.options.create {
description = "The dependency target that is being generated.";
type = lib.types.enum [
"build.only"
"build.build"
"build.host"
"build.target"
"host.only"
"host.host"
"host.target"
"target.only"
"target.target"
];
writable = false;
default.value = builtins.concatStringsSep "." path;
};
deps = lib.options.create {
description = "The collected dependencies.";
writable = false;
default.value = collected;
type = lib.types.submodule {
options = {
build = {
only = lib.options.create { type = lib.types.list.of lib'.types.package; };
build = lib.options.create { type = lib.types.list.of lib'.types.package; };
host = lib.options.create { type = lib.types.list.of lib'.types.package; };
target = lib.options.create { type = lib.types.list.of lib'.types.package; };
};
host = {
only = lib.options.create { type = lib.types.list.of lib'.types.package; };
host = lib.options.create { type = lib.types.list.of lib'.types.package; };
target = lib.options.create { type = lib.types.list.of lib'.types.package; };
};
target = {
only = lib.options.create { type = lib.types.list.of lib'.types.package; };
target = lib.options.create { type = lib.types.list.of lib'.types.package; };
};
};
};
};
};
config = ctx;
}
];
};
in
result.config;
in
{
build = {
only = process [
"build"
"only"
];
build = process [
"build"
"build"
];
host = process [
"build"
"host"
];
target = process [
"build"
"target"
];
};
host = {
only = process [
"host"
"only"
];
host = process [
"host"
"host"
];
target = process [
"host"
"target"
];
};
target = {
only = process [
"target"
"only"
];
target = process [
"target"
"target"
];
};
};
};
hooks = {
create =
collected: ctx:
let
process =
path:
let
dependencies = lib.attrs.selectOrThrow path collected;
hooks = builtins.map
(
dependency:
let
getHooks = dependency.hooks or (lib.fp.const { });
in
getHooks ctx
)
dependencies;
in
hooks;
in
{
build = {
only = process [
"build"
"only"
];
build = process [
"build"
"build"
];
host = process [
"build"
"host"
];
target = process [
"build"
"target"
];
};
host = {
only = process [
"host"
"only"
];
host = process [
"host"
"host"
];
target = process [
"host"
"target"
];
};
target = {
only = process [
"target"
"only"
];
target = process [
"target"
"target"
];
};
};
}; };
getLatest = getLatest =
@ -277,89 +25,54 @@ in
in in
builtins.head sorted; builtins.head sorted;
resolve =
alias:
if alias ? versions then
alias.versions.${config.preferences.packages.version}
or (alias.versions.${lib'.packages.getLatest alias})
else
alias;
build = build =
alias: build: host: target: package: build: host: target:
let let
package = lib'.packages.resolve alias; resolved =
if package ? versions then
package.versions.${config.preferences.packages.version}
or (package.versions.${lib'.packages.getLatest package})
else
package;
buildDependencies = buildDependencies =
build': host': target': build': host': target':
builtins.mapAttrs (name: dep: lib'.packages.build dep build' host' target'); builtins.mapAttrs (name: dep: lib'.packages.build dep build' host' target');
platform = { result = resolved.extend (
build = lib.modules.overrides.force build;
host = lib.modules.overrides.force host;
target = lib.modules.overrides.force target;
};
withPlatform = lib.modules.run {
modules = package.__modules__ ++ [
lib'.types.package.children.submodule
(
{ config }: { config }:
{ {
config = { config = {
__modules__ = package.__modules__; platform = {
build = build;
inherit platform; host = host;
}; target = lib.modules.override 150 target;
}
)
];
}; };
# Not all platform information can be effectively handled via submodules. To handle
# the case where a user copies the resolved config over we need to ensure that
# dependencies are appropriately updated.
withDeps = withPlatform.config // {
deps = { deps = {
build = { build = {
only = buildDependencies build build build withPlatform.config.deps.build.only; only = buildDependencies build build build resolved.deps.build.only;
build = buildDependencies build build target withPlatform.config.deps.build.build; build = buildDependencies build build target resolved.deps.build.build;
host = buildDependencies build host target withPlatform.config.deps.build.host; host = buildDependencies build host target resolved.deps.build.host;
target = buildDependencies build target target withPlatform.config.deps.build.target; target = buildDependencies build target target resolved.deps.build.target;
}; };
host = { host = {
only = buildDependencies host host host withPlatform.config.deps.host.only; only = buildDependencies host host host resolved.deps.host.only;
host = buildDependencies host host target withPlatform.config.deps.host.host; host = buildDependencies host host target resolved.deps.host.host;
target = buildDependencies host target target withPlatform.config.deps.host.target; target = buildDependencies host target target resolved.deps.host.target;
}; };
target = { target = {
only = buildDependencies target target target withPlatform.config.deps.target.only; only = buildDependencies target target target resolved.deps.target.only;
target = buildDependencies target target target withPlatform.config.deps.target.target; target = buildDependencies target target target resolved.deps.target.target;
};
}; };
}; };
withPackage = lib.modules.run { package = config.builder.build config;
modules = package.__modules__ ++ [
lib'.types.package.children.submodule
(
{ config }:
{
config = {
__modules__ = package.__modules__;
inherit platform;
deps = lib.modules.overrides.force withDeps.deps;
package = lib.modules.overrides.force (withDeps.builder.build withDeps);
}; };
} }
) );
];
};
in in
withPackage.config; result;
}; };
}; };
} }

View file

@ -1220,7 +1220,6 @@ in
vendor, vendor,
kernel, kernel,
abi, abi,
...
}: }:
types.cpu.check cpu types.cpu.check cpu
&& types.vendor.check vendor && types.vendor.check vendor
@ -1228,17 +1227,6 @@ in
&& types.abi.check abi; && types.abi.check abi;
}; };
platformWithBuildInfo = lib.types.create {
name = "systemWithBuildInfo";
description = "fully parsed representation of llvm- or nix-style platform tuple with build information";
merge = lib.options.merge.one;
check =
value:
lib.types.is "systemWithBuildInfo" value
&& value ? system
&& lib'.systems.types.platform.check value.system;
};
endian = lib.types.enum (builtins.attrValues types.endians); endian = lib.types.enum (builtins.attrValues types.endians);
endians = setTypes types.generic.endian { endians = setTypes types.generic.endian {
@ -2804,7 +2792,7 @@ in
assert resolved.useAndroidPrebuilt -> resolved.isAndroid; assert resolved.useAndroidPrebuilt -> resolved.isAndroid;
assert assertions; assert assertions;
# And finally, return the generated system info. # And finally, return the generated system info.
lib.types.set "systemWithBuildInfo" resolved; resolved;
}; };
}; };
} }

View file

@ -1,9 +1,8 @@
{ lib, config }: {
let lib,
inherit (config) preferences builders; lib',
config,
lib' = config.lib; }:
in
{ {
config = { config = {
lib.types = { lib.types = {
@ -56,10 +55,6 @@ in
in in
lib.types.either type (lib.types.list.of type); lib.types.either type (lib.types.list.of type);
platform =
lib.types.coerce lib.types.string lib'.systems.withBuildInfo
lib'.systems.types.platformWithBuildInfo;
builder = lib.types.submodule { builder = lib.types.submodule {
freeform = lib.types.any; freeform = lib.types.any;
@ -71,227 +66,67 @@ in
}; };
}; };
packages = lib.types.attrs.of (lib.types.attrs.of lib'.types.alias); packages = lib.types.attrs.of (lib'.types.alias);
dependencies = alias = lib.types.attrs.of (
build: host: target:
let
initial = lib.types.raw;
transform =
value:
let
package = lib'.packages.resolve value;
in
lib'.packages.build package build host target;
in
lib.types.attrs.of (lib.types.coerce initial transform lib'.types.package);
alias = lib.types.submodule {
options = {
stable = lib.options.create {
description = "The stable version of the package.";
type = lib.types.nullish lib'.types.package;
};
latest = lib.options.create {
description = "The latest version of the package.";
type = lib'.types.package;
};
versions = lib.options.create {
description = "Available versions of the package.";
type = lib.types.attrs.of lib'.types.package;
default.value = { };
};
};
};
package =
let
normalize =
value:
if builtins.isFunction value || builtins.isList value then
value
else if value ? __modules__ then
value.__modules__
else
{ config = value; };
initial = lib.types.create {
name = "PackageConfig";
description = "configuration for a package";
check = value: builtins.isFunction value || builtins.isAttrs value || builtins.isList value;
merge =
location: definitions:
let
normalized = builtins.map (definition: lib.lists.from.any (normalize definition.value)) definitions;
in
builtins.concatLists normalized;
};
transform =
location: value:
let
modules = lib.lists.from.any (normalize value);
result = lib.modules.run {
prefix = location;
modules = modules ++ [
submodule
{ config.__modules__ = modules; }
];
};
in
result.config;
final = lib.types.raw;
deps =
build: host: target:
lib.types.submodule { lib.types.submodule {
options = { options = {
build = { versions = lib.options.create {
only = lib.options.create { description = "All available package versions.";
description = "Dependencies which are only used in the build environment."; type = lib.types.attrs.of lib'.types.package;
type = lib'.types.dependencies build build build;
default.value = { };
}; };
};
}
);
build = lib.options.create { dependencies = lib.types.attrs.of (
description = "Dependencies which are created in the build environment and are executed in the build environment."; lib.types.nullish (lib.types.either lib'.types.alias lib'.types.package)
type = lib'.types.dependencies build build target; );
default.value = { };
};
host = lib.options.create { package = lib.types.submodule (
description = "Dependencies which are created in the build environment and are executed in the host environment.";
type = lib'.types.dependencies build host target;
default.value = { };
};
target = lib.options.create {
description = "Dependencies which are created in the build environment and are executed in the target environment.";
type = lib'.types.dependencies build target target;
default.value = { };
};
};
host = {
only = lib.options.create {
description = "Dependencies which are only used in the host environment.";
type = lib'.types.dependencies host host host;
default.value = { };
};
host = lib.options.create {
description = "Dependencies which are executed in the host environment.";
type = lib'.types.dependencies host host target;
default.value = { };
};
target = lib.options.create {
description = "Dependencies which are executed in the host environment which produces code for the target environment.";
type = lib'.types.dependencies host target target;
default.value = { };
};
};
target = {
only = lib.options.create {
description = "Dependencies which are only used in the target environment.";
type = lib'.types.dependencies target target target;
default.value = { };
};
target = lib.options.create {
description = "Dependencies which are executed in the target environment.";
type = lib'.types.dependencies target target target;
default.value = { };
};
};
};
};
submodule =
{ config, meta }: { config, meta }:
let
build = config.platform.build;
host = config.platform.host;
target = config.platform.target;
in
{ {
options = { options = {
__modules__ = lib.options.create {
description = "User specified modules for the package definition.";
type = lib.types.list.of (initial // { merge = lib.options.merge.one; });
# writable = false;
internal = true;
default.value = [ ];
};
# extend = lib.options.create {
# description = "Extend the package definition.";
# type = lib.types.function lib.types.raw;
# internal = true;
# writable = false;
# default.value = module:
# let
# normalized =
# if builtins.isList module then
# module
# else if builtins.isFunction module || module ? config then
# [ module ]
# else
# [{
# config = module;
# }];
# result = meta.extend {
# modules =
# normalized ++ [
# {
# config.__modules__ = lib.modules.overrides.force (config.__modules__ ++ normalized);
# }
# ];
# };
# in
# result.config;
# };
extend = lib.options.create { extend = lib.options.create {
description = "Extend the package definition."; description = "Extend the package's submodules with additional configuration.";
type = lib.types.function lib.types.raw; type = lib.types.function lib.types.raw;
internal = true; default.value =
writable = false; value:
default.value = module:
let let
normalized = result = meta.extend {
if builtins.isList module then modules = if builtins.isAttrs value then [ { config = value; } ] else lib.lists.from.any value;
module
else if builtins.isFunction module || module ? config then
[ module ]
else
[{
config = module;
}];
modules = config.__modules__ ++ normalized;
result = lib.modules.run {
modules = [
submodule
{ config.__modules__ = modules; }
] ++ modules;
}; };
in in
result.config; result.config;
}; };
name = lib.options.create {
description = "The name of the package.";
type = lib.types.string;
default = {
text = "\${config.pname}-\${config.version}";
value =
if config.pname != null && config.version != null then "${config.pname}-${config.version}" else "";
};
};
pname = lib.options.create {
description = "The program name for the package";
type = lib.types.nullish lib.types.string;
default.value = null;
};
version = lib.options.create {
description = "The version for the package.";
type = lib.types.nullish lib.types.version;
default.value = null;
};
meta = { meta = {
description = lib.options.create { description = lib.options.create {
description = "The description for the package."; description = "The description for the package.";
type = lib.types.string; type = lib.types.nullish lib.types.string;
default.value = ""; default.value = null;
}; };
homepage = lib.options.create { homepage = lib.options.create {
@ -337,57 +172,67 @@ in
}; };
}; };
extras = lib.options.create {
description = "Extra information for the package.";
type = lib.types.attrs.of lib.types.any;
default.value = { };
};
platform = { platform = {
build = lib.options.create { build = lib.options.create {
description = "The build platform for the package."; description = "The build platform for the package.";
type = lib'.types.platform; type = lib.types.string;
default.value = lib'.systems.withBuildInfo "x86_64-linux"; default.value = "x86_64-linux";
apply =
raw:
let
system = lib'.systems.from.string raw;
x = lib'.systems.withBuildInfo raw;
in
x;
}; };
host = lib.options.create { host = lib.options.create {
description = "The host platform for the package."; description = "The host platform for the package.";
type = lib'.types.platform; type = lib.types.string;
default.value = lib'.systems.withBuildInfo "x86_64-linux"; default.value = "x86_64-linux";
# apply = raw: let
# system = lib'.systems.from.string raw;
# in {
# inherit raw system;
# double = lib'.systems.into.double system;
# triple = lib'.systems.into.triple system;
# };
apply =
raw:
let
system = lib'.systems.from.string raw;
x = lib'.systems.withBuildInfo raw;
in
x;
}; };
target = lib.options.create { target = lib.options.create {
description = "The target platform for the package."; description = "The target platform for the package.";
type = lib'.types.platform;
default.value = lib'.systems.withBuildInfo "x86_64-linux";
};
};
name = lib.options.create {
description = "The name of the package.";
type = lib.types.string; type = lib.types.string;
default = { default.value = "x86_64-linux";
text = "\${config.pname}-\${config.version}"; # apply = raw: let
value = # system = lib'.systems.from.string raw;
if config.pname != null && config.version != null then "${config.pname}-${config.version}" else ""; # in {
# inherit raw system;
# double = lib'.systems.into.double system;
# triple = lib'.systems.into.triple system;
# };
apply =
raw:
let
system = lib'.systems.from.string raw;
x = lib'.systems.withBuildInfo raw;
in
x;
}; };
}; };
pname = lib.options.create { phases = lib.options.create {
description = "The program name for the package"; description = "The phases for the package.";
type = lib.types.nullish lib.types.string; type = lib.types.dag.of (lib.types.either lib.types.string (lib.types.function lib.types.string));
default.value = null; default.value = { };
};
version = lib.options.create {
description = "The version for the package.";
type = lib.types.nullish lib.types.version;
default.value = null;
};
builder = lib.options.create {
description = "The builder for the package.";
type = lib'.types.builder;
}; };
env = lib.options.create { env = lib.options.create {
@ -396,72 +241,81 @@ in
default.value = { }; default.value = { };
}; };
builder = lib.options.create {
description = "The builder for the package.";
type = lib'.types.builder;
};
deps = {
build = {
only = lib.options.create {
description = "Dependencies which are only used in the build environment.";
type = lib'.types.dependencies;
default.value = { };
};
build = lib.options.create {
description = "Dependencies which are created in the build environment and are executed in the build environment.";
type = lib'.types.dependencies;
default.value = { };
};
host = lib.options.create {
description = "Dependencies which are created in the build environment and are executed in the host environment.";
type = lib'.types.dependencies;
default.value = { };
};
target = lib.options.create {
description = "Dependencies which are created in the build environment and are executed in the target environment.";
type = lib'.types.dependencies;
default.value = { };
};
};
host = {
only = lib.options.create {
description = "Dependencies which are only used in the host environment.";
type = lib'.types.dependencies;
default.value = { };
};
host = lib.options.create {
description = "Dependencies which are executed in the host environment.";
type = lib'.types.dependencies;
default.value = { };
};
target = lib.options.create {
description = "Dependencies which are executed in the host environment which produces code for the target environment.";
type = lib'.types.dependencies;
default.value = { };
};
};
target = {
only = lib.options.create {
description = "Dependencies which are only used in the target environment.";
type = lib'.types.dependencies;
default.value = { };
};
target = lib.options.create {
description = "Dependencies which are executed in the target environment.";
type = lib'.types.dependencies;
default.value = { };
};
};
};
package = lib.options.create { package = lib.options.create {
description = "The built derivation."; description = "The built derivation.";
type = lib.types.derivation; type = lib.types.derivation;
default.value = config.builder.build config; default.value = config.builder.build config;
}; };
phases = lib.options.create {
description = "The phases for the package.";
type = lib.types.dag.of lib.types.string;
default.value = { };
};
context = lib.options.create {
description = "The context information that the package provides.";
type = lib.types.attrs.of lib.types.raw;
default.value = { };
};
hooks = lib.options.create {
description = "The hooks that the package provides.";
type = lib.types.function (lib.types.dag.of lib.types.string);
default.value = ctx: { };
};
propagate = lib.options.create {
description = "Whether the package should propagate its hooks and context.";
type = lib.types.bool;
default.value = false;
};
deps = lib.options.create {
description = "The dependencies for the package.";
type = deps build host target;
default.value = { };
apply = value: {
build = {
only = lib'.packages.dependencies.build build build build value.build.only;
build = lib'.packages.dependencies.build build build target value.build.build;
host = lib'.packages.dependencies.build build host target value.build.host;
target = lib'.packages.dependencies.build build target target value.build.target;
};
host = {
only = lib'.packages.dependencies.build host host host value.host.only;
host = lib'.packages.dependencies.build host host target value.host.host;
target = lib'.packages.dependencies.build host target target value.host.target;
};
target = {
only = lib'.packages.dependencies.build target target target value.target.only;
target = lib'.packages.dependencies.build target target target value.target.target;
};
};
};
};
};
type = (lib.types.coerceWithLocation initial transform final) // {
name = "Package";
description = "a package definition";
};
in
type
// {
children = type.children // {
inherit submodule;
};
}; };
}
);
}; };
}; };
} }

View file

@ -1,36 +0,0 @@
{ config }:
let
inherit (config) builders packages;
in
{
config.packages.aux.a = {
versions = {
"latest" =
{ config }:
{
config = {
meta = {
platforms = [ "i686-linux" ];
};
name = "${config.pname}-${config.version}";
pname = "a";
version = "1.0.0";
builder = builders.basic;
deps.build.host = {
inherit (packages.aux) b;
};
phases = {
install = ''
echo "a with b: ${config.deps.build.host.b.package.system}" > $out
'';
};
};
};
};
};
}

View file

@ -1,54 +0,0 @@
{ config }:
let
inherit (config) lib builders packages;
in
{
config.packages.aux.b = {
versions = {
"latest" =
{ config }:
{
options = {
custom = lib.options.create { type = lib.types.bool; };
};
config = {
meta = {
platforms = [ "i686-linux" ];
};
name = "${config.pname}-${config.version}";
custom = true;
pname = "b";
version = "1.0.0";
builder = builders.basic;
deps = {
build = {
host = {
c = packages.aux.c.versions.latest.extend {
propagate = true;
};
};
};
};
context = {
"foundation:cflags" = [ "-I $AUX_B/include" ];
};
hooks = ctx: { "aux:b:env" = lib.dag.entry.after [ "unpack" ] ''export AUX_B=${config.package}''; };
phases = {
install = ''
echo "b" > $out
'';
};
};
};
};
};
}

View file

@ -1,44 +0,0 @@
{ config }:
let
inherit (config) lib builders packages;
in
{
config.packages.aux.c = {
versions = {
"latest" =
{ config }:
{
options = {
custom = lib.options.create { type = lib.types.bool; };
};
config = {
meta = {
platforms = [ "i686-linux" ];
};
name = "${config.pname}-${config.version}";
custom = true;
pname = "c";
version = "1.0.0";
builder = builders.basic;
context = {
"foundation:cflags" = [ "-I $AUX_C/include" ];
};
hooks = ctx: { "aux:c:env" = lib.dag.entry.after [ "unpack" ] ''export AUX_C=${config.package}''; };
phases = {
install = ''
echo "c" > $out
'';
};
};
};
};
};
}

View file

@ -1,51 +1,30 @@
{ config }: {
lib,
lib',
config,
}:
let let
inherit (config) lib; doubles = lib'.systems.doubles.all;
doubles = lib.systems.doubles.all; packages = builtins.removeAttrs config.packages [ "cross" ];
packages = builtins.removeAttrs config.packages [ "cross" "cross-tools" ];
in in
{ {
includes = [ includes = [ ./foundation ];
./foundation
./aux/a.nix
./aux/b.nix
./aux/c.nix
];
options = { options = {
packages = lib.options.create { packages = lib.options.create {
description = "The package set."; description = "The package set.";
type = lib.types.submodule { type = lib.types.submodule {
freeform = lib.types.packages; freeform = lib.types.attrs.of (lib.types.submodule { freeform = lib'.types.alias; });
options = { options.cross = lib.attrs.generate doubles (
cross-tools = lib.attrs.generate doubles (
system:
lib.options.create {
description = "The cross-compilation tools for the ${system} target.";
type = lib.types.packages;
default.value = { };
}
);
cross = lib.attrs.generate doubles (
system: system:
lib.options.create { lib.options.create {
description = "The cross-compiled package set for the ${system} target."; description = "The cross-compiled package set for the ${system} target.";
type = lib.types.packages; type = lib'.types.packages;
default.value = { }; default = { };
} }
); );
# NOTE: We may offer a way to set default context values. For this reason we have
# nested `options` under `context` rather than using a plain option directly under `packages`.
context.options = lib.options.create {
description = "The available options for package contexts.";
default.value = { };
type = lib.types.attrs.of lib.types.option;
};
};
}; };
}; };
@ -61,67 +40,54 @@ in
}; };
}; };
config.packages.cross = lib.attrs.generate doubles (
system:
builtins.mapAttrs (
namespace:
builtins.mapAttrs (
name: alias:
let
setHost =
package:
if package != { } then
(package.extend (
{ config }:
{
config = { config = {
packages.cross-tools = lib.attrs.generate doubles ( platform = {
system: host = lib.modules.overrides.force system;
builtins.mapAttrs target = lib.modules.overrides.default system;
(
namespace:
builtins.mapAttrs (
name: alias:
let
setTarget =
package:
package
// {
__modules__ = package.__modules__ ++ [
{
config.platform = {
target = lib.modules.override 5 system;
};
}
];
}; };
deps = {
build = {
only = setHost package.deps.build.only;
build = setHost package.deps.build.build;
host = setHost package.deps.build.host;
target = setHost package.deps.build.target;
};
host = {
only = setHost package.deps.host.only;
host = setHost package.deps.host.host;
target = setHost package.deps.host.target;
};
target = {
only = setHost package.deps.target.only;
target = setHost package.deps.target.target;
};
};
};
}
)).config
else
package;
updated = alias // { updated = alias // {
versions = builtins.mapAttrs (version: package: setTarget package) alias.versions; versions = builtins.mapAttrs (version: package: setHost package) alias.versions;
}; };
in in
updated updated
) )
) ) packages
packages
); );
packages.cross = lib.attrs.generate doubles (
system:
builtins.mapAttrs
(
namespace:
builtins.mapAttrs (
name: alias:
let
setPlatform =
package:
package
// {
__modules__ = package.__modules__ ++ [
{
config.platform = {
host = lib.modules.override 5 system;
target = lib.modules.override 5 system;
};
}
];
};
updated = alias // {
versions = builtins.mapAttrs (version: package: setPlatform package) alias.versions;
};
in
updated
)
)
packages
);
};
} }

View file

@ -1,8 +1,8 @@
{ lib {
, lib' lib,
, config lib',
, options config,
, options,
}: }:
let let
inherit (config) inherit (config)
@ -11,14 +11,13 @@ let
# These are the upstream foundational packages exported from the Aux Foundation project. # These are the upstream foundational packages exported from the Aux Foundation project.
foundation foundation
packages
; ;
in in
{ {
config.packages.foundation.binutils = { config.packages.foundation.binutils = {
versions = { versions = {
"latest" = "latest" =
{ config }: { config, meta }:
{ {
options = { options = {
src = lib.options.create { src = lib.options.create {
@ -27,23 +26,9 @@ in
}; };
}; };
config = config = {
let
isBuildBootstrapped = config.platform.build.double == "i686-linux";
isHostBootstrapped = config.platform.host.double == "i686-linux";
isBootstrapped = isBuildBootstrapped && isHostBootstrapped;
isCross =
config.platform.build.double != config.platform.host.double
&& config.platform.host.double == config.platform.target.double;
in
{
meta = { meta = {
platforms = [ platforms = [ "i686-linux" ];
"i686-linux"
"x86_64-linux"
];
}; };
pname = "binutils"; pname = "binutils";
@ -51,44 +36,8 @@ in
builder = builders.basic; builder = builders.basic;
deps = {
build = {
only = {
gcc = lib.modules.when (!isBootstrapped) (
if isCross then
packages.foundation.gcc-cross.versions.latest.extend
{
platform = lib.modules.override 0 {
inherit (config.platform) build target;
host = config.platform.build;
};
}
else
packages.foundation.gcc.versions.latest
);
glibc = lib.modules.when (isCross) (
packages.foundation.glibc.versions.latest.extend {
platform = lib.modules.override 0 {
inherit (config.platform) host target build;
};
}
);
binutils = lib.modules.when (isCross) (
packages.foundation.binutils.versions.latest.extend {
platform = lib.modules.override 0 {
inherit (config.platform) target build;
host = config.platform.build;
};
}
);
};
};
};
env = { env = {
PATH = lib.paths.bin ( PATH = lib.paths.bin [
lib.lists.when (isBootstrapped) [ foundation.stage2-gcc ]
++ [
foundation.stage2-gcc foundation.stage2-gcc
foundation.stage2-binutils foundation.stage2-binutils
foundation.stage2-gnumake foundation.stage2-gnumake
@ -100,11 +49,8 @@ in
foundation.stage2-findutils foundation.stage2-findutils
foundation.stage2-gnutar foundation.stage2-gnutar
foundation.stage1-xz foundation.stage1-xz
] ];
); };
} // (lib.attrs.when (isCross) {
LDFLAGS_FOR_TARGET = "-B${config.deps.build.only.glibc.package}/lib -L${config.deps.build.only.glibc.package}/lib -I${config.deps.build.only.glibc.package}/include";
});
phases = phases =
let let
@ -113,11 +59,9 @@ in
./patches/deterministic.patch ./patches/deterministic.patch
]; ];
configureFlags = configureFlags = [
lib.lists.when (!isCross) [ # "CC=musl-gcc"
"LDFLAGS=--static" "LDFLAGS=--static"
]
++ [
"--prefix=${builtins.placeholder "out"}" "--prefix=${builtins.placeholder "out"}"
"--build=${config.platform.build.triple}" "--build=${config.platform.build.triple}"
"--host=${config.platform.host.triple}" "--host=${config.platform.host.triple}"
@ -139,28 +83,27 @@ in
"--with-lib-path=:" "--with-lib-path=:"
"--disable-multilib" "--disable-multilib"
]; ];
in in
{ {
unpack = '' unpack = lib.dag.entry.before [ "patch" ] ''
tar xf ${config.src} tar xf ${config.src}
cd binutils-${config.version} cd binutils-${config.version}
''; '';
patch = '' patch = lib.dag.entry.between [ "configure" ] [ "unpack" ] ''
${lib.strings.concatMapSep "\n" (file: "patch -Np1 -i ${file}") patches} ${lib.strings.concatMapSep "\n" (file: "patch -Np1 -i ${file}") patches}
''; '';
configure = '' configure = lib.dag.entry.between [ "build" ] [ "patch" ] ''
bash ./configure ${builtins.concatStringsSep " " configureFlags} bash ./configure ${builtins.concatStringsSep " " configureFlags}
''; '';
build = '' build = lib.dag.entry.between [ "install" ] [ "configure" ] ''
make -j $NIX_BUILD_CORES make -j $NIX_BUILD_CORES
''; '';
install = '' install = lib.dag.entry.after [ "build" ] ''
make -j $NIX_BUILD_CORES install-strip make -j $NIX_BUILD_CORES install-strip
''; '';
}; };

View file

@ -9,8 +9,6 @@
./gcc ./gcc
./binutils ./binutils
./linux-headers ./linux-headers
./glibc
# ./xz
]; ];
config = { config = {

View file

@ -1,84 +0,0 @@
{ config, options }:
let
inherit (config)
lib
packages
;
in
{
config.packages.foundation.gcc-bootstrap = {
versions = {
"latest" = config.packages.foundation.gcc.versions.latest.extend
(
{ config }:
{
config = {
meta = {
platforms = lib.modules.override 0 [
"i686-linux"
];
};
deps = {
build = {
build = {
gcc = lib.modules.override 0 (
packages.foundation.gcc-cross.versions.latest.extend {
platform = lib.modules.override 0 {
build = "i686-linux";
target = config.platform.target;
host = "i686-linux";
};
}
);
binutils = lib.modules.override 0 (
packages.foundation.binutils.versions.latest.extend {
platform = lib.modules.override 0 {
build = "i686-linux";
target = config.platform.target;
host = config.platform.host;
};
}
);
glibc = lib.modules.override 0 (
packages.foundation.glibc.versions.latest.extend {
platform = lib.modules.override 0 {
build = "i686-linux";
target = config.platform.target;
host = config.platform.host;
};
}
);
};
};
};
env = {
LIBRARY_PATH = lib.modules.override 0 "${config.deps.build.build.glibc.package}/lib";
LDFLAGS_FOR_TARGET =
lib.modules.override 0
"-L$(pwd)/${config.platform.target.triple}/libgcc -L${config.deps.build.build.glibc.package}/lib";
};
configureFlags = lib.modules.override 0 [
"--prefix=${builtins.placeholder "out"}"
# Pretend we're native even though we're not
"--build=${config.platform.target.triple}"
"--host=${config.platform.host.triple}"
"--target=${config.platform.target.triple}"
"--with-as=${config.deps.build.build.binutils.package}/bin/as"
"--with-ld=${config.deps.build.build.binutils.package}/bin/ld"
"--enable-languages=c,c++"
"--disable-bootstrap"
"--disable-libsanitizer"
"--disable-multilib"
"--with-native-system-header-dir=${config.deps.build.build.glibc.package}/include"
"--with-gxx-include-dir=${placeholder "out"}/include/c++/${config.version}/"
"--with-build-sysroot=/"
];
};
}
);
};
};
}

View file

@ -1,104 +0,0 @@
{ config, options }:
let
inherit (config)
lib
foundation
packages
;
in
{
config.packages.foundation.gcc-cross = {
versions = {
"latest" = config.packages.foundation.gcc.versions.latest.extend
(
{ config }:
{
config =
let
programPrefix = lib.strings.when
(
config.platform.build.triple != config.platform.target.triple
) "${config.platform.target.triple}-";
in
{
meta = {
platforms = lib.modules.override 0 [
"i686-linux"
];
};
deps = {
build = {
build = {
binutils = (
packages.foundation.binutils.versions.latest.extend {
platform = lib.modules.override 0 config.platform;
}
);
glibc = (
packages.foundation.glibc.versions.latest.extend {
platform = lib.modules.override 0 {
inherit (config.platform) build target;
host = config.platform.target;
};
}
);
linux-headers = (
packages.foundation.linux-headers.versions.latest.extend {
platform.target = lib.modules.override 0 config.platform.target;
}
);
};
};
};
env = {
# LIBRARY_PATH = lib.modules.override 0 "${foundation.stage1-musl}/lib";
CC = lib.modules.override 0 "gcc -Wl,-dynamic-linker -Wl,${foundation.stage1-musl}/lib/libc.so -idirafter ${foundation.stage1-musl}/include";
CXX = lib.modules.override 0 "g++ -Wl,-dynamic-linker -Wl,${foundation.stage1-musl}/lib/libc.so -idirafter ${foundation.stage1-musl}/include";
CFLAGS_FOR_TARGET =
lib.modules.override 0
"-Wl,-dynamic-linker -Wl,${config.deps.build.build.glibc.package}/lib/ld-linux-x86-64.so.2 -B${config.deps.build.build.glibc.package}/lib";
LDFLAGS_FOR_TARGET =
lib.modules.override 0
"-L$(pwd)/${config.platform.target.triple}/libgcc -L${config.deps.build.build.glibc.package}/lib";
};
configureFlags = lib.modules.override 0 [
"--prefix=${builtins.placeholder "out"}"
"--build=${config.platform.build.triple}"
"--host=${config.platform.host.triple}"
"--target=${config.platform.target.triple}"
"--with-as=${config.deps.build.build.binutils.package}/bin/${programPrefix}as"
"--with-ld=${config.deps.build.build.binutils.package}/bin/${programPrefix}ld"
"--enable-languages=c,c++"
"--disable-libsanitizer"
"--disable-lto"
"--disable-multilib"
"--with-headers=${config.deps.build.build.glibc.package}/include"
"--with-build-sysroot=/"
# "--with-sysroot=${config.deps.build.build.glibc.package}"
"--with-native-system-header-dir=${config.deps.build.build.glibc.package}/include"
];
phases.configure = lib.modules.override 0 ''
# Configure
mkdir build
cd build
echo PATH=$PATH
# TODO(vlinkz) Hack to fix missing crti.o and crtn.o. Figure out how to properly find their paths.
mkdir gcc
ln -sv ${config.deps.build.build.glibc.package}/lib/{crti.o,crtn.o} gcc
mkdir -p x86_64-unknown-linux-gnu/libstdc++-v3/src
ln -sv ${config.deps.build.build.glibc.package}/lib/{crti.o,crtn.o} x86_64-unknown-linux-gnu/libstdc++-v3/src
bash ../configure ${builtins.concatStringsSep " " config.configureFlags}
'';
};
}
);
};
};
}

View file

@ -1,22 +1,19 @@
{ config, options }: {
lib,
lib',
config,
options,
}:
let let
inherit (config) inherit (config)
lib
mirrors mirrors
builders builders
# These are the upstream foundational packages exported from the Aux Foundation project. # These are the upstream foundational packages exported from the Aux Foundation project.
foundation foundation
packages
; ;
in in
{ {
includes = [
./newlib.nix
./cross.nix
./bootstrap.nix
];
config.packages.foundation.gcc = { config.packages.foundation.gcc = {
versions = { versions = {
"latest" = "latest" =
@ -81,78 +78,46 @@ in
description = "Version of isl."; description = "Version of isl.";
}; };
}; };
configureFlags = lib.options.create {
type = lib.types.list.of lib.types.string;
description = "Flags to pass to the configure script.";
}; };
exports = lib.options.create { config = {
type = lib.types.attrs.of lib.types.string;
description = "List of exports to add to the environment.";
};
};
config =
let
isBuildBootstrapped = config.platform.build.double == "i686-linux";
isHostBootstrapped = config.platform.host.double == "i686-linux";
isBootstrapped = isBuildBootstrapped && isHostBootstrapped;
crossTool =
(config.platform.target.triple != config.platform.host.triple)
&& (config.platform.host.triple == config.platform.build.triple);
cross =
(config.platform.target.triple != config.platform.host.triple)
&& (config.platform.host.triple == config.platform.target.triple);
programPrefix = lib.strings.when
(
config.platform.build.triple != config.platform.target.triple
) "${config.platform.target.triple}-";
libc = if isBootstrapped then foundation.stage1-musl else config.deps.build.build.glibc.package;
libcLd =
if isBootstrapped then
"${foundation.stage1-musl}/lib/libc.so"
else
"${config.deps.build.build.glibc.package}/lib/ld-linux-x86-64.so.2";
host = lib.systems.withBuildInfo config.platform.host;
target = lib.systems.withBuildInfo config.platform.target;
in
{
meta = { meta = {
platforms = [ platforms = [ "i686-linux" ];
"i686-linux"
];
}; };
pname = "gcc-${config.platform.build.double}--${config.platform.host.double}--${config.platform.target.double}"; pname = "gcc";
version = "13.2.0"; version = "13.2.0";
builder = builders.basic; builder = builders.basic;
deps = { env = {
build = { PATH =
build = lib.modules.when (!isBootstrapped) { let
gcc = packages.foundation.gcc-cross.versions.latest; gcc =
glibc = packages.foundation.glibc.versions.latest; if
linux-headers = packages.foundation.linux-headers.versions.latest; config.platform.build.triple == config.platform.host.triple
binutils = packages.foundation.binutils.versions.latest; # If we're on the same system then we can use the existing GCC instance.
then
foundation.stage2-gcc
# Otherwise we are going to need a cross-compiler.
else
# TODO: Create a gcc-cross package.
(meta.extend (args: {
config = {
platform = {
build = config.platform.build.triple;
host = config.platform.build.triple;
target = lib.modules.override.force config.platform.host.triple;
}; };
}; };
}; })).config.package;
in
env = lib.paths.bin [
{ foundation.stage2-gcc
PATH = lib.modules.when (isBuildBootstrapped) ( foundation.stage2-binutils
lib.paths.bin ([
foundation.stage2-gnumake foundation.stage2-gnumake
foundation.stage2-gnused foundation.stage2-gnused
foundation.stage2-gnugrep foundation.stage2-gnugrep
foundation.stage2-gnupatch
foundation.stage2-gawk foundation.stage2-gawk
foundation.stage2-diffutils foundation.stage2-diffutils
foundation.stage2-findutils foundation.stage2-findutils
@ -160,76 +125,17 @@ in
foundation.stage2-gzip foundation.stage2-gzip
foundation.stage2-bzip2 foundation.stage2-bzip2
foundation.stage1-xz foundation.stage1-xz
] ++ (lib.lists.when (isBootstrapped) [
foundation.stage2-gcc
foundation.stage2-binutils
]))
);
CFLAGS_FOR_TARGET = "-Wl,-dynamic-linker -Wl,${libcLd}";
}
// lib.attrs.when (isBootstrapped) {
CC = "gcc -Wl,-dynamic-linker -Wl,${foundation.stage1-musl}/lib/libc.so";
CXX = "g++ -Wl,-dynamic-linker -Wl,${foundation.stage1-musl}/lib/libc.so";
}
// lib.attrs.when (!cross && !crossTool) {
LIBRARY_PATH = "${libc}/lib";
};
hooks =
let
flags =
if (isBootstrapped && !(cross || crossTool)) then
[
"-Wl,-dynamic-linker"
"-Wl,${foundation.stage1-musl}/lib/libc.so"
]
else
[
"-Wl,-dynamic-linker"
"-Wl,${config.deps.build.build.glibc.package}/lib/ld-linux${lib.strings.when (target.isx86 && target.is64bit) "-x86-64"}.so.2"
"-B${config.deps.build.build.glibc.package}/lib"
# "-idirafter ${config.deps.build.build.glibc.package}/include"
]; ];
in
ctx: {
"aux:gcc:env" = lib.dag.entry.between [ "unpack" ] [ "configure" ] ''
export CC='${config.package}/bin/${programPrefix}gcc ${builtins.concatStringsSep " " flags}'
export CXX='${config.package}/bin/${programPrefix}g++ ${builtins.concatStringsSep " " flags}'
export CC_FOR_TARGET=$CC
export CXX_FOR_TARGET=$CXX
export CC_FOR_BUILD=$CC
export CXX_FOR_BUILD=$CXX
alias gcc='$CC'
alias g++='$CXX'
'';
}; };
configureFlags =
[
"--prefix=${builtins.placeholder "out"}"
"--build=${config.platform.build.triple}"
"--host=${config.platform.host.triple}"
"--target=${config.platform.target.triple}"
"--enable-languages=c,c++"
"--disable-bootstrap"
"--disable-libsanitizer"
"--disable-multilib"
"--with-build-sysroot=/"
"--with-native-system-header-dir=${libc}/include"
]
++ lib.lists.when (isBootstrapped) [
"--disable-lto"
];
phases = phases =
let let
patches = [ host = lib'.systems.withBuildInfo config.platform.host;
# Make binutils output deterministic by default.
./patches/libstdc++-target.patch mbits = if host.system.cpu.family == "x86" then if host.is64bit then "-m64" else "-m32" else "";
];
in in
{ {
unpack = '' unpack = lib.dag.entry.before [ "patch" ] ''
# Unpack # Unpack
tar xf ${config.src} tar xf ${config.src}
tar xf ${config.gmp.src} tar xf ${config.gmp.src}
@ -244,36 +150,46 @@ in
ln -s ../isl-${config.isl.version} isl ln -s ../isl-${config.isl.version} isl
''; '';
patch = '' patch = lib.dag.entry.between [ "configure" ] [ "unpack" ] ''
${lib.strings.concatMapSep "\n" (file: "patch -Np1 -i ${file}") patches} # Patch
${lib.strings.when (isBootstrapped && !(crossTool || cross))''
# force musl even if host triple is gnu # force musl even if host triple is gnu
sed -i 's|"os/gnu-linux"|"os/generic"|' libstdc++-v3/configure.host sed -i 's|"os/gnu-linux"|"os/generic"|' libstdc++-v3/configure.host
''}
''; '';
configure = '' configure = lib.dag.entry.between [ "build" ] [ "patch" ] ''
# Configure # Configure
mkdir build export CC="gcc -Wl,-dynamic-linker -march=${
cd build host.gcc.arch or host.system.cpu.family
} ${mbits} -Wl,${foundation.stage1-musl}/lib/libc.so"
export CXX="g++ -Wl,-dynamic-linker -Wl,${foundation.stage1-musl}/lib/libc.so"
export CFLAGS_FOR_TARGET="-Wl,-dynamic-linker -Wl,${foundation.stage1-musl}/lib/libc.so"
export LIBRARY_PATH="${foundation.stage1-musl}/lib"
bash ../configure ${builtins.concatStringsSep " " config.configureFlags} bash ./configure \
--prefix=$out \
--build=${config.platform.build.triple} \
--host=${config.platform.host.triple} \
--target=${config.platform.target.triple} \
--with-native-system-header-dir=/include \
--with-sysroot=${foundation.stage1-musl} \
--enable-languages=c,c++ \
--disable-bootstrap \
--disable-libsanitizer \
--disable-lto \
--disable-multilib \
--disable-plugin \
CFLAGS=-static \
CXXFLAGS=-static
''; '';
build = '' build = lib.dag.entry.between [ "install" ] [ "configure" ] ''
# Build # Build
make -j $NIX_BUILD_CORES make -j $NIX_BUILD_CORES
''; '';
install = '' install = lib.dag.entry.after [ "build" ] ''
# Install # Install
${ make -j $NIX_BUILD_CORES install-strip
lib.strings.when (host.is64bit) ''
mkdir -p $out/lib
ln -s lib $out/lib64
''
}
make -j $NIX_BUILD_CORES install
''; '';
}; };

View file

@ -1,71 +0,0 @@
{ config, options }:
let
inherit (config)
lib
packages
;
in
{
config.packages.foundation.gcc-newlib = {
versions = {
"latest" = config.packages.foundation.gcc.versions.latest.extend (
{ config }:
{
config =
let
programPrefix = lib.strings.when
(
config.platform.build.triple != config.platform.target.triple
) "${config.platform.target.triple}-";
in
{
meta = {
platforms = lib.modules.override 0 [
"i686-linux"
];
};
deps = {
build = {
build = {
binutils = (
packages.foundation.binutils.versions.latest.extend {
platform = lib.modules.override 0 config.platform;
}
);
};
};
};
configureFlags = lib.modules.override 0 [
"--prefix=${builtins.placeholder "out"}"
"--build=${config.platform.build.triple}"
"--host=${config.platform.host.triple}"
"--target=${config.platform.target.triple}"
"--with-as=${config.deps.build.build.binutils.package}/bin/${programPrefix}as"
"--with-ld=${config.deps.build.build.binutils.package}/bin/${programPrefix}ld"
"--enable-languages=c,c++"
"--disable-bootstrap"
"--disable-libsanitizer"
"--disable-lto"
"--disable-multilib"
"--disable-plugin"
"--disable-libssp"
"--disable-libvtv"
"--disable-libstdcxx"
"--disable-libquadmath"
"--disable-threads"
"--disable-decimal-float"
"--disable-shared"
"--disable-libmudflap"
"--disable-libgomp"
"--disable-libatomic"
"--without-headers"
"--with-newlib"
];
};
}
);
};
};
}

View file

@ -1,33 +0,0 @@
# From https://github.com/NixOS/nixpkgs/blob/nixos-24.05/pkgs/development/compilers/gcc/patches/libstdc%2B%2B-target.patch
Patch to make the target libraries 'configure' scripts find the proper CPP.
I noticed that building the mingw32 cross compiler.
Looking at the build script for mingw in archlinux, I think that only nixos
needs this patch. I don't know why.
diff --git a/Makefile.in b/Makefile.in
index 93f66b6..d691917 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -266,6 +266,7 @@ BASE_TARGET_EXPORTS = \
AR="$(AR_FOR_TARGET)"; export AR; \
AS="$(COMPILER_AS_FOR_TARGET)"; export AS; \
CC="$(CC_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS"; export CC; \
+ CPP="$(CC_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS -E"; export CC; \
CFLAGS="$(CFLAGS_FOR_TARGET)"; export CFLAGS; \
CONFIG_SHELL="$(SHELL)"; export CONFIG_SHELL; \
CPPFLAGS="$(CPPFLAGS_FOR_TARGET)"; export CPPFLAGS; \
@@ -291,11 +292,13 @@ BASE_TARGET_EXPORTS = \
RAW_CXX_TARGET_EXPORTS = \
$(BASE_TARGET_EXPORTS) \
CXX_FOR_TARGET="$(RAW_CXX_FOR_TARGET)"; export CXX_FOR_TARGET; \
- CXX="$(RAW_CXX_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS"; export CXX;
+ CXX="$(RAW_CXX_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS"; export CXX; \
+ CXXCPP="$(RAW_CXX_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS -E"; export CXX;
NORMAL_TARGET_EXPORTS = \
$(BASE_TARGET_EXPORTS) \
- CXX="$(CXX_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS"; export CXX;
+ CXX="$(CXX_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS"; export CXX; \
+ CXXCPP="$(CXX_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS -E"; export CXX;
# Where to find GMP
HOST_GMPLIBS = @gmplibs@

View file

@ -3,7 +3,6 @@
lib', lib',
config, config,
options, options,
packages,
}: }:
let let
inherit (config) inherit (config)
@ -11,7 +10,6 @@ let
builders builders
# These are the upstream foundational packages exported from the Aux Foundation project. # These are the upstream foundational packages exported from the Aux Foundation project.
packages
foundation foundation
; ;
in in
@ -28,35 +26,12 @@ in
}; };
}; };
config = config = {
let
isCross =
(config.platform.build.triple != config.platform.host.triple)
&& (config.platform.host.triple == config.platform.target.triple);
binutils =
if isCross then
"${
(packages.foundation.binutils.versions.latest.extend {
platform = lib.modules.override 0 {
inherit (config.platform) build target;
host = config.platform.build;
};
}).package
}/${config.platform.target.triple}"
else
foundation.stage2-binutils;
in
{
meta = { meta = {
platforms = [ platforms = [ "i686-linux" ];
"i686-linux"
"x86_64-linux"
];
}; };
pname = "glibc"; pname = "gcc";
version = "2.38"; version = "2.38";
src = builtins.fetchurl { src = builtins.fetchurl {
@ -66,39 +41,30 @@ in
builder = builders.basic; builder = builders.basic;
deps = {
build = {
host = {
linux-headers = (
packages.foundation.linux-headers.versions.latest.extend {
platform.target = lib.modules.override 0 config.platform.target;
}
);
};
};
};
env = { env = {
PATH = PATH =
let let
gcc = gcc =
if if
isCross config.platform.build.triple == config.platform.host.triple
# Otherwise we are going to need a cross-compiler.
then
(packages.foundation.gcc-newlib.versions.latest.extend {
platform = lib.modules.override 0 {
inherit (config.platform) build target;
host = config.platform.build;
};
}).package
# If we're on the same system then we can use the existing GCC instance. # If we're on the same system then we can use the existing GCC instance.
then
foundation.stage2-gcc
# Otherwise we are going to need a cross-compiler.
else else
foundation.stage2-gcc; (meta.extend (args: {
config = {
platform = {
build = config.platform.build.triple;
host = config.platform.build.triple;
target = lib.modules.override.force config.platform.host.triple;
};
};
})).config.package;
in in
lib.paths.bin [ lib.paths.bin [
gcc foundation.stage2-gcc
binutils foundation.stage2-binutils
foundation.stage2-gnumake foundation.stage2-gnumake
foundation.stage2-gnused foundation.stage2-gnused
foundation.stage2-gnugrep foundation.stage2-gnugrep
@ -108,41 +74,36 @@ in
foundation.stage2-gnutar foundation.stage2-gnutar
foundation.stage2-gzip foundation.stage2-gzip
foundation.stage2-bzip2 foundation.stage2-bzip2
foundation.stage1-python
foundation.stage1-bison
foundation.stage1-xz foundation.stage1-xz
]; ];
}; };
phases = phases = {
unpack = lib.dag.entry.before [ "patch" ] ''
{
unpack = ''
tar xf ${config.src} tar xf ${config.src}
cd glibc-${config.version} cd glibc-${config.version}
''; '';
configure = '' configure = lib.dag.entry.between [ "build" ] [ "patch" ] ''
mkdir build mkdir build
cd build cd build
# libstdc++.so is built against musl and fails to link
export CXX=false
bash ../configure \ bash ../configure \
--prefix=$out \ --prefix=$out \
--build=${config.platform.build.triple} \ --build=${config.platform.build.triple} \
--host=${config.platform.host.triple} \ --host=${config.platform.host.triple} \
--with-headers=${config.deps.build.host.linux-headers.package}/include \ --with-headers=${foundation.stage1-linux-headers}/include
--with-binutils=${binutils}/bin
''; '';
build = '' build = lib.dag.entry.between [ "install" ] [ "configure" ] ''
# Build # Build
make -j $NIX_BUILD_CORES make -j $NIX_BUILD_CORES
''; '';
install = '' install = lib.dag.entry.after [ "build" ] ''
# Install # Install
make -j $NIX_BUILD_CORES install make -j $NIX_BUILD_CORES install-strip
ln -sv $(ls -d ${config.deps.build.host.linux-headers.package}/include/* | grep -v scsi\$) $out/include/
''; '';
}; };
}; };

View file

@ -1,8 +1,8 @@
{ lib {
, lib' lib,
, config lib',
, options config,
, options,
}: }:
let let
inherit (config) inherit (config)
@ -28,7 +28,7 @@ in
config = { config = {
meta = { meta = {
platforms = [ "x86_64-linux" "i686-linux" ]; platforms = [ "i686-linux" ];
}; };
pname = "linux-headers"; pname = "linux-headers";
@ -54,16 +54,20 @@ in
}; };
phases = { phases = {
unpack = '' unpack = lib.dag.entry.before [ "patch" ] ''
tar xf ${config.src} tar xf ${config.src}
cd linux-${config.version} cd linux-${config.version}
''; '';
build = '' patch = lib.dag.entry.between [ "configure" ] [ "unpack" ] '''';
make -j $NIX_BUILD_CORES CC=musl-gcc HOSTCC=musl-gcc ARCH=${config.platform.target.linux.arch} headers
configure = lib.dag.entry.between [ "build" ] [ "patch" ] '''';
build = lib.dag.entry.between [ "install" ] [ "configure" ] ''
make -j $NIX_BUILD_CORES CC=musl-gcc HOSTCC=musl-gcc ARCH=${config.platform.host.linux.arch} headers
''; '';
install = '' install = lib.dag.entry.after [ "build" ] ''
find usr/include -name '.*' -exec rm {} + find usr/include -name '.*' -exec rm {} +
mkdir -p $out mkdir -p $out
cp -rv usr/include $out/ cp -rv usr/include $out/