refactor: format all nix code

This commit is contained in:
Jake Hamilton 2024-06-22 10:58:44 -07:00
parent 3479354ec9
commit a707b0f06b
Signed by untrusted user: jakehamilton
GPG key ID: 9762169A1B35EA68
153 changed files with 8899 additions and 8024 deletions

View file

@ -1,4 +1,6 @@
#!/usr/bin/env nix-shell #!/usr/bin/env nix-shell
#!nix-shell -i bash -I "nixpkgs=https://github.com/nixos/nixpkgs/archive/nixos-24.05.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
nixfmt ${1:-"--verify"} ./**/*.nix files=$(find . -name "*.nix" -type f)
nixfmt ${1:-"--verify"} ${files}

View file

@ -1,13 +1,12 @@
{ { lib, config }:
lib, let
config,
}: let
system = config.aux.system; system = config.aux.system;
builders = config.aux.foundation.builders; builders = config.aux.foundation.builders;
stage0 = config.aux.foundation.stages.stage0; stage0 = config.aux.foundation.stages.stage0;
stage1 = config.aux.foundation.stages.stage1; stage1 = config.aux.foundation.stages.stage1;
in { in
{
options.aux.foundation.builders.bash.boot = { options.aux.foundation.builders.bash.boot = {
build = lib.options.create { build = lib.options.create {
type = lib.types.function lib.types.derivation; type = lib.types.function lib.types.derivation;
@ -17,61 +16,67 @@ in {
config = { config = {
aux.foundation.builders.bash.boot = { aux.foundation.builders.bash.boot = {
build = settings @ { build =
name, settings@{
script, name,
meta ? {}, script,
extras ? {}, meta ? { },
env ? {}, extras ? { },
deps ? {}, env ? { },
... deps ? { },
}: let ...
package = builtins.derivation ( }:
(builtins.removeAttrs settings ["meta" "extras" "executable" "env" "deps" "script"]) let
// env package = builtins.derivation (
// { (builtins.removeAttrs settings [
inherit name system script; "meta"
"extras"
"executable"
"env"
"deps"
"script"
])
// env
// {
inherit name system script;
passAsFile = ["script"]; passAsFile = [ "script" ];
builder = "${stage1.bash.boot.package}/bin/bash"; builder = "${stage1.bash.boot.package}/bin/bash";
args = [ args = [
"-e" "-e"
(builtins.toFile "bash-builder.sh" '' (builtins.toFile "bash-builder.sh" ''
export CONFIG_SHELL=$SHELL export CONFIG_SHELL=$SHELL
# Normalize the NIX_BUILD_CORES variable. The value might be 0, which # Normalize the NIX_BUILD_CORES variable. The value might be 0, which
# means that we're supposed to try and auto-detect the number of # means that we're supposed to try and auto-detect the number of
# available CPU cores at run-time. We don't have nproc to detect the # available CPU cores at run-time. We don't have nproc to detect the
# number of available CPU cores so default to 1 if not set. # number of available CPU cores so default to 1 if not set.
NIX_BUILD_CORES="''${NIX_BUILD_CORES:-1}" NIX_BUILD_CORES="''${NIX_BUILD_CORES:-1}"
if [ $NIX_BUILD_CORES -le 0 ]; then if [ $NIX_BUILD_CORES -le 0 ]; then
NIX_BUILD_CORES=1 NIX_BUILD_CORES=1
fi fi
export NIX_BUILD_CORES export NIX_BUILD_CORES
bash -eux $scriptPath bash -eux $scriptPath
'') '')
]; ];
SHELL = "${stage1.bash.boot.package}/bin/bash"; SHELL = "${stage1.bash.boot.package}/bin/bash";
PATH = lib.paths.bin ( PATH = lib.paths.bin (
(deps.build.host or []) (deps.build.host or [ ])
++ [ ++ [
stage1.bash.boot.package stage1.bash.boot.package
stage1.coreutils.boot.package stage1.coreutils.boot.package
stage0.mescc-tools-extra.package stage0.mescc-tools-extra.package
] ]
); );
} }
); );
in in
package package // { inherit meta extras; };
// {
inherit meta extras;
};
}; };
}; };
} }

View file

@ -1,15 +1,12 @@
{ { lib, config }:
lib, let
config,
}: let
system = config.aux.system; system = config.aux.system;
builders = config.aux.foundation.builders; builders = config.aux.foundation.builders;
stage1 = config.aux.foundation.stages.stage1; stage1 = config.aux.foundation.stages.stage1;
in { in
includes = [ {
./boot.nix includes = [ ./boot.nix ];
];
options.aux.foundation.builders.bash = { options.aux.foundation.builders.bash = {
build = lib.options.create { build = lib.options.create {
@ -20,60 +17,66 @@ in {
config = { config = {
aux.foundation.builders.bash = { aux.foundation.builders.bash = {
build = settings @ { build =
name, settings@{
script, name,
meta ? {}, script,
extras ? {}, meta ? { },
env ? {}, extras ? { },
deps ? {}, env ? { },
... deps ? { },
}: let ...
package = builtins.derivation ( }:
(builtins.removeAttrs settings ["meta" "extras" "executable" "env" "deps" "script"]) let
// env package = builtins.derivation (
// { (builtins.removeAttrs settings [
inherit name system script; "meta"
"extras"
"executable"
"env"
"deps"
"script"
])
// env
// {
inherit name system script;
passAsFile = ["script"]; passAsFile = [ "script" ];
builder = "${stage1.bash.package}/bin/bash"; builder = "${stage1.bash.package}/bin/bash";
args = [ args = [
"-e" "-e"
(builtins.toFile "bash-builder.sh" '' (builtins.toFile "bash-builder.sh" ''
export CONFIG_SHELL=$SHELL export CONFIG_SHELL=$SHELL
# Normalize the NIX_BUILD_CORES variable. The value might be 0, which # Normalize the NIX_BUILD_CORES variable. The value might be 0, which
# means that we're supposed to try and auto-detect the number of # means that we're supposed to try and auto-detect the number of
# available CPU cores at run-time. # available CPU cores at run-time.
NIX_BUILD_CORES="''${NIX_BUILD_CORES:-1}" NIX_BUILD_CORES="''${NIX_BUILD_CORES:-1}"
if ((NIX_BUILD_CORES <= 0)); then if ((NIX_BUILD_CORES <= 0)); then
guess=$(nproc 2>/dev/null || true) guess=$(nproc 2>/dev/null || true)
((NIX_BUILD_CORES = guess <= 0 ? 1 : guess)) ((NIX_BUILD_CORES = guess <= 0 ? 1 : guess))
fi fi
export NIX_BUILD_CORES export NIX_BUILD_CORES
bash -eux $scriptPath bash -eux $scriptPath
'') '')
]; ];
SHELL = "${stage1.bash.package}/bin/bash"; SHELL = "${stage1.bash.package}/bin/bash";
PATH = lib.paths.bin ( PATH = lib.paths.bin (
(deps.build.host or []) (deps.build.host or [ ])
++ [ ++ [
stage1.bash.package stage1.bash.package
stage1.coreutils.package stage1.coreutils.package
] ]
); );
} }
); );
in in
package package // { inherit meta extras; };
// {
inherit meta extras;
};
}; };
}; };
} }

View file

@ -1,11 +1,10 @@
{ { lib, config }:
lib, let
config,
}: let
system = config.aux.system; system = config.aux.system;
stage0 = config.aux.foundation.stages.stage0; stage0 = config.aux.foundation.stages.stage0;
in { in
{
options.aux.foundation.builders.file.text = { options.aux.foundation.builders.file.text = {
build = lib.options.create { build = lib.options.create {
type = lib.types.function lib.types.derivation; type = lib.types.function lib.types.derivation;
@ -15,55 +14,62 @@ in {
config = { config = {
aux.foundation.builders.file.text = { aux.foundation.builders.file.text = {
build = settings @ { build =
name, settings@{
contents, name,
isExecutable ? false, contents,
destination ? "", isExecutable ? false,
meta ? {}, destination ? "",
extras ? {}, meta ? { },
... extras ? { },
}: let ...
script = }:
'' let
target=''${out}''${destination} script =
'' ''
+ lib.strings.when (builtins.dirOf destination == ".") '' target=''${out}''${destination}
mkdir -p ''${out}''${destinationDir} ''
'' + lib.strings.when (builtins.dirOf destination == ".") ''
+ '' mkdir -p ''${out}''${destinationDir}
cp ''${contentsPath} ''${target} ''
'' + ''
+ lib.strings.when isExecutable '' cp ''${contentsPath} ''${target}
chmod 555 ''${target} ''
''; + lib.strings.when isExecutable ''
package = builtins.derivation ( chmod 555 ''${target}
(builtins.removeAttrs settings ["meta" "extras" "executable" "isExecutable"]) '';
// { package = builtins.derivation (
inherit name system destination contents; (builtins.removeAttrs settings [
destinationDir = builtins.dirOf destination; "meta"
"extras"
"executable"
"isExecutable"
])
// {
inherit
name
system
destination
contents
;
destinationDir = builtins.dirOf destination;
passAsFile = ["contents"]; passAsFile = [ "contents" ];
builder = "${stage0.kaem.package}/bin/kaem"; builder = "${stage0.kaem.package}/bin/kaem";
args = [ args = [
"--verbose" "--verbose"
"--strict" "--strict"
"--file" "--file"
(builtins.toFile "write-text-to-file.kaem" script) (builtins.toFile "write-text-to-file.kaem" script)
]; ];
PATH = lib.paths.bin [ PATH = lib.paths.bin [ stage0.mescc-tools-extra.package ];
stage0.mescc-tools-extra.package }
]; );
} in
); package // { inherit meta extras; };
in
package
// {
inherit meta extras;
};
}; };
}; };
} }

View file

@ -1,12 +1,11 @@
{ { lib, config }:
lib, let
config,
}: let
system = config.aux.system; system = config.aux.system;
builders = config.aux.foundation.builders; builders = config.aux.foundation.builders;
stage0 = config.aux.foundation.stages.stage0; stage0 = config.aux.foundation.stages.stage0;
in { in
{
options.aux.foundation.builders.kaem = { options.aux.foundation.builders.kaem = {
build = lib.options.create { build = lib.options.create {
type = lib.types.function lib.types.derivation; type = lib.types.function lib.types.derivation;
@ -16,50 +15,54 @@ in {
config = { config = {
aux.foundation.builders.kaem = { aux.foundation.builders.kaem = {
build = settings @ { build =
name, settings@{
script, name,
meta ? {}, script,
extras ? {}, meta ? { },
env ? {}, extras ? { },
deps ? {}, env ? { },
... deps ? { },
}: let ...
package = builtins.derivation ( }:
(builtins.removeAttrs settings ["meta" "extras" "executable" "env" "deps" "script"]) let
// env package = builtins.derivation (
// { (builtins.removeAttrs settings [
inherit name system; "meta"
"extras"
"executable"
"env"
"deps"
"script"
])
// env
// {
inherit name system;
builder = "${stage0.kaem.package}/bin/kaem"; builder = "${stage0.kaem.package}/bin/kaem";
args = [ args = [
"--verbose" "--verbose"
"--strict" "--strict"
"--file" "--file"
( (builders.file.text.build {
builders.file.text.build {
name = "${name}-builder"; name = "${name}-builder";
contents = script; contents = script;
} })
) ];
];
PATH = lib.paths.bin ( PATH = lib.paths.bin (
(deps.build.host or []) (deps.build.host or [ ])
++ [ ++ [
stage0.kaem.package stage0.kaem.package
stage0.mescc-tools.package stage0.mescc-tools.package
stage0.mescc-tools-extra.package stage0.mescc-tools-extra.package
] ]
); );
} }
); );
in in
package package // { inherit meta extras; };
// {
inherit meta extras;
};
}; };
}; };
} }

View file

@ -1,9 +1,8 @@
{ { lib, config }:
lib, let
config,
}: let
system = config.aux.system; system = config.aux.system;
in { in
{
options.aux.foundation.builders.raw = { options.aux.foundation.builders.raw = {
build = lib.options.create { build = lib.options.create {
type = lib.types.function lib.types.derivation; type = lib.types.function lib.types.derivation;
@ -13,30 +12,38 @@ in {
config = { config = {
aux.foundation.builders.raw = { aux.foundation.builders.raw = {
build = settings @ { build =
pname, settings@{
version, pname,
executable, version,
args ? [], executable,
meta ? {}, args ? [ ],
extras ? {}, meta ? { },
... extras ? { },
}: let ...
package = builtins.derivation ( }:
(builtins.removeAttrs settings ["meta" "extras" "executable"]) let
// { package = builtins.derivation (
inherit version pname system args; (builtins.removeAttrs settings [
"meta"
"extras"
"executable"
])
// {
inherit
version
pname
system
args
;
name = "${pname}-${version}"; name = "${pname}-${version}";
builder = executable; builder = executable;
} }
); );
in in
package package // { inherit meta extras; };
// {
inherit meta extras;
};
}; };
}; };
} }

View file

@ -13,4 +13,4 @@ let
system = ./system; system = ./system;
}; };
in in
modules modules

View file

@ -1,20 +1,19 @@
{ { lib, config }:
lib, let
config,
}: let
options = { options = {
packages = lib.options.create { packages = lib.options.create {
default.value = {}; default.value = { };
type = lib.types.attrs.of lib.types.derivation; type = lib.types.attrs.of lib.types.derivation;
}; };
extras = lib.options.create { extras = lib.options.create {
default.value = {}; default.value = { };
type = lib.types.attrs.any; type = lib.types.attrs.any;
}; };
}; };
in { in
{
options = { options = {
exports = { exports = {
inherit (options) packages extras; inherit (options) packages extras;
@ -27,19 +26,16 @@ in {
config = { config = {
exports.resolved = { exports.resolved = {
packages = packages = builtins.mapAttrs (
builtins.mapAttrs ( name: value:
lib.attrs.filter (
name: value: name: value:
lib.attrs.filter if value ? meta && value.meta ? platforms then
( builtins.elem config.aux.system value.meta.platforms
name: value: else
if value ? meta && value.meta ? platforms true
then builtins.elem config.aux.system value.meta.platforms ) value
else true ) config.exports.packages;
)
value
)
config.exports.packages;
extras = config.exports.extras; extras = config.exports.extras;
}; };

View file

@ -1,4 +1,5 @@
{lib}: { { lib }:
{
options.aux.mirrors = { options.aux.mirrors = {
gnu = lib.options.create { gnu = lib.options.create {
type = lib.types.string; type = lib.types.string;

View file

@ -1,7 +1,5 @@
{ { lib, config }:
lib, let
config,
}: let
system = config.aux.system; system = config.aux.system;
parts = lib.strings.split "-" system; parts = lib.strings.split "-" system;
@ -285,7 +283,8 @@
family = "javascript"; family = "javascript";
}; };
}; };
in { in
{
options.aux.platform = { options.aux.platform = {
name = lib.options.create { name = lib.options.create {
type = lib.types.string; type = lib.types.string;
@ -303,7 +302,10 @@ in {
}; };
endian = lib.options.create { endian = lib.options.create {
type = lib.types.enum ["little" "big"]; type = lib.types.enum [
"little"
"big"
];
default.value = "big"; default.value = "big";
description = "Endianess of the platform"; description = "Endianess of the platform";
}; };
@ -332,18 +334,13 @@ in {
}; };
config = { config = {
aux.platform = aux.platform = (platforms.${platform} or (builtins.throw "Unsupported platform: ${system}")) // {
( name = platform;
platforms.${platform}
or (builtins.throw "Unsupported platform: ${system}")
)
// {
name = platform;
# These will only ever have `linux` as the target since we # These will only ever have `linux` as the target since we
# do not support darwin bootstrapping. # do not support darwin bootstrapping.
build = "${platform}-unknown-${target}-gnu"; build = "${platform}-unknown-${target}-gnu";
host = "${platform}-unknown-${target}-gnu"; host = "${platform}-unknown-${target}-gnu";
}; };
}; };
} }

View file

@ -1,18 +1,18 @@
{ { lib, config }:
lib, let
config,
}: let
system = config.aux.system; system = config.aux.system;
architecture = architecture =
if system == "x86_64-linux" if system == "x86_64-linux" then
then "AMD64" "AMD64"
else if system == "aarch64-linux" else if system == "aarch64-linux" then
then "AArch64" "AArch64"
else if system == "i686-linux" else if system == "i686-linux" then
then "x86" "x86"
else builtins.throw "Unsupported system for stage0: ${system}"; else
in { builtins.throw "Unsupported system for stage0: ${system}";
in
{
options.aux.foundation.stages.stage0.architecture = { options.aux.foundation.stages.stage0.architecture = {
base = lib.options.create { base = lib.options.create {
type = lib.types.string; type = lib.types.string;

View file

@ -1,21 +1,21 @@
{ { lib, config }:
lib, let
config,
}: let
cfg = config.aux.foundation.stages.stage0; cfg = config.aux.foundation.stages.stage0;
system = config.aux.system; system = config.aux.system;
builders = config.aux.foundation.builders; builders = config.aux.foundation.builders;
architecture = architecture =
if system == "x86_64-linux" if system == "x86_64-linux" then
then "AMD64" "AMD64"
else if system == "aarch64-linux" else if system == "aarch64-linux" then
then "AArch64" "AArch64"
else if system == "i686-linux" else if system == "i686-linux" then
then "x86" "x86"
else builtins.throw "Unsupported system for stage0: ${system}"; else
in { builtins.throw "Unsupported system for stage0: ${system}";
in
{
includes = [ includes = [
./sources ./sources
./architecture ./architecture

View file

@ -1,7 +1,5 @@
{ { lib, config }:
lib, let
config,
}: let
cfg = config.aux.foundation.stages.stage0.kaem; cfg = config.aux.foundation.stages.stage0.kaem;
system = config.aux.system; system = config.aux.system;
@ -10,7 +8,8 @@
kaem-unwrapped = config.aux.foundation.stages.stage0.kaem-unwrapped; kaem-unwrapped = config.aux.foundation.stages.stage0.kaem-unwrapped;
mescc-tools = config.aux.foundation.stages.stage0.mescc-tools; mescc-tools = config.aux.foundation.stages.stage0.mescc-tools;
mescc-tools-extra = config.aux.foundation.stages.stage0.mescc-tools-extra; mescc-tools-extra = config.aux.foundation.stages.stage0.mescc-tools-extra;
in { in
{
options.aux.foundation.stages.stage0.kaem = { options.aux.foundation.stages.stage0.kaem = {
meta = { meta = {
description = lib.options.create { description = lib.options.create {
@ -35,7 +34,7 @@ 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" ];
}; };
}; };
@ -47,24 +46,26 @@ in {
config = { config = {
aux.foundation.stages.stage0.kaem = { aux.foundation.stages.stage0.kaem = {
package = lib.modules.overrides.default (builders.raw.build { package = lib.modules.overrides.default (
pname = "kaem"; builders.raw.build {
version = "1.6.0"; pname = "kaem";
version = "1.6.0";
meta = cfg.meta; meta = cfg.meta;
executable = kaem-unwrapped.package; executable = kaem-unwrapped.package;
args = [ args = [
"--verbose" "--verbose"
"--strict" "--strict"
"--file" "--file"
./build.kaem ./build.kaem
]; ];
kaemUnwrapped = kaem-unwrapped.package; kaemUnwrapped = kaem-unwrapped.package;
PATH = lib.paths.bin [mescc-tools-extra.package]; PATH = lib.paths.bin [ mescc-tools-extra.package ];
}); }
);
}; };
}; };
} }

View file

@ -1,7 +1,5 @@
{ { lib, config }:
lib, let
config,
}: let
cfg = config.aux.foundation.stages.stage0.mescc-tools-extra; cfg = config.aux.foundation.stages.stage0.mescc-tools-extra;
hex0 = config.aux.foundation.stages.stage0.hex0; hex0 = config.aux.foundation.stages.stage0.hex0;
catm = config.aux.foundation.stages.stage0.catm; catm = config.aux.foundation.stages.stage0.catm;
@ -18,7 +16,8 @@
builders = config.aux.foundation.builders; builders = config.aux.foundation.builders;
sources = config.aux.foundation.stages.stage0.sources; sources = config.aux.foundation.stages.stage0.sources;
architecture = config.aux.foundation.stages.stage0.architecture; architecture = config.aux.foundation.stages.stage0.architecture;
in { in
{
options.aux.foundation.stages.stage0.mescc-tools-extra = { options.aux.foundation.stages.stage0.mescc-tools-extra = {
meta = { meta = {
description = lib.options.create { description = lib.options.create {
@ -43,7 +42,7 @@ 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" ];
}; };
}; };
@ -55,27 +54,29 @@ in {
config = { config = {
aux.foundation.stages.stage0.mescc-tools-extra = { aux.foundation.stages.stage0.mescc-tools-extra = {
package = lib.modules.overrides.default (builders.raw.build { package = lib.modules.overrides.default (
pname = "mescc-tools-tools"; builders.raw.build {
version = "1.6.0"; pname = "mescc-tools-tools";
version = "1.6.0";
meta = cfg.meta; meta = cfg.meta;
executable = kaem-unwrapped.package; executable = kaem-unwrapped.package;
args = [ args = [
"--verbose" "--verbose"
"--strict" "--strict"
"--file" "--file"
./build.kaem ./build.kaem
]; ];
src = sources.mescc-tools-extra; src = sources.mescc-tools-extra;
m2libcOS = "linux"; m2libcOS = "linux";
m2libcArch = architecture.m2libc; m2libcArch = architecture.m2libc;
mesccTools = mescc-tools.package; mesccTools = mescc-tools.package;
}); }
);
}; };
}; };
} }

View file

@ -1,7 +1,5 @@
{ { lib, config }:
lib, let
config,
}: let
cfg = config.aux.foundation.stages.stage0.mescc-tools; cfg = config.aux.foundation.stages.stage0.mescc-tools;
hex0 = config.aux.foundation.stages.stage0.hex0; hex0 = config.aux.foundation.stages.stage0.hex0;
catm = config.aux.foundation.stages.stage0.catm; catm = config.aux.foundation.stages.stage0.catm;
@ -18,60 +16,57 @@
sources = config.aux.foundation.stages.stage0.sources; sources = config.aux.foundation.stages.stage0.sources;
architecture = config.aux.foundation.stages.stage0.architecture; architecture = config.aux.foundation.stages.stage0.architecture;
bloodFlag = bloodFlag = if config.aux.platform.bits == 64 then "--64" else " ";
if config.aux.platform.bits == 64 endianFlag = if config.aux.platform.endian == "little" then "--little-endian" else "--big-endian";
then "--64"
else " ";
endianFlag =
if config.aux.platform.endian == "little"
then "--little-endian"
else "--big-endian";
baseAddress = baseAddress =
if config.aux.system == "x86_64-linux" if config.aux.system == "x86_64-linux" then
then "0x00600000" "0x00600000"
else if config.aux.system == "aarch64-linux" else if config.aux.system == "aarch64-linux" then
then "0x00600000" "0x00600000"
else if config.aux.system == "i686-linux" else if config.aux.system == "i686-linux" then
then "0x08048000" "0x08048000"
else builtins.throw "Unsupported system: ${config.aux.system}"; else
builtins.throw "Unsupported system: ${config.aux.system}";
getExtraUtil = name: let getExtraUtil =
script = builtins.toFile "build-${name}.kaem" '' name:
''${M2} --architecture ${architecture.m2libc} \ let
-f ''${m2libc}/sys/types.h \ script = builtins.toFile "build-${name}.kaem" ''
-f ''${m2libc}/stddef.h \ ''${M2} --architecture ${architecture.m2libc} \
-f ''${m2libc}/${architecture.m2libc}/linux/fcntl.c \ -f ''${m2libc}/sys/types.h \
-f ''${m2libc}/fcntl.c \ -f ''${m2libc}/stddef.h \
-f ''${m2libc}/${architecture.m2libc}/linux/unistd.c \ -f ''${m2libc}/${architecture.m2libc}/linux/fcntl.c \
-f ''${m2libc}/${architecture.m2libc}/linux/sys/stat.c \ -f ''${m2libc}/fcntl.c \
-f ''${m2libc}/stdlib.c \ -f ''${m2libc}/${architecture.m2libc}/linux/unistd.c \
-f ''${m2libc}/stdio.h \ -f ''${m2libc}/${architecture.m2libc}/linux/sys/stat.c \
-f ''${m2libc}/stdio.c \ -f ''${m2libc}/stdlib.c \
-f ''${m2libc}/string.c \ -f ''${m2libc}/stdio.h \
-f ''${m2libc}/bootstrappable.c \ -f ''${m2libc}/stdio.c \
-f ''${mesccToolsExtra}/${name}.c \ -f ''${m2libc}/string.c \
--debug \ -f ''${m2libc}/bootstrappable.c \
-o ${name}.M1 -f ''${mesccToolsExtra}/${name}.c \
--debug \
-o ${name}.M1
''${blood-elf-0} ${endianFlag} ${bloodFlag} -f ${name}.M1 -o ${name}-footer.M1 ''${blood-elf-0} ${endianFlag} ${bloodFlag} -f ${name}.M1 -o ${name}-footer.M1
''${M1} --architecture ${architecture.m2libc} \ ''${M1} --architecture ${architecture.m2libc} \
${endianFlag} \ ${endianFlag} \
-f ''${m2libc}/${architecture.m2libc}/${architecture.m2libc}_defs.M1 \ -f ''${m2libc}/${architecture.m2libc}/${architecture.m2libc}_defs.M1 \
-f ''${m2libc}/${architecture.m2libc}/libc-full.M1 \ -f ''${m2libc}/${architecture.m2libc}/libc-full.M1 \
-f ${name}.M1 \ -f ${name}.M1 \
-f ${name}-footer.M1 \ -f ${name}-footer.M1 \
-o ${name}.hex2 -o ${name}.hex2
''${hex2} --architecture ${architecture.m2libc} \ ''${hex2} --architecture ${architecture.m2libc} \
${endianFlag} \ ${endianFlag} \
-f ''${m2libc}/${architecture.m2libc}/ELF-${architecture.m2libc}-debug.hex2 \ -f ''${m2libc}/${architecture.m2libc}/ELF-${architecture.m2libc}-debug.hex2 \
-f ${name}.hex2 \ -f ${name}.hex2 \
--base-address ${baseAddress} \ --base-address ${baseAddress} \
-o ''${out} -o ''${out}
''; '';
in in
builders.raw.build { builders.raw.build {
pname = "mescc-tools-extra-${name}"; pname = "mescc-tools-extra-${name}";
version = "1.6.0"; version = "1.6.0";
@ -104,7 +99,8 @@
endianFlag = endianFlag; endianFlag = endianFlag;
baseAddress = baseAddress; baseAddress = baseAddress;
}; };
in { in
{
options.aux.foundation.stages.stage0.mescc-tools = { options.aux.foundation.stages.stage0.mescc-tools = {
meta = { meta = {
description = lib.options.create { description = lib.options.create {
@ -129,7 +125,7 @@ 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" ];
}; };
}; };
@ -141,42 +137,44 @@ in {
config = { config = {
aux.foundation.stages.stage0.mescc-tools = { aux.foundation.stages.stage0.mescc-tools = {
package = lib.modules.overrides.default (builders.raw.build { package = lib.modules.overrides.default (
pname = "mescc-tools"; builders.raw.build {
version = "1.6.0"; pname = "mescc-tools";
version = "1.6.0";
meta = cfg.meta; meta = cfg.meta;
executable = kaem-unwrapped.package; executable = kaem-unwrapped.package;
args = [ args = [
"--verbose" "--verbose"
"--strict" "--strict"
"--file" "--file"
./build.kaem ./build.kaem
]; ];
M1 = M1.package; M1 = M1.package;
M2 = M2.package; M2 = M2.package;
blood-elf-0 = blood-elf.package; blood-elf-0 = blood-elf.package;
hex2 = hex2.package; hex2 = hex2.package;
m2libc = sources.m2libc; m2libc = sources.m2libc;
m2libcArch = architecture.m2libc; m2libcArch = architecture.m2libc;
m2planet = sources.m2planet; m2planet = sources.m2planet;
m2mesoplanet = sources.m2mesoplanet; m2mesoplanet = sources.m2mesoplanet;
mesccTools = sources.mescc-tools; mesccTools = sources.mescc-tools;
mesccToolsExtra = sources.mescc-tools-extra; mesccToolsExtra = sources.mescc-tools-extra;
bloodFlag = bloodFlag; bloodFlag = bloodFlag;
endianFlag = endianFlag; endianFlag = endianFlag;
baseAddress = baseAddress; baseAddress = baseAddress;
mkdir = getExtraUtil "mkdir"; mkdir = getExtraUtil "mkdir";
cp = getExtraUtil "cp"; cp = getExtraUtil "cp";
chmod = getExtraUtil "chmod"; chmod = getExtraUtil "chmod";
replace = getExtraUtil "replace"; replace = getExtraUtil "replace";
}); }
);
}; };
}; };
} }

View file

@ -1,7 +1,5 @@
{ { lib, config }:
lib, let
config,
}: let
cfg = config.aux.foundation.stages.stage0.hex0; cfg = config.aux.foundation.stages.stage0.hex0;
system = config.aux.system; system = config.aux.system;
@ -9,14 +7,16 @@
sources = config.aux.foundation.stages.stage0.sources; sources = config.aux.foundation.stages.stage0.sources;
architecture = architecture =
if system == "x86_64-linux" if system == "x86_64-linux" then
then "AMD64" "AMD64"
else if system == "aarch64-linux" else if system == "aarch64-linux" then
then "AArch64" "AArch64"
else if system == "i686-linux" else if system == "i686-linux" then
then "x86" "x86"
else builtins.throw "Unsupported system for stage0: ${system}"; else
in { builtins.throw "Unsupported system for stage0: ${system}";
in
{
options.aux.foundation.stages.stage0.hex0 = { options.aux.foundation.stages.stage0.hex0 = {
meta = { meta = {
description = lib.options.create { description = lib.options.create {
@ -41,7 +41,7 @@ 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" ];
}; };
}; };
@ -66,40 +66,45 @@ in {
config = { config = {
aux.foundation.stages.stage0.hex0 = { aux.foundation.stages.stage0.hex0 = {
package = lib.modules.overrides.default (builders.raw.build { package = lib.modules.overrides.default (
pname = "hex0"; builders.raw.build {
version = "1.6.0"; pname = "hex0";
version = "1.6.0";
meta = cfg.meta; meta = cfg.meta;
executable = cfg.executable; executable = cfg.executable;
args = [ args = [
"${sources.base}/hex0_${architecture}.hex0" "${sources.base}/hex0_${architecture}.hex0"
(builtins.placeholder "out") (builtins.placeholder "out")
]; ];
outputHashMode = "recursive"; outputHashMode = "recursive";
outputHashAlgo = "sha256"; outputHashAlgo = "sha256";
outputHash = cfg.hash; outputHash = cfg.hash;
}); }
hash = lib.modules.overrides.default (
if system == "x86_64-linux"
then "sha256-RCgK9oZRDQUiWLVkcIBSR2HeoB+Bh0czthrpjFEkCaY="
else if system == "aarch64-linux"
then "sha256-XTPsoKeI6wTZAF0UwEJPzuHelWOJe//wXg4HYO0dEJo="
else if system == "i686-linux"
then "sha256-QU3RPGy51W7M2xnfFY1IqruKzusrSLU+L190ztN6JW8="
else null
); );
executable = lib.modules.overrides.default (import <nix/fetchurl.nix> { hash = lib.modules.overrides.default (
name = "hex0-seed"; if system == "x86_64-linux" then
url = "https://github.com/oriansj/bootstrap-seeds/raw/b1263ff14a17835f4d12539226208c426ced4fba/POSIX/${architecture}/hex0-seed"; "sha256-RCgK9oZRDQUiWLVkcIBSR2HeoB+Bh0czthrpjFEkCaY="
executable = true; else if system == "aarch64-linux" then
hash = cfg.hash; "sha256-XTPsoKeI6wTZAF0UwEJPzuHelWOJe//wXg4HYO0dEJo="
}); else if system == "i686-linux" then
"sha256-QU3RPGy51W7M2xnfFY1IqruKzusrSLU+L190ztN6JW8="
else
null
);
executable = lib.modules.overrides.default (
import <nix/fetchurl.nix> {
name = "hex0-seed";
url = "https://github.com/oriansj/bootstrap-seeds/raw/b1263ff14a17835f4d12539226208c426ced4fba/POSIX/${architecture}/hex0-seed";
executable = true;
hash = cfg.hash;
}
);
}; };
}; };
} }

View file

@ -1,7 +1,5 @@
{ { lib, config }:
lib, let
config,
}: let
cfg = config.aux.foundation.stages.stage0.hex1; cfg = config.aux.foundation.stages.stage0.hex1;
hex0 = config.aux.foundation.stages.stage0.hex0; hex0 = config.aux.foundation.stages.stage0.hex0;
@ -9,7 +7,8 @@
builders = config.aux.foundation.builders; builders = config.aux.foundation.builders;
sources = config.aux.foundation.stages.stage0.sources; sources = config.aux.foundation.stages.stage0.sources;
architecture = config.aux.foundation.stages.stage0.architecture; architecture = config.aux.foundation.stages.stage0.architecture;
in { in
{
options.aux.foundation.stages.stage0.hex1 = { options.aux.foundation.stages.stage0.hex1 = {
meta = { meta = {
description = lib.options.create { description = lib.options.create {
@ -34,7 +33,7 @@ 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" ];
}; };
}; };
@ -46,19 +45,21 @@ in {
config = { config = {
aux.foundation.stages.stage0.hex1 = { aux.foundation.stages.stage0.hex1 = {
package = lib.modules.overrides.default (builders.raw.build { package = lib.modules.overrides.default (
pname = "hex1"; builders.raw.build {
version = "1.6.0"; pname = "hex1";
version = "1.6.0";
meta = cfg.meta; meta = cfg.meta;
executable = hex0.package; executable = hex0.package;
args = [ args = [
"${sources.base}/hex1_${architecture.base}.hex0" "${sources.base}/hex1_${architecture.base}.hex0"
(builtins.placeholder "out") (builtins.placeholder "out")
]; ];
}); }
);
}; };
}; };
} }

View file

@ -1,7 +1,5 @@
{ { lib, config }:
lib, let
config,
}: let
cfg = config.aux.foundation.stages.stage0.hex2-0; cfg = config.aux.foundation.stages.stage0.hex2-0;
hex0 = config.aux.foundation.stages.stage0.hex0; hex0 = config.aux.foundation.stages.stage0.hex0;
hex1 = config.aux.foundation.stages.stage0.hex1; hex1 = config.aux.foundation.stages.stage0.hex1;
@ -10,7 +8,8 @@
builders = config.aux.foundation.builders; builders = config.aux.foundation.builders;
sources = config.aux.foundation.stages.stage0.sources; sources = config.aux.foundation.stages.stage0.sources;
architecture = config.aux.foundation.stages.stage0.architecture; architecture = config.aux.foundation.stages.stage0.architecture;
in { in
{
options.aux.foundation.stages.stage0.hex2-0 = { options.aux.foundation.stages.stage0.hex2-0 = {
meta = { meta = {
description = lib.options.create { description = lib.options.create {
@ -35,7 +34,7 @@ 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" ];
}; };
}; };
@ -47,19 +46,21 @@ in {
config = { config = {
aux.foundation.stages.stage0.hex2-0 = { aux.foundation.stages.stage0.hex2-0 = {
package = lib.modules.overrides.default (builders.raw.build { package = lib.modules.overrides.default (
pname = "hex2-0"; builders.raw.build {
version = "1.6.0"; pname = "hex2-0";
version = "1.6.0";
meta = cfg.meta; meta = cfg.meta;
executable = hex1.package; executable = hex1.package;
args = [ args = [
"${sources.base}/hex2_${architecture.base}.hex1" "${sources.base}/hex2_${architecture.base}.hex1"
(builtins.placeholder "out") (builtins.placeholder "out")
]; ];
}); }
);
}; };
}; };
} }

View file

@ -1,7 +1,5 @@
{ { lib, config }:
lib, let
config,
}: let
cfg = config.aux.foundation.stages.stage0.catm; cfg = config.aux.foundation.stages.stage0.catm;
hex0 = config.aux.foundation.stages.stage0.hex0; hex0 = config.aux.foundation.stages.stage0.hex0;
hex1 = config.aux.foundation.stages.stage0.hex1; hex1 = config.aux.foundation.stages.stage0.hex1;
@ -11,7 +9,8 @@
builders = config.aux.foundation.builders; builders = config.aux.foundation.builders;
sources = config.aux.foundation.stages.stage0.sources; sources = config.aux.foundation.stages.stage0.sources;
architecture = config.aux.foundation.stages.stage0.architecture; architecture = config.aux.foundation.stages.stage0.architecture;
in { in
{
options.aux.foundation.stages.stage0.catm = { options.aux.foundation.stages.stage0.catm = {
meta = { meta = {
description = lib.options.create { description = lib.options.create {
@ -36,7 +35,7 @@ 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" ];
}; };
}; };
@ -48,28 +47,28 @@ in {
config = { config = {
aux.foundation.stages.stage0.catm = { aux.foundation.stages.stage0.catm = {
package = lib.modules.overrides.default (builders.raw.build { package = lib.modules.overrides.default (
pname = "catm"; builders.raw.build {
version = "1.6.0"; pname = "catm";
version = "1.6.0";
meta = cfg.meta; meta = cfg.meta;
executable = executable = if architecture.base == "AArch64" then hex1.package else hex2-0.package;
if architecture.base == "AArch64"
then hex1.package
else hex2-0.package;
args = args =
if architecture.base == "AArch64" if architecture.base == "AArch64" then
then [ [
"${sources.base}/catm_${architecture.base}.hex1" "${sources.base}/catm_${architecture.base}.hex1"
(builtins.placeholder "out") (builtins.placeholder "out")
] ]
else [ else
"${sources.base}/catm_${architecture.base}.hex2" [
(builtins.placeholder "out") "${sources.base}/catm_${architecture.base}.hex2"
]; (builtins.placeholder "out")
}); ];
}
);
}; };
}; };
} }

View file

@ -1,7 +1,5 @@
{ { lib, config }:
lib, let
config,
}: let
cfg = config.aux.foundation.stages.stage0.M0; cfg = config.aux.foundation.stages.stage0.M0;
hex0 = config.aux.foundation.stages.stage0.hex0; hex0 = config.aux.foundation.stages.stage0.hex0;
hex2-0 = config.aux.foundation.stages.stage0.hex2-0; hex2-0 = config.aux.foundation.stages.stage0.hex2-0;
@ -11,7 +9,8 @@
builders = config.aux.foundation.builders; builders = config.aux.foundation.builders;
sources = config.aux.foundation.stages.stage0.sources; sources = config.aux.foundation.stages.stage0.sources;
architecture = config.aux.foundation.stages.stage0.architecture; architecture = config.aux.foundation.stages.stage0.architecture;
in { in
{
options.aux.foundation.stages.stage0.M0 = { options.aux.foundation.stages.stage0.M0 = {
meta = { meta = {
description = lib.options.create { description = lib.options.create {
@ -36,7 +35,7 @@ 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" ];
}; };
}; };
@ -48,34 +47,38 @@ in {
config = { config = {
aux.foundation.stages.stage0.M0 = { aux.foundation.stages.stage0.M0 = {
package = lib.modules.overrides.default (builders.raw.build { package = lib.modules.overrides.default (
pname = "M0"; builders.raw.build {
version = "1.6.0"; pname = "M0";
version = "1.6.0";
meta = cfg.meta; meta = cfg.meta;
executable = hex2-0.package; executable = hex2-0.package;
args = let args =
M0_hex2-0 = builders.raw.build { let
pname = "M0_hex2-0"; M0_hex2-0 = builders.raw.build {
version = "1.6.0"; pname = "M0_hex2-0";
version = "1.6.0";
meta = cfg.meta; meta = cfg.meta;
executable = catm.package; executable = catm.package;
args = [ args = [
(builtins.placeholder "out")
"${sources.m2libc}/${architecture.m2libc}/ELF-${architecture.m2libc}.hex2"
"${sources.base}/M0_${architecture.base}.hex2"
];
};
in
[
M0_hex2-0
(builtins.placeholder "out") (builtins.placeholder "out")
"${sources.m2libc}/${architecture.m2libc}/ELF-${architecture.m2libc}.hex2"
"${sources.base}/M0_${architecture.base}.hex2"
]; ];
}; }
in [ );
M0_hex2-0
(builtins.placeholder "out")
];
});
}; };
}; };
} }

View file

@ -1,7 +1,5 @@
{ { lib, config }:
lib, let
config,
}: let
cfg = config.aux.foundation.stages.stage0.cc_arch; cfg = config.aux.foundation.stages.stage0.cc_arch;
hex0 = config.aux.foundation.stages.stage0.hex0; hex0 = config.aux.foundation.stages.stage0.hex0;
hex2-0 = config.aux.foundation.stages.stage0.hex2-0; hex2-0 = config.aux.foundation.stages.stage0.hex2-0;
@ -12,7 +10,8 @@
builders = config.aux.foundation.builders; builders = config.aux.foundation.builders;
sources = config.aux.foundation.stages.stage0.sources; sources = config.aux.foundation.stages.stage0.sources;
architecture = config.aux.foundation.stages.stage0.architecture; architecture = config.aux.foundation.stages.stage0.architecture;
in { in
{
options.aux.foundation.stages.stage0.cc_arch = { options.aux.foundation.stages.stage0.cc_arch = {
meta = { meta = {
description = lib.options.create { description = lib.options.create {
@ -37,7 +36,7 @@ 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" ];
}; };
}; };
@ -49,47 +48,51 @@ in {
config = { config = {
aux.foundation.stages.stage0.cc_arch = { aux.foundation.stages.stage0.cc_arch = {
package = lib.modules.overrides.default (builders.raw.build { package = lib.modules.overrides.default (
pname = "cc_arch"; builders.raw.build {
version = "1.6.0"; pname = "cc_arch";
version = "1.6.0";
meta = cfg.meta; meta = cfg.meta;
executable = hex2-0.package; executable = hex2-0.package;
args = let args =
cc_arch0_hex2-0 = builders.raw.build { let
pname = "cc_arch0_hex2-0"; cc_arch0_hex2-0 = builders.raw.build {
version = "1.6.0"; pname = "cc_arch0_hex2-0";
version = "1.6.0";
meta = cfg.meta; meta = cfg.meta;
executable = M0.package; executable = M0.package;
args = [ args = [
"${sources.base}/cc_${architecture.m2libc}.M1" "${sources.base}/cc_${architecture.m2libc}.M1"
(builtins.placeholder "out")
];
};
cc_arch1_hex2-0 = builders.raw.build {
pname = "cc_arch1_hex2-0";
version = "1.6.0";
meta = cfg.meta;
executable = catm.package;
args = [
(builtins.placeholder "out")
"${sources.m2libc}/${architecture.m2libc}/ELF-${architecture.m2libc}.hex2"
cc_arch0_hex2-0
];
};
in
[
cc_arch1_hex2-0
(builtins.placeholder "out") (builtins.placeholder "out")
]; ];
}; }
cc_arch1_hex2-0 = builders.raw.build { );
pname = "cc_arch1_hex2-0";
version = "1.6.0";
meta = cfg.meta;
executable = catm.package;
args = [
(builtins.placeholder "out")
"${sources.m2libc}/${architecture.m2libc}/ELF-${architecture.m2libc}.hex2"
cc_arch0_hex2-0
];
};
in [
cc_arch1_hex2-0
(builtins.placeholder "out")
];
});
}; };
}; };
} }

View file

@ -1,7 +1,5 @@
{ { lib, config }:
lib, let
config,
}: let
cfg = config.aux.foundation.stages.stage0.M2; cfg = config.aux.foundation.stages.stage0.M2;
hex0 = config.aux.foundation.stages.stage0.hex0; hex0 = config.aux.foundation.stages.stage0.hex0;
hex2-0 = config.aux.foundation.stages.stage0.hex2-0; hex2-0 = config.aux.foundation.stages.stage0.hex2-0;
@ -13,7 +11,8 @@
builders = config.aux.foundation.builders; builders = config.aux.foundation.builders;
sources = config.aux.foundation.stages.stage0.sources; sources = config.aux.foundation.stages.stage0.sources;
architecture = config.aux.foundation.stages.stage0.architecture; architecture = config.aux.foundation.stages.stage0.architecture;
in { in
{
options.aux.foundation.stages.stage0.M2 = { options.aux.foundation.stages.stage0.M2 = {
meta = { meta = {
description = lib.options.create { description = lib.options.create {
@ -38,7 +37,7 @@ 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" ];
}; };
}; };
@ -50,97 +49,101 @@ in {
config = { config = {
aux.foundation.stages.stage0.M2 = { aux.foundation.stages.stage0.M2 = {
package = lib.modules.overrides.default (builders.raw.build { package = lib.modules.overrides.default (
pname = "M2"; builders.raw.build {
version = "1.6.0"; pname = "M2";
version = "1.6.0";
meta = cfg.meta; meta = cfg.meta;
executable = hex2-0.package; executable = hex2-0.package;
args = let args =
M2_c = builders.raw.build { let
pname = "M2_c"; M2_c = builders.raw.build {
version = "1.6.0"; pname = "M2_c";
version = "1.6.0";
meta = cfg.meta; meta = cfg.meta;
executable = catm.package; executable = catm.package;
args = [ args = [
(builtins.placeholder "out") (builtins.placeholder "out")
"${sources.m2libc}/${architecture.m2libc}/linux/bootstrap.c" "${sources.m2libc}/${architecture.m2libc}/linux/bootstrap.c"
"${sources.m2planet}/cc.h" "${sources.m2planet}/cc.h"
"${sources.m2libc}/bootstrappable.c" "${sources.m2libc}/bootstrappable.c"
"${sources.m2planet}/cc_globals.c" "${sources.m2planet}/cc_globals.c"
"${sources.m2planet}/cc_reader.c" "${sources.m2planet}/cc_reader.c"
"${sources.m2planet}/cc_strings.c" "${sources.m2planet}/cc_strings.c"
"${sources.m2planet}/cc_types.c" "${sources.m2planet}/cc_types.c"
"${sources.m2planet}/cc_core.c" "${sources.m2planet}/cc_core.c"
"${sources.m2planet}/cc_macro.c" "${sources.m2planet}/cc_macro.c"
"${sources.m2planet}/cc.c" "${sources.m2planet}/cc.c"
]; ];
}; };
M2_M1 = builders.raw.build { M2_M1 = builders.raw.build {
pname = "M2_M1"; pname = "M2_M1";
version = "1.6.0"; version = "1.6.0";
meta = cfg.meta; meta = cfg.meta;
executable = cc_arch.package; executable = cc_arch.package;
args = [ args = [
M2_c M2_c
(builtins.placeholder "out")
];
};
M2_M1' = builders.raw.build {
pname = "M2_M1";
version = "1.6.0";
meta = cfg.meta;
executable = catm.package;
args = [
(builtins.placeholder "out")
"${sources.m2libc}/${architecture.m2libc}/${architecture.m2libc}_defs.M1"
"${sources.m2libc}/${architecture.m2libc}/libc-core.M1"
M2_M1
];
};
M2_hex2-0 = builders.raw.build {
pname = "M2_hex2-0";
version = "1.6.0";
meta = cfg.meta;
executable = M0.package;
args = [
M2_M1'
(builtins.placeholder "out")
];
};
M2_hex2-0' = builders.raw.build {
pname = "M2_hex2-0";
version = "1.6.0";
meta = cfg.meta;
executable = catm.package;
args = [
(builtins.placeholder "out")
"${sources.m2libc}/${architecture.m2libc}/ELF-${architecture.m2libc}.hex2"
M2_hex2-0
];
};
in
[
M2_hex2-0'
(builtins.placeholder "out") (builtins.placeholder "out")
]; ];
}; }
M2_M1' = builders.raw.build { );
pname = "M2_M1";
version = "1.6.0";
meta = cfg.meta;
executable = catm.package;
args = [
(builtins.placeholder "out")
"${sources.m2libc}/${architecture.m2libc}/${architecture.m2libc}_defs.M1"
"${sources.m2libc}/${architecture.m2libc}/libc-core.M1"
M2_M1
];
};
M2_hex2-0 = builders.raw.build {
pname = "M2_hex2-0";
version = "1.6.0";
meta = cfg.meta;
executable = M0.package;
args = [
M2_M1'
(builtins.placeholder "out")
];
};
M2_hex2-0' = builders.raw.build {
pname = "M2_hex2-0";
version = "1.6.0";
meta = cfg.meta;
executable = catm.package;
args = [
(builtins.placeholder "out")
"${sources.m2libc}/${architecture.m2libc}/ELF-${architecture.m2libc}.hex2"
M2_hex2-0
];
};
in [
M2_hex2-0'
(builtins.placeholder "out")
];
});
}; };
}; };
} }

View file

@ -1,7 +1,5 @@
{ { lib, config }:
lib, let
config,
}: let
cfg = config.aux.foundation.stages.stage0.blood-elf; cfg = config.aux.foundation.stages.stage0.blood-elf;
hex0 = config.aux.foundation.stages.stage0.hex0; hex0 = config.aux.foundation.stages.stage0.hex0;
hex2-0 = config.aux.foundation.stages.stage0.hex2-0; hex2-0 = config.aux.foundation.stages.stage0.hex2-0;
@ -14,7 +12,8 @@
builders = config.aux.foundation.builders; builders = config.aux.foundation.builders;
sources = config.aux.foundation.stages.stage0.sources; sources = config.aux.foundation.stages.stage0.sources;
architecture = config.aux.foundation.stages.stage0.architecture; architecture = config.aux.foundation.stages.stage0.architecture;
in { in
{
options.aux.foundation.stages.stage0.blood-elf = { options.aux.foundation.stages.stage0.blood-elf = {
meta = { meta = {
description = lib.options.create { description = lib.options.create {
@ -39,7 +38,7 @@ 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" ];
}; };
}; };
@ -51,86 +50,90 @@ in {
config = { config = {
aux.foundation.stages.stage0.blood-elf = { aux.foundation.stages.stage0.blood-elf = {
package = lib.modules.overrides.default (builders.raw.build { package = lib.modules.overrides.default (
pname = "blood-elf"; builders.raw.build {
version = "1.6.0"; pname = "blood-elf";
version = "1.6.0";
meta = cfg.meta; meta = cfg.meta;
executable = hex2-0.package; executable = hex2-0.package;
args = let args =
blood-elf_M1 = builders.raw.build { let
pname = "blood-elf_M1"; blood-elf_M1 = builders.raw.build {
version = "1.6.0"; pname = "blood-elf_M1";
version = "1.6.0";
meta = cfg.meta; meta = cfg.meta;
executable = M2.package; executable = M2.package;
args = [ args = [
"--architecture" "--architecture"
architecture.m2libc architecture.m2libc
"-f" "-f"
"${sources.m2libc}/${architecture.m2libc}/linux/bootstrap.c" "${sources.m2libc}/${architecture.m2libc}/linux/bootstrap.c"
"-f" "-f"
"${sources.m2libc}/bootstrappable.c" "${sources.m2libc}/bootstrappable.c"
"-f" "-f"
"${sources.mescc-tools}/stringify.c" "${sources.mescc-tools}/stringify.c"
"-f" "-f"
"${sources.mescc-tools}/blood-elf.c" "${sources.mescc-tools}/blood-elf.c"
"--bootstrap-mode" "--bootstrap-mode"
"-o" "-o"
(builtins.placeholder "out")
];
};
blood-elf_M1' = builders.raw.build {
pname = "blood-elf_M1-1";
version = "1.6.0";
meta = cfg.meta;
executable = catm.package;
args = [
(builtins.placeholder "out")
"${sources.m2libc}/${architecture.m2libc}/${architecture.m2libc}_defs.M1"
"${sources.m2libc}/${architecture.m2libc}/libc-core.M1"
blood-elf_M1
];
};
blood-elf_hex2-0 = builders.raw.build {
pname = "blood-elf_hex2-0";
version = "1.6.0";
meta = cfg.meta;
executable = M0.package;
args = [
blood-elf_M1'
(builtins.placeholder "out")
];
};
blood-elf_hex2-0' = builders.raw.build {
pname = "blood-elf_hex2-0-1";
version = "1.6.0";
meta = cfg.meta;
executable = catm.package;
args = [
(builtins.placeholder "out")
"${sources.m2libc}/${architecture.m2libc}/ELF-${architecture.m2libc}.hex2"
blood-elf_hex2-0
];
};
in
[
blood-elf_hex2-0'
(builtins.placeholder "out") (builtins.placeholder "out")
]; ];
}; }
blood-elf_M1' = builders.raw.build { );
pname = "blood-elf_M1-1";
version = "1.6.0";
meta = cfg.meta;
executable = catm.package;
args = [
(builtins.placeholder "out")
"${sources.m2libc}/${architecture.m2libc}/${architecture.m2libc}_defs.M1"
"${sources.m2libc}/${architecture.m2libc}/libc-core.M1"
blood-elf_M1
];
};
blood-elf_hex2-0 = builders.raw.build {
pname = "blood-elf_hex2-0";
version = "1.6.0";
meta = cfg.meta;
executable = M0.package;
args = [
blood-elf_M1'
(builtins.placeholder "out")
];
};
blood-elf_hex2-0' = builders.raw.build {
pname = "blood-elf_hex2-0-1";
version = "1.6.0";
meta = cfg.meta;
executable = catm.package;
args = [
(builtins.placeholder "out")
"${sources.m2libc}/${architecture.m2libc}/ELF-${architecture.m2libc}.hex2"
blood-elf_hex2-0
];
};
in [
blood-elf_hex2-0'
(builtins.placeholder "out")
];
});
}; };
}; };
} }

View file

@ -1,7 +1,5 @@
{ { lib, config }:
lib, let
config,
}: let
cfg = config.aux.foundation.stages.stage0.M1-0; cfg = config.aux.foundation.stages.stage0.M1-0;
hex0 = config.aux.foundation.stages.stage0.hex0; hex0 = config.aux.foundation.stages.stage0.hex0;
hex2-0 = config.aux.foundation.stages.stage0.hex2-0; hex2-0 = config.aux.foundation.stages.stage0.hex2-0;
@ -15,7 +13,8 @@
builders = config.aux.foundation.builders; builders = config.aux.foundation.builders;
sources = config.aux.foundation.stages.stage0.sources; sources = config.aux.foundation.stages.stage0.sources;
architecture = config.aux.foundation.stages.stage0.architecture; architecture = config.aux.foundation.stages.stage0.architecture;
in { in
{
options.aux.foundation.stages.stage0.M1-0 = { options.aux.foundation.stages.stage0.M1-0 = {
meta = { meta = {
description = lib.options.create { description = lib.options.create {
@ -40,7 +39,7 @@ 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" ];
}; };
}; };
@ -52,110 +51,108 @@ in {
config = { config = {
aux.foundation.stages.stage0.M1-0 = { aux.foundation.stages.stage0.M1-0 = {
package = lib.modules.overrides.default (builders.raw.build { package = lib.modules.overrides.default (
pname = "M1-0"; builders.raw.build {
version = "1.6.0"; pname = "M1-0";
version = "1.6.0";
meta = cfg.meta; meta = cfg.meta;
executable = hex2-0.package; executable = hex2-0.package;
args = let args =
M1-macro-0_M1 = builders.raw.build { let
pname = "M1-macro-0_M1"; M1-macro-0_M1 = builders.raw.build {
version = "1.6.0"; pname = "M1-macro-0_M1";
version = "1.6.0";
meta = cfg.meta; meta = cfg.meta;
executable = M2.package; executable = M2.package;
args = [ args = [
"--architecture" "--architecture"
architecture.m2libc architecture.m2libc
"-f" "-f"
"${sources.m2libc}/${architecture.m2libc}/linux/bootstrap.c" "${sources.m2libc}/${architecture.m2libc}/linux/bootstrap.c"
"-f" "-f"
"${sources.m2libc}/bootstrappable.c" "${sources.m2libc}/bootstrappable.c"
"-f" "-f"
"${sources.mescc-tools}/stringify.c" "${sources.mescc-tools}/stringify.c"
"-f" "-f"
"${sources.mescc-tools}/M1-macro.c" "${sources.mescc-tools}/M1-macro.c"
"--bootstrap-mode" "--bootstrap-mode"
"--debug" "--debug"
"-o" "-o"
(builtins.placeholder "out")
];
};
M1-macro-0-footer_M1 = builders.raw.build {
pname = "M1-macro-0-footer_M1";
version = "1.6.0";
meta = cfg.meta;
executable = blood-elf.package;
args = (lib.lists.when (config.aux.platform.bits == 64) "--64") ++ [
"-f"
M1-macro-0_M1
(if config.aux.platform.endian == "little" then "--little-endian" else "--big-endian")
"-o"
(builtins.placeholder "out")
];
};
M1-macro-0_M1' = builders.raw.build {
pname = "M1-macro-0_M1-1";
version = "1.6.0";
meta = cfg.meta;
executable = catm.package;
args = [
(builtins.placeholder "out")
"${sources.m2libc}/${architecture.m2libc}/${architecture.m2libc}_defs.M1"
"${sources.m2libc}/${architecture.m2libc}/libc-core.M1"
M1-macro-0_M1
M1-macro-0-footer_M1
];
};
M1-macro-0_hex2-0 = builders.raw.build {
pname = "M1-macro-0_hex2-0";
version = "1.6.0";
meta = cfg.meta;
executable = M0.package;
args = [
M1-macro-0_M1'
(builtins.placeholder "out")
];
};
M1-macro-0_hex2-0' = builders.raw.build {
pname = "M1-macro-0_hex2-0-1";
version = "1.6.0";
meta = cfg.meta;
executable = catm.package;
args = [
(builtins.placeholder "out")
"${sources.m2libc}/${architecture.m2libc}/ELF-${architecture.m2libc}-debug.hex2"
M1-macro-0_hex2-0
];
};
in
[
M1-macro-0_hex2-0'
(builtins.placeholder "out") (builtins.placeholder "out")
]; ];
}; }
M1-macro-0-footer_M1 = builders.raw.build { );
pname = "M1-macro-0-footer_M1";
version = "1.6.0";
meta = cfg.meta;
executable = blood-elf.package;
args =
(lib.lists.when (config.aux.platform.bits == 64) "--64")
++ [
"-f"
M1-macro-0_M1
(
if config.aux.platform.endian == "little"
then "--little-endian"
else "--big-endian"
)
"-o"
(builtins.placeholder "out")
];
};
M1-macro-0_M1' = builders.raw.build {
pname = "M1-macro-0_M1-1";
version = "1.6.0";
meta = cfg.meta;
executable = catm.package;
args = [
(builtins.placeholder "out")
"${sources.m2libc}/${architecture.m2libc}/${architecture.m2libc}_defs.M1"
"${sources.m2libc}/${architecture.m2libc}/libc-core.M1"
M1-macro-0_M1
M1-macro-0-footer_M1
];
};
M1-macro-0_hex2-0 = builders.raw.build {
pname = "M1-macro-0_hex2-0";
version = "1.6.0";
meta = cfg.meta;
executable = M0.package;
args = [
M1-macro-0_M1'
(builtins.placeholder "out")
];
};
M1-macro-0_hex2-0' = builders.raw.build {
pname = "M1-macro-0_hex2-0-1";
version = "1.6.0";
meta = cfg.meta;
executable = catm.package;
args = [
(builtins.placeholder "out")
"${sources.m2libc}/${architecture.m2libc}/ELF-${architecture.m2libc}-debug.hex2"
M1-macro-0_hex2-0
];
};
in [
M1-macro-0_hex2-0'
(builtins.placeholder "out")
];
});
}; };
}; };
} }

View file

@ -1,7 +1,5 @@
{ { lib, config }:
lib, let
config,
}: let
cfg = config.aux.foundation.stages.stage0.hex2-1; cfg = config.aux.foundation.stages.stage0.hex2-1;
hex0 = config.aux.foundation.stages.stage0.hex0; hex0 = config.aux.foundation.stages.stage0.hex0;
hex2-0 = config.aux.foundation.stages.stage0.hex2-0; hex2-0 = config.aux.foundation.stages.stage0.hex2-0;
@ -16,7 +14,8 @@
builders = config.aux.foundation.builders; builders = config.aux.foundation.builders;
sources = config.aux.foundation.stages.stage0.sources; sources = config.aux.foundation.stages.stage0.sources;
architecture = config.aux.foundation.stages.stage0.architecture; architecture = config.aux.foundation.stages.stage0.architecture;
in { in
{
options.aux.foundation.stages.stage0.hex2-1 = { options.aux.foundation.stages.stage0.hex2-1 = {
meta = { meta = {
description = lib.options.create { description = lib.options.create {
@ -41,7 +40,7 @@ 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" ];
}; };
}; };
@ -53,128 +52,122 @@ in {
config = { config = {
aux.foundation.stages.stage0.hex2-1 = { aux.foundation.stages.stage0.hex2-1 = {
package = lib.modules.overrides.default (builders.raw.build { package = lib.modules.overrides.default (
pname = "hex2-1"; builders.raw.build {
version = "1.6.0"; pname = "hex2-1";
version = "1.6.0";
meta = cfg.meta; meta = cfg.meta;
executable = hex2-0.package; executable = hex2-0.package;
args = let args =
hex2_linker_M1 = builders.raw.build { let
pname = "hex2_linker_M1"; hex2_linker_M1 = builders.raw.build {
version = "1.6.0"; pname = "hex2_linker_M1";
version = "1.6.0";
meta = cfg.meta; meta = cfg.meta;
executable = M2.package; executable = M2.package;
args = [ args = [
"--architecture" "--architecture"
architecture.m2libc architecture.m2libc
"-f" "-f"
"${sources.m2libc}/sys/types.h" "${sources.m2libc}/sys/types.h"
"-f" "-f"
"${sources.m2libc}/stddef.h" "${sources.m2libc}/stddef.h"
"-f" "-f"
"${sources.m2libc}/${architecture.m2libc}/linux/unistd.c" "${sources.m2libc}/${architecture.m2libc}/linux/unistd.c"
"-f" "-f"
"${sources.m2libc}/${architecture.m2libc}/linux/fcntl.c" "${sources.m2libc}/${architecture.m2libc}/linux/fcntl.c"
"-f" "-f"
"${sources.m2libc}/fcntl.c" "${sources.m2libc}/fcntl.c"
"-f" "-f"
"${sources.m2libc}/${architecture.m2libc}/linux/sys/stat.c" "${sources.m2libc}/${architecture.m2libc}/linux/sys/stat.c"
"-f" "-f"
"${sources.m2libc}/stdlib.c" "${sources.m2libc}/stdlib.c"
"-f" "-f"
"${sources.m2libc}/stdio.h" "${sources.m2libc}/stdio.h"
"-f" "-f"
"${sources.m2libc}/stdio.c" "${sources.m2libc}/stdio.c"
"-f" "-f"
"${sources.m2libc}/bootstrappable.c" "${sources.m2libc}/bootstrappable.c"
"-f" "-f"
"${sources.mescc-tools}/hex2.h" "${sources.mescc-tools}/hex2.h"
"-f" "-f"
"${sources.mescc-tools}/hex2_linker.c" "${sources.mescc-tools}/hex2_linker.c"
"-f" "-f"
"${sources.mescc-tools}/hex2_word.c" "${sources.mescc-tools}/hex2_word.c"
"-f" "-f"
"${sources.mescc-tools}/hex2.c" "${sources.mescc-tools}/hex2.c"
"--debug" "--debug"
"-o" "-o"
(builtins.placeholder "out")
];
};
hex2_linker-footer_M1 = builders.raw.build {
pname = "hex2_linker-footer_M1";
version = "1.6.0";
meta = cfg.meta;
executable = blood-elf.package;
args = (lib.lists.when (config.aux.platform.bits == 64) "--64") ++ [
"-f"
hex2_linker_M1
(if config.aux.platform.endian == "little" then "--little-endian" else "--big-endian")
"-o"
(builtins.placeholder "out")
];
};
hex2_linker_hex2 = builders.raw.build {
pname = "hex2_linker_hex2";
version = "1.6.0";
meta = cfg.meta;
executable = M1-0.package;
args = [
"--architecture"
architecture.m2libc
(if config.aux.platform.endian == "little" then "--little-endian" else "--big-endian")
"-f"
"${sources.m2libc}/${architecture.m2libc}/${architecture.m2libc}_defs.M1"
"-f"
"${sources.m2libc}/${architecture.m2libc}/libc-full.M1"
"-f"
hex2_linker_M1
"-f"
hex2_linker-footer_M1
"-o"
(builtins.placeholder "out")
];
};
hex2_linker_hex2' = builders.raw.build {
pname = "hex2_linker_hex2-1";
version = "1.6.0";
meta = cfg.meta;
executable = catm.package;
args = [
(builtins.placeholder "out")
"${sources.m2libc}/${architecture.m2libc}/ELF-${architecture.m2libc}-debug.hex2"
hex2_linker_hex2
];
};
in
[
hex2_linker_hex2'
(builtins.placeholder "out") (builtins.placeholder "out")
]; ];
}; }
hex2_linker-footer_M1 = builders.raw.build { );
pname = "hex2_linker-footer_M1";
version = "1.6.0";
meta = cfg.meta;
executable = blood-elf.package;
args =
(lib.lists.when (config.aux.platform.bits == 64) "--64")
++ [
"-f"
hex2_linker_M1
(
if config.aux.platform.endian == "little"
then "--little-endian"
else "--big-endian"
)
"-o"
(builtins.placeholder "out")
];
};
hex2_linker_hex2 = builders.raw.build {
pname = "hex2_linker_hex2";
version = "1.6.0";
meta = cfg.meta;
executable = M1-0.package;
args = [
"--architecture"
architecture.m2libc
(
if config.aux.platform.endian == "little"
then "--little-endian"
else "--big-endian"
)
"-f"
"${sources.m2libc}/${architecture.m2libc}/${architecture.m2libc}_defs.M1"
"-f"
"${sources.m2libc}/${architecture.m2libc}/libc-full.M1"
"-f"
hex2_linker_M1
"-f"
hex2_linker-footer_M1
"-o"
(builtins.placeholder "out")
];
};
hex2_linker_hex2' = builders.raw.build {
pname = "hex2_linker_hex2-1";
version = "1.6.0";
meta = cfg.meta;
executable = catm.package;
args = [
(builtins.placeholder "out")
"${sources.m2libc}/${architecture.m2libc}/ELF-${architecture.m2libc}-debug.hex2"
hex2_linker_hex2
];
};
in [
hex2_linker_hex2'
(builtins.placeholder "out")
];
});
}; };
}; };
} }

View file

@ -1,7 +1,5 @@
{ { lib, config }:
lib, let
config,
}: let
cfg = config.aux.foundation.stages.stage0.M1; cfg = config.aux.foundation.stages.stage0.M1;
hex0 = config.aux.foundation.stages.stage0.hex0; hex0 = config.aux.foundation.stages.stage0.hex0;
hex2-0 = config.aux.foundation.stages.stage0.hex2-0; hex2-0 = config.aux.foundation.stages.stage0.hex2-0;
@ -17,7 +15,8 @@
builders = config.aux.foundation.builders; builders = config.aux.foundation.builders;
sources = config.aux.foundation.stages.stage0.sources; sources = config.aux.foundation.stages.stage0.sources;
architecture = config.aux.foundation.stages.stage0.architecture; architecture = config.aux.foundation.stages.stage0.architecture;
in { in
{
options.aux.foundation.stages.stage0.M1 = { options.aux.foundation.stages.stage0.M1 = {
meta = { meta = {
description = lib.options.create { description = lib.options.create {
@ -42,7 +41,7 @@ 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" ];
}; };
}; };
@ -54,133 +53,124 @@ in {
config = { config = {
aux.foundation.stages.stage0.M1 = { aux.foundation.stages.stage0.M1 = {
package = lib.modules.overrides.default (builders.raw.build { package = lib.modules.overrides.default (
pname = "M1"; builders.raw.build {
version = "1.6.0"; pname = "M1";
version = "1.6.0";
meta = cfg.meta; meta = cfg.meta;
executable = hex2-1.package; executable = hex2-1.package;
args = let args =
M1-macro_M1 = builders.raw.build { let
pname = "M1-macro_M1"; M1-macro_M1 = builders.raw.build {
version = "1.6.0"; pname = "M1-macro_M1";
version = "1.6.0";
meta = cfg.meta; meta = cfg.meta;
executable = M2.package; executable = M2.package;
args = [ args = [
"--architecture" "--architecture"
architecture.m2libc architecture.m2libc
"-f" "-f"
"${sources.m2libc}/sys/types.h" "${sources.m2libc}/sys/types.h"
"-f" "-f"
"${sources.m2libc}/stddef.h" "${sources.m2libc}/stddef.h"
"-f" "-f"
"${sources.m2libc}/${architecture.m2libc}/linux/unistd.c" "${sources.m2libc}/${architecture.m2libc}/linux/unistd.c"
"-f" "-f"
"${sources.m2libc}/${architecture.m2libc}/linux/fcntl.c" "${sources.m2libc}/${architecture.m2libc}/linux/fcntl.c"
"-f" "-f"
"${sources.m2libc}/fcntl.c" "${sources.m2libc}/fcntl.c"
"-f" "-f"
"${sources.m2libc}/${architecture.m2libc}/linux/sys/stat.c" "${sources.m2libc}/${architecture.m2libc}/linux/sys/stat.c"
"-f" "-f"
"${sources.m2libc}/string.c" "${sources.m2libc}/string.c"
"-f" "-f"
"${sources.m2libc}/stdlib.c" "${sources.m2libc}/stdlib.c"
"-f" "-f"
"${sources.m2libc}/stdio.h" "${sources.m2libc}/stdio.h"
"-f" "-f"
"${sources.m2libc}/stdio.c" "${sources.m2libc}/stdio.c"
"-f" "-f"
"${sources.m2libc}/bootstrappable.c" "${sources.m2libc}/bootstrappable.c"
"-f" "-f"
"${sources.mescc-tools}/stringify.c" "${sources.mescc-tools}/stringify.c"
"-f" "-f"
"${sources.mescc-tools}/M1-macro.c" "${sources.mescc-tools}/M1-macro.c"
"--debug" "--debug"
"-o" "-o"
(builtins.placeholder "out") (builtins.placeholder "out")
]; ];
}; };
M1-macro-footer_M1 = builders.raw.build { M1-macro-footer_M1 = builders.raw.build {
pname = "M1-macro-footer_M1"; pname = "M1-macro-footer_M1";
version = "1.6.0"; version = "1.6.0";
meta = cfg.meta; meta = cfg.meta;
executable = blood-elf.package; executable = blood-elf.package;
args = args = (lib.lists.when (config.aux.platform.bits == 64) "--64") ++ [
(lib.lists.when (config.aux.platform.bits == 64) "--64") "-f"
++ [ M1-macro_M1
"-f" (if config.aux.platform.endian == "little" then "--little-endian" else "--big-endian")
M1-macro_M1 "-o"
( (builtins.placeholder "out")
if config.aux.platform.endian == "little" ];
then "--little-endian" };
else "--big-endian" M1-macro_hex2 = builders.raw.build {
) pname = "M1-macro_hex2";
"-o" version = "1.6.0";
(builtins.placeholder "out")
]; meta = cfg.meta;
};
M1-macro_hex2 = builders.raw.build { executable = M1-0.package;
pname = "M1-macro_hex2";
version = "1.6.0"; args = [
"--architecture"
meta = cfg.meta; architecture.m2libc
(if config.aux.platform.endian == "little" then "--little-endian" else "--big-endian")
executable = M1-0.package; "-f"
"${sources.m2libc}/${architecture.m2libc}/${architecture.m2libc}_defs.M1"
args = [ "-f"
"${sources.m2libc}/${architecture.m2libc}/libc-full.M1"
"-f"
M1-macro_M1
"-f"
M1-macro-footer_M1
"-o"
(builtins.placeholder "out")
];
};
in
[
"--architecture" "--architecture"
architecture.m2libc architecture.m2libc
(if config.aux.platform.endian == "little" then "--little-endian" else "--big-endian")
"--base-address"
( (
if config.aux.platform.endian == "little" if config.aux.system == "x86_64-linux" then
then "--little-endian" "0x00600000"
else "--big-endian" else if config.aux.system == "aarch64-linux" then
"0x00600000"
else if config.aux.system == "i686-linux" then
"0x08048000"
else
builtins.throw "Unsupported system: ${config.aux.system}"
) )
"-f" "-f"
"${sources.m2libc}/${architecture.m2libc}/${architecture.m2libc}_defs.M1" "${sources.m2libc}/${architecture.m2libc}/ELF-${architecture.m2libc}-debug.hex2"
"-f" "-f"
"${sources.m2libc}/${architecture.m2libc}/libc-full.M1" M1-macro_hex2
"-f"
M1-macro_M1
"-f"
M1-macro-footer_M1
"-o" "-o"
(builtins.placeholder "out") (builtins.placeholder "out")
]; ];
}; }
in [ );
"--architecture"
architecture.m2libc
(
if config.aux.platform.endian == "little"
then "--little-endian"
else "--big-endian"
)
"--base-address"
(
if config.aux.system == "x86_64-linux"
then "0x00600000"
else if config.aux.system == "aarch64-linux"
then "0x00600000"
else if config.aux.system == "i686-linux"
then "0x08048000"
else builtins.throw "Unsupported system: ${config.aux.system}"
)
"-f"
"${sources.m2libc}/${architecture.m2libc}/ELF-${architecture.m2libc}-debug.hex2"
"-f"
M1-macro_hex2
"-o"
(builtins.placeholder "out")
];
});
}; };
}; };
} }

View file

@ -1,7 +1,5 @@
{ { lib, config }:
lib, let
config,
}: let
cfg = config.aux.foundation.stages.stage0.hex2; cfg = config.aux.foundation.stages.stage0.hex2;
hex0 = config.aux.foundation.stages.stage0.hex0; hex0 = config.aux.foundation.stages.stage0.hex0;
catm = config.aux.foundation.stages.stage0.catm; catm = config.aux.foundation.stages.stage0.catm;
@ -16,7 +14,8 @@
builders = config.aux.foundation.builders; builders = config.aux.foundation.builders;
sources = config.aux.foundation.stages.stage0.sources; sources = config.aux.foundation.stages.stage0.sources;
architecture = config.aux.foundation.stages.stage0.architecture; architecture = config.aux.foundation.stages.stage0.architecture;
in { in
{
options.aux.foundation.stages.stage0.hex2 = { options.aux.foundation.stages.stage0.hex2 = {
meta = { meta = {
description = lib.options.create { description = lib.options.create {
@ -41,7 +40,7 @@ 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" ];
}; };
}; };
@ -53,135 +52,126 @@ in {
config = { config = {
aux.foundation.stages.stage0.hex2 = { aux.foundation.stages.stage0.hex2 = {
package = lib.modules.overrides.default (builders.raw.build { package = lib.modules.overrides.default (
pname = "hex2"; builders.raw.build {
version = "1.6.0"; pname = "hex2";
version = "1.6.0";
meta = cfg.meta; meta = cfg.meta;
executable = hex2-1.package; executable = hex2-1.package;
args = let args =
hex2_linker_M1 = builders.raw.build { let
pname = "hex2_linker_M1"; hex2_linker_M1 = builders.raw.build {
version = "1.6.0"; pname = "hex2_linker_M1";
version = "1.6.0";
meta = cfg.meta; meta = cfg.meta;
executable = M2.package; executable = M2.package;
args = [ args = [
"--architecture" "--architecture"
architecture.m2libc architecture.m2libc
"-f" "-f"
"${sources.m2libc}/sys/types.h" "${sources.m2libc}/sys/types.h"
"-f" "-f"
"${sources.m2libc}/stddef.h" "${sources.m2libc}/stddef.h"
"-f" "-f"
"${sources.m2libc}/${architecture.m2libc}/linux/unistd.c" "${sources.m2libc}/${architecture.m2libc}/linux/unistd.c"
"-f" "-f"
"${sources.m2libc}/${architecture.m2libc}/linux/fcntl.c" "${sources.m2libc}/${architecture.m2libc}/linux/fcntl.c"
"-f" "-f"
"${sources.m2libc}/fcntl.c" "${sources.m2libc}/fcntl.c"
"-f" "-f"
"${sources.m2libc}/${architecture.m2libc}/linux/sys/stat.c" "${sources.m2libc}/${architecture.m2libc}/linux/sys/stat.c"
"-f" "-f"
"${sources.m2libc}/stdlib.c" "${sources.m2libc}/stdlib.c"
"-f" "-f"
"${sources.m2libc}/stdio.h" "${sources.m2libc}/stdio.h"
"-f" "-f"
"${sources.m2libc}/stdio.c" "${sources.m2libc}/stdio.c"
"-f" "-f"
"${sources.m2libc}/bootstrappable.c" "${sources.m2libc}/bootstrappable.c"
"-f" "-f"
"${sources.mescc-tools}/hex2.h" "${sources.mescc-tools}/hex2.h"
"-f" "-f"
"${sources.mescc-tools}/hex2_linker.c" "${sources.mescc-tools}/hex2_linker.c"
"-f" "-f"
"${sources.mescc-tools}/hex2_word.c" "${sources.mescc-tools}/hex2_word.c"
"-f" "-f"
"${sources.mescc-tools}/hex2.c" "${sources.mescc-tools}/hex2.c"
"--debug" "--debug"
"-o" "-o"
(builtins.placeholder "out") (builtins.placeholder "out")
]; ];
}; };
hex2_linker-footer_M1 = builders.raw.build { hex2_linker-footer_M1 = builders.raw.build {
pname = "hex2_linker-footer_M1"; pname = "hex2_linker-footer_M1";
version = "1.6.0"; version = "1.6.0";
meta = cfg.meta; meta = cfg.meta;
executable = blood-elf.package; executable = blood-elf.package;
args = args = (lib.lists.when (config.aux.platform.bits == 64) "--64") ++ [
(lib.lists.when (config.aux.platform.bits == 64) "--64") "-f"
++ [ hex2_linker_M1
"-f" (if config.aux.platform.endian == "little" then "--little-endian" else "--big-endian")
hex2_linker_M1 "-o"
( (builtins.placeholder "out")
if config.aux.platform.endian == "little" ];
then "--little-endian" };
else "--big-endian" hex2_linker_hex2 = builders.raw.build {
) pname = "hex2_linker_hex2";
"-o" version = "1.6.0";
(builtins.placeholder "out")
]; meta = cfg.meta;
};
hex2_linker_hex2 = builders.raw.build { executable = M1.package;
pname = "hex2_linker_hex2";
version = "1.6.0"; args = [
"--architecture"
meta = cfg.meta; architecture.m2libc
(if config.aux.platform.endian == "little" then "--little-endian" else "--big-endian")
executable = M1.package; "-f"
"${sources.m2libc}/${architecture.m2libc}/${architecture.m2libc}_defs.M1"
args = [ "-f"
"${sources.m2libc}/${architecture.m2libc}/libc-full.M1"
"-f"
hex2_linker_M1
"-f"
hex2_linker-footer_M1
"-o"
(builtins.placeholder "out")
];
};
in
[
"--architecture" "--architecture"
architecture.m2libc architecture.m2libc
(if config.aux.platform.endian == "little" then "--little-endian" else "--big-endian")
"--base-address"
( (
if config.aux.platform.endian == "little" if config.aux.system == "x86_64-linux" then
then "--little-endian" "0x00600000"
else "--big-endian" else if config.aux.system == "aarch64-linux" then
"0x00600000"
else if config.aux.system == "i686-linux" then
"0x08048000"
else
builtins.throw "Unsupported system: ${config.aux.system}"
) )
"-f" "-f"
"${sources.m2libc}/${architecture.m2libc}/${architecture.m2libc}_defs.M1" "${sources.m2libc}/${architecture.m2libc}/ELF-${architecture.m2libc}-debug.hex2"
"-f" "-f"
"${sources.m2libc}/${architecture.m2libc}/libc-full.M1" hex2_linker_hex2
"-f"
hex2_linker_M1
"-f"
hex2_linker-footer_M1
"-o" "-o"
(builtins.placeholder "out") (builtins.placeholder "out")
]; ];
}; }
in [ );
"--architecture"
architecture.m2libc
(
if config.aux.platform.endian == "little"
then "--little-endian"
else "--big-endian"
)
"--base-address"
(
if config.aux.system == "x86_64-linux"
then "0x00600000"
else if config.aux.system == "aarch64-linux"
then "0x00600000"
else if config.aux.system == "i686-linux"
then "0x08048000"
else builtins.throw "Unsupported system: ${config.aux.system}"
)
"-f"
"${sources.m2libc}/${architecture.m2libc}/ELF-${architecture.m2libc}-debug.hex2"
"-f"
hex2_linker_hex2
"-o"
(builtins.placeholder "out")
];
});
}; };
}; };
} }

View file

@ -1,7 +1,5 @@
{ { lib, config }:
lib, let
config,
}: let
cfg = config.aux.foundation.stages.stage0.kaem-unwrapped; cfg = config.aux.foundation.stages.stage0.kaem-unwrapped;
hex0 = config.aux.foundation.stages.stage0.hex0; hex0 = config.aux.foundation.stages.stage0.hex0;
catm = config.aux.foundation.stages.stage0.catm; catm = config.aux.foundation.stages.stage0.catm;
@ -16,7 +14,8 @@
builders = config.aux.foundation.builders; builders = config.aux.foundation.builders;
sources = config.aux.foundation.stages.stage0.sources; sources = config.aux.foundation.stages.stage0.sources;
architecture = config.aux.foundation.stages.stage0.architecture; architecture = config.aux.foundation.stages.stage0.architecture;
in { in
{
options.aux.foundation.stages.stage0.kaem-unwrapped = { options.aux.foundation.stages.stage0.kaem-unwrapped = {
meta = { meta = {
description = lib.options.create { description = lib.options.create {
@ -41,7 +40,7 @@ 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" ];
}; };
}; };
@ -53,137 +52,128 @@ in {
config = { config = {
aux.foundation.stages.stage0.kaem-unwrapped = { aux.foundation.stages.stage0.kaem-unwrapped = {
package = lib.modules.overrides.default (builders.raw.build { package = lib.modules.overrides.default (
pname = "kaem-unwrapped"; builders.raw.build {
version = "1.6.0"; pname = "kaem-unwrapped";
version = "1.6.0";
meta = cfg.meta; meta = cfg.meta;
executable = hex2.package; executable = hex2.package;
args = let args =
kaem_M1 = builders.raw.build { let
pname = "kaem_M1"; kaem_M1 = builders.raw.build {
version = "1.6.0"; pname = "kaem_M1";
version = "1.6.0";
meta = cfg.meta; meta = cfg.meta;
executable = M2.package; executable = M2.package;
args = [ args = [
"--architecture" "--architecture"
architecture.m2libc architecture.m2libc
"-f" "-f"
"${sources.m2libc}/sys/types.h" "${sources.m2libc}/sys/types.h"
"-f" "-f"
"${sources.m2libc}/stddef.h" "${sources.m2libc}/stddef.h"
"-f" "-f"
"${sources.m2libc}/${architecture.m2libc}/linux/unistd.c" "${sources.m2libc}/${architecture.m2libc}/linux/unistd.c"
"-f" "-f"
"${sources.m2libc}/${architecture.m2libc}/linux/fcntl.c" "${sources.m2libc}/${architecture.m2libc}/linux/fcntl.c"
"-f" "-f"
"${sources.m2libc}/fcntl.c" "${sources.m2libc}/fcntl.c"
"-f" "-f"
"${sources.m2libc}/${architecture.m2libc}/linux/sys/stat.c" "${sources.m2libc}/${architecture.m2libc}/linux/sys/stat.c"
"-f" "-f"
"${sources.m2libc}/string.c" "${sources.m2libc}/string.c"
"-f" "-f"
"${sources.m2libc}/stdlib.c" "${sources.m2libc}/stdlib.c"
"-f" "-f"
"${sources.m2libc}/stdio.h" "${sources.m2libc}/stdio.h"
"-f" "-f"
"${sources.m2libc}/stdio.c" "${sources.m2libc}/stdio.c"
"-f" "-f"
"${sources.m2libc}/bootstrappable.c" "${sources.m2libc}/bootstrappable.c"
"-f" "-f"
"${sources.mescc-tools}/Kaem/kaem.h" "${sources.mescc-tools}/Kaem/kaem.h"
"-f" "-f"
"${sources.mescc-tools}/Kaem/variable.c" "${sources.mescc-tools}/Kaem/variable.c"
"-f" "-f"
"${sources.mescc-tools}/Kaem/kaem_globals.c" "${sources.mescc-tools}/Kaem/kaem_globals.c"
"-f" "-f"
"${sources.mescc-tools}/Kaem/kaem.c" "${sources.mescc-tools}/Kaem/kaem.c"
"--debug" "--debug"
"-o" "-o"
(builtins.placeholder "out") (builtins.placeholder "out")
]; ];
}; };
kaem-footer_M1 = builders.raw.build { kaem-footer_M1 = builders.raw.build {
pname = "kaem-footer_M1"; pname = "kaem-footer_M1";
version = "1.6.0"; version = "1.6.0";
meta = cfg.meta; meta = cfg.meta;
executable = blood-elf.package; executable = blood-elf.package;
args = args = (lib.lists.when (config.aux.platform.bits == 64) "--64") ++ [
(lib.lists.when (config.aux.platform.bits == 64) "--64") "-f"
++ [ kaem_M1
"-f" (if config.aux.platform.endian == "little" then "--little-endian" else "--big-endian")
kaem_M1 "-o"
( (builtins.placeholder "out")
if config.aux.platform.endian == "little" ];
then "--little-endian" };
else "--big-endian" kaem_hex2 = builders.raw.build {
) pname = "kaem_hex2";
"-o" version = "1.6.0";
(builtins.placeholder "out")
]; meta = cfg.meta;
};
kaem_hex2 = builders.raw.build { executable = M1.package;
pname = "kaem_hex2";
version = "1.6.0"; args = [
"--architecture"
meta = cfg.meta; architecture.m2libc
(if config.aux.platform.endian == "little" then "--little-endian" else "--big-endian")
executable = M1.package; "-f"
"${sources.m2libc}/${architecture.m2libc}/${architecture.m2libc}_defs.M1"
args = [ "-f"
"${sources.m2libc}/${architecture.m2libc}/libc-full.M1"
"-f"
kaem_M1
"-f"
kaem-footer_M1
"-o"
(builtins.placeholder "out")
];
};
in
[
"--architecture" "--architecture"
architecture.m2libc architecture.m2libc
(if config.aux.platform.endian == "little" then "--little-endian" else "--big-endian")
"--base-address"
( (
if config.aux.platform.endian == "little" if config.aux.system == "x86_64-linux" then
then "--little-endian" "0x00600000"
else "--big-endian" else if config.aux.system == "aarch64-linux" then
"0x00600000"
else if config.aux.system == "i686-linux" then
"0x08048000"
else
builtins.throw "Unsupported system: ${config.aux.system}"
) )
"-f" "-f"
"${sources.m2libc}/${architecture.m2libc}/${architecture.m2libc}_defs.M1" "${sources.m2libc}/${architecture.m2libc}/ELF-${architecture.m2libc}-debug.hex2"
"-f" "-f"
"${sources.m2libc}/${architecture.m2libc}/libc-full.M1" kaem_hex2
"-f"
kaem_M1
"-f"
kaem-footer_M1
"-o" "-o"
(builtins.placeholder "out") (builtins.placeholder "out")
]; ];
}; }
in [ );
"--architecture"
architecture.m2libc
(
if config.aux.platform.endian == "little"
then "--little-endian"
else "--big-endian"
)
"--base-address"
(
if config.aux.system == "x86_64-linux"
then "0x00600000"
else if config.aux.system == "aarch64-linux"
then "0x00600000"
else if config.aux.system == "i686-linux"
then "0x08048000"
else builtins.throw "Unsupported system: ${config.aux.system}"
)
"-f"
"${sources.m2libc}/${architecture.m2libc}/ELF-${architecture.m2libc}-debug.hex2"
"-f"
kaem_hex2
"-o"
(builtins.placeholder "out")
];
});
}; };
}; };
} }

View file

@ -1,11 +1,10 @@
{ { lib, config }:
lib, let
config,
}: let
system = config.aux.system; system = config.aux.system;
architecture = config.aux.foundation.stages.stage0.architecture.base; architecture = config.aux.foundation.stages.stage0.architecture.base;
in { in
{
options.aux.foundation.stages.stage0.sources = { options.aux.foundation.stages.stage0.sources = {
base = lib.options.create { base = lib.options.create {
type = lib.types.string; type = lib.types.string;
@ -44,27 +43,25 @@ in {
# fetching that, we are instead fetching each submodule directly. The central repository is located # fetching that, we are instead fetching each submodule directly. The central repository is located
# here: https://github.com/oriansj/stage0-posix # here: https://github.com/oriansj/stage0-posix
base = base =
if architecture == "AMD64" if architecture == "AMD64" then
then
builtins.fetchTarball { builtins.fetchTarball {
url = "https://github.com/oriansj/stage0-posix-amd64/archive/93fbe4c08772d8df1412e2554668e24cf604088c.tar.gz"; url = "https://github.com/oriansj/stage0-posix-amd64/archive/93fbe4c08772d8df1412e2554668e24cf604088c.tar.gz";
sha256 = "10d1xnjzqplpfip3pm89bydd501x1bcgkg7lkkadyq5bqpad5flp"; sha256 = "10d1xnjzqplpfip3pm89bydd501x1bcgkg7lkkadyq5bqpad5flp";
} }
else if architecture == "AArch64" else if architecture == "AArch64" then
then
# FIXME: We may need to patch the aarch64 variant. # FIXME: We may need to patch the aarch64 variant.
# https://github.com/oriansj/M2libc/pull/17 # https://github.com/oriansj/M2libc/pull/17
builtins.fetchTarball { builtins.fetchTarball {
url = "https://github.com/oriansj/stage0-posix-aarch64/archive/39a43f803d572b53f95d42507202152eeda18361.tar.gz"; url = "https://github.com/oriansj/stage0-posix-aarch64/archive/39a43f803d572b53f95d42507202152eeda18361.tar.gz";
sha256 = "1x607hr3n5j89394d156r23igpx8hifjd14ygksx7902rlwrrry2"; sha256 = "1x607hr3n5j89394d156r23igpx8hifjd14ygksx7902rlwrrry2";
} }
else if architecture == "x86" else if architecture == "x86" then
then
builtins.fetchTarball { builtins.fetchTarball {
url = "https://github.com/oriansj/stage0-posix-x86/archive/e86bf7d304bae5ce5ccc88454bb60cf0837e941f.tar.gz"; url = "https://github.com/oriansj/stage0-posix-x86/archive/e86bf7d304bae5ce5ccc88454bb60cf0837e941f.tar.gz";
sha256 = "1c1fk793yzq8zbg60n2zd22fsmirc3zr26fj0iskap456g84nxv8"; sha256 = "1c1fk793yzq8zbg60n2zd22fsmirc3zr26fj0iskap456g84nxv8";
} }
else builtins.throw "Unsupported architecture for stage0: ${architecture}"; else
builtins.throw "Unsupported architecture for stage0: ${architecture}";
m2libc = builtins.fetchTarball { m2libc = builtins.fetchTarball {
url = "https://github.com/oriansj/M2libc/archive/de7c75f144176c3b9be77695d9bf94440445aeae.tar.gz"; url = "https://github.com/oriansj/M2libc/archive/de7c75f144176c3b9be77695d9bf94440445aeae.tar.gz";

View file

@ -1,13 +1,12 @@
{ { lib, config }:
lib, let
config,
}: let
cfg = config.aux.foundation.stages.stage1.bash.boot; cfg = config.aux.foundation.stages.stage1.bash.boot;
builders = config.aux.foundation.builders; builders = config.aux.foundation.builders;
stage1 = config.aux.foundation.stages.stage1; stage1 = config.aux.foundation.stages.stage1;
in { in
{
options.aux.foundation.stages.stage1.bash.boot = { options.aux.foundation.stages.stage1.bash.boot = {
meta = { meta = {
description = lib.options.create { description = lib.options.create {
@ -32,7 +31,7 @@ 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" ];
}; };
}; };
@ -61,55 +60,56 @@ in {
sha256 = "1r1z2qdw3rz668nxrzwa14vk2zcn00hw7mpjn384picck49d80xs"; sha256 = "1r1z2qdw3rz668nxrzwa14vk2zcn00hw7mpjn384picck49d80xs";
}; };
package = let package =
# Thanks to the live-bootstrap project! let
# See https://github.com/fosslinux/live-bootstrap/blob/1bc4296091c51f53a5598050c8956d16e945b0f5/sysa/bash-2.05b/bash-2.05b.kaem # Thanks to the live-bootstrap project!
liveBootstrap = "https://github.com/fosslinux/live-bootstrap/raw/1bc4296091c51f53a5598050c8956d16e945b0f5/sysa/bash-2.05b"; # See https://github.com/fosslinux/live-bootstrap/blob/1bc4296091c51f53a5598050c8956d16e945b0f5/sysa/bash-2.05b/bash-2.05b.kaem
liveBootstrap = "https://github.com/fosslinux/live-bootstrap/raw/1bc4296091c51f53a5598050c8956d16e945b0f5/sysa/bash-2.05b";
main_mk = builtins.fetchurl { main_mk = builtins.fetchurl {
url = "${liveBootstrap}/mk/main.mk"; url = "${liveBootstrap}/mk/main.mk";
sha256 = "0hj29q3pq3370p18sxkpvv9flb7yvx2fs96xxlxqlwa8lkimd0j4"; sha256 = "0hj29q3pq3370p18sxkpvv9flb7yvx2fs96xxlxqlwa8lkimd0j4";
}; };
common_mk = builtins.fetchurl { common_mk = builtins.fetchurl {
url = "${liveBootstrap}/mk/common.mk"; url = "${liveBootstrap}/mk/common.mk";
sha256 = "09rigxxf85p2ybnq248sai1gdx95yykc8jmwi4yjx389zh09mcr8"; sha256 = "09rigxxf85p2ybnq248sai1gdx95yykc8jmwi4yjx389zh09mcr8";
}; };
builtins_mk = builtins.fetchurl { builtins_mk = builtins.fetchurl {
url = "${liveBootstrap}/mk/builtins.mk"; url = "${liveBootstrap}/mk/builtins.mk";
sha256 = "0939dy5by1xhfmsjj6w63nlgk509fjrhpb2crics3dpcv7prl8lj"; sha256 = "0939dy5by1xhfmsjj6w63nlgk509fjrhpb2crics3dpcv7prl8lj";
}; };
patches = [ patches = [
# mes libc does not have locale support # mes libc does not have locale support
(builtins.fetchurl { (builtins.fetchurl {
url = "${liveBootstrap}/patches/mes-libc.patch"; url = "${liveBootstrap}/patches/mes-libc.patch";
sha256 = "0zksdjf6zbb3p4hqg6plq631y76hhhgab7kdvf7cnpk8bcykn12z"; sha256 = "0zksdjf6zbb3p4hqg6plq631y76hhhgab7kdvf7cnpk8bcykn12z";
}) })
# int name, namelen; is wrong for mes libc, it is char* name, so we modify tinycc # int name, namelen; is wrong for mes libc, it is char* name, so we modify tinycc
# to reflect this. # to reflect this.
(builtins.fetchurl { (builtins.fetchurl {
url = "${liveBootstrap}/patches/tinycc.patch"; url = "${liveBootstrap}/patches/tinycc.patch";
sha256 = "042d2kr4a8klazk1hlvphxr6frn4mr53k957aq3apf6lbvrjgcj2"; sha256 = "042d2kr4a8klazk1hlvphxr6frn4mr53k957aq3apf6lbvrjgcj2";
}) })
# add ifdef's for features we don't want # add ifdef's for features we don't want
(builtins.fetchurl { (builtins.fetchurl {
url = "${liveBootstrap}/patches/missing-defines.patch"; url = "${liveBootstrap}/patches/missing-defines.patch";
sha256 = "1q0k1kj5mrvjkqqly7ki5575a5b3hy1ywnmvhrln318yh67qnkj4"; sha256 = "1q0k1kj5mrvjkqqly7ki5575a5b3hy1ywnmvhrln318yh67qnkj4";
}) })
# mes libc + setting locale = not worky # mes libc + setting locale = not worky
(builtins.fetchurl { (builtins.fetchurl {
url = "${liveBootstrap}/patches/locale.patch"; url = "${liveBootstrap}/patches/locale.patch";
sha256 = "1p1q1slhafsgj8x4k0dpn9h6ryq5fwfx7dicbbxhldbw7zvnnbx9"; sha256 = "1p1q1slhafsgj8x4k0dpn9h6ryq5fwfx7dicbbxhldbw7zvnnbx9";
}) })
# We do not have /dev at this stage of the bootstrap, including /dev/tty # We do not have /dev at this stage of the bootstrap, including /dev/tty
(builtins.fetchurl { (builtins.fetchurl {
url = "${liveBootstrap}/patches/dev-tty.patch"; url = "${liveBootstrap}/patches/dev-tty.patch";
sha256 = "1315slv5f7ziajqyxg4jlyanf1xwd06xw14y6pq7xpm3jzjk55j9"; sha256 = "1315slv5f7ziajqyxg4jlyanf1xwd06xw14y6pq7xpm3jzjk55j9";
}) })
]; ];
in in
builders.kaem.build { builders.kaem.build {
name = "bash-${cfg.version}"; name = "bash-${cfg.version}";

View file

@ -1,17 +1,14 @@
{ { lib, config }:
lib, let
config,
}: let
cfg = config.aux.foundation.stages.stage1.bash; cfg = config.aux.foundation.stages.stage1.bash;
platform = config.aux.platform; platform = config.aux.platform;
builders = config.aux.foundation.builders; builders = config.aux.foundation.builders;
stage1 = config.aux.foundation.stages.stage1; stage1 = config.aux.foundation.stages.stage1;
in { in
includes = [ {
./boot.nix includes = [ ./boot.nix ];
];
options.aux.foundation.stages.stage1.bash = { options.aux.foundation.stages.stage1.bash = {
meta = { meta = {
@ -37,7 +34,7 @@ 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" ];
}; };
mainProgram = lib.options.create { mainProgram = lib.options.create {
@ -72,12 +69,13 @@ in {
sha256 = "132qng0jy600mv1fs95ylnlisx2wavkkgpb19c6kmz7lnmjhjwhk"; sha256 = "132qng0jy600mv1fs95ylnlisx2wavkkgpb19c6kmz7lnmjhjwhk";
}; };
package = let package =
patches = [ let
# flush output for generated code patches = [
./patches/mksignames-flush.patch # flush output for generated code
]; ./patches/mksignames-flush.patch
in ];
in
builders.bash.boot.build { builders.bash.boot.build {
name = "bash-${cfg.version}"; name = "bash-${cfg.version}";

View file

@ -1,14 +1,13 @@
{ { lib, config }:
lib, let
config,
}: let
cfg = config.aux.foundation.stages.stage1.binutils; cfg = config.aux.foundation.stages.stage1.binutils;
platform = config.aux.platform; platform = config.aux.platform;
builders = config.aux.foundation.builders; builders = config.aux.foundation.builders;
stage1 = config.aux.foundation.stages.stage1; stage1 = config.aux.foundation.stages.stage1;
in { in
{
options.aux.foundation.stages.stage1.binutils = { options.aux.foundation.stages.stage1.binutils = {
meta = { meta = {
description = lib.options.create { description = lib.options.create {
@ -33,7 +32,7 @@ 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" ];
}; };
}; };
@ -62,32 +61,33 @@ in {
sha256 = "rppXieI0WeWWBuZxRyPy0//DHAMXQZHvDQFb3wYAdFA="; sha256 = "rppXieI0WeWWBuZxRyPy0//DHAMXQZHvDQFb3wYAdFA=";
}; };
package = let package =
patches = [ let
# Make binutils output deterministic by default. patches = [
./patches/deterministic.patch # Make binutils output deterministic by default.
]; ./patches/deterministic.patch
];
configureFlags = [ configureFlags = [
"--prefix=${builtins.placeholder "out"}" "--prefix=${builtins.placeholder "out"}"
"--build=${platform.build}" "--build=${platform.build}"
"--host=${platform.host}" "--host=${platform.host}"
"--with-sysroot=/" "--with-sysroot=/"
"--enable-deterministic-archives" "--enable-deterministic-archives"
# depends on bison # depends on bison
"--disable-gprofng" "--disable-gprofng"
# Turn on --enable-new-dtags by default to make the linker set # Turn on --enable-new-dtags by default to make the linker set
# RUNPATH instead of RPATH on binaries. This is important because # RUNPATH instead of RPATH on binaries. This is important because
# RUNPATH can be overridden using LD_LIBRARY_PATH at runtime. # RUNPATH can be overridden using LD_LIBRARY_PATH at runtime.
"--enable-new-dtags" "--enable-new-dtags"
# By default binutils searches $libdir for libraries. This brings in # By default binutils searches $libdir for libraries. This brings in
# libbfd and libopcodes into a default visibility. Drop default lib # libbfd and libopcodes into a default visibility. Drop default lib
# path to force users to declare their use of these libraries. # path to force users to declare their use of these libraries.
"--with-lib-path=:" "--with-lib-path=:"
]; ];
in in
builders.bash.boot.build { builders.bash.boot.build {
name = "binutils-${cfg.version}"; name = "binutils-${cfg.version}";

View file

@ -1,14 +1,13 @@
{ { lib, config }:
lib, let
config,
}: let
cfg = config.aux.foundation.stages.stage1.bison; cfg = config.aux.foundation.stages.stage1.bison;
platform = config.aux.platform; platform = config.aux.platform;
builders = config.aux.foundation.builders; builders = config.aux.foundation.builders;
stage1 = config.aux.foundation.stages.stage1; stage1 = config.aux.foundation.stages.stage1;
in { in
{
options.aux.foundation.stages.stage1.bison = { options.aux.foundation.stages.stage1.bison = {
meta = { meta = {
description = lib.options.create { description = lib.options.create {
@ -33,7 +32,7 @@ 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" ];
}; };
}; };

View file

@ -1,14 +1,13 @@
{ { lib, config }:
lib, let
config,
}: let
cfg = config.aux.foundation.stages.stage1.bzip2; cfg = config.aux.foundation.stages.stage1.bzip2;
platform = config.aux.platform; platform = config.aux.platform;
builders = config.aux.foundation.builders; builders = config.aux.foundation.builders;
stage1 = config.aux.foundation.stages.stage1; stage1 = config.aux.foundation.stages.stage1;
in { in
{
options.aux.foundation.stages.stage1.bzip2 = { options.aux.foundation.stages.stage1.bzip2 = {
meta = { meta = {
description = lib.options.create { description = lib.options.create {
@ -34,7 +33,7 @@ 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" ];
}; };
}; };

View file

@ -1,13 +1,12 @@
{ { lib, config }:
lib, let
config,
}: let
cfg = config.aux.foundation.stages.stage1.coreutils.boot; cfg = config.aux.foundation.stages.stage1.coreutils.boot;
builders = config.aux.foundation.builders; builders = config.aux.foundation.builders;
stage1 = config.aux.foundation.stages.stage1; stage1 = config.aux.foundation.stages.stage1;
in { in
{
options.aux.foundation.stages.stage1.coreutils.boot = { options.aux.foundation.stages.stage1.coreutils.boot = {
package = lib.options.create { package = lib.options.create {
type = lib.types.derivation; type = lib.types.derivation;
@ -34,63 +33,64 @@ in {
sha256 = "10wq6k66i8adr4k08p0xmg87ff4ypiazvwzlmi7myib27xgffz62"; sha256 = "10wq6k66i8adr4k08p0xmg87ff4ypiazvwzlmi7myib27xgffz62";
}; };
package = let package =
# Thanks to the live-bootstrap project! let
# See https://github.com/fosslinux/live-bootstrap/blob/a8752029f60217a5c41c548b16f5cdd2a1a0e0db/sysa/coreutils-5.0/coreutils-5.0.kaem # Thanks to the live-bootstrap project!
liveBootstrap = "https://github.com/fosslinux/live-bootstrap/raw/a8752029f60217a5c41c548b16f5cdd2a1a0e0db/sysa/coreutils-5.0"; # See https://github.com/fosslinux/live-bootstrap/blob/a8752029f60217a5c41c548b16f5cdd2a1a0e0db/sysa/coreutils-5.0/coreutils-5.0.kaem
liveBootstrap = "https://github.com/fosslinux/live-bootstrap/raw/a8752029f60217a5c41c548b16f5cdd2a1a0e0db/sysa/coreutils-5.0";
makefile = builtins.fetchurl { makefile = builtins.fetchurl {
url = "${liveBootstrap}/mk/main.mk"; url = "${liveBootstrap}/mk/main.mk";
sha256 = "0njg4xccxfqrslrmlb8ls7h6hlnfmdx42nvxwmca8flvczwrplfd"; sha256 = "0njg4xccxfqrslrmlb8ls7h6hlnfmdx42nvxwmca8flvczwrplfd";
}; };
patches = [ patches = [
# modechange.h uses functions defined in sys/stat.h, so we need to move it to # modechange.h uses functions defined in sys/stat.h, so we need to move it to
# after sys/stat.h include. # after sys/stat.h include.
(builtins.fetchurl { (builtins.fetchurl {
url = "${liveBootstrap}/patches/modechange.patch"; url = "${liveBootstrap}/patches/modechange.patch";
sha256 = "04xa4a5w2syjs3xs6qhh8kdzqavxnrxpxwyhc3qqykpk699p3ms5"; sha256 = "04xa4a5w2syjs3xs6qhh8kdzqavxnrxpxwyhc3qqykpk699p3ms5";
}) })
# mbstate_t is a struct that is required. However, it is not defined by mes libc. # mbstate_t is a struct that is required. However, it is not defined by mes libc.
(builtins.fetchurl { (builtins.fetchurl {
url = "${liveBootstrap}/patches/mbstate.patch"; url = "${liveBootstrap}/patches/mbstate.patch";
sha256 = "0rz3c0sflgxjv445xs87b83i7gmjpl2l78jzp6nm3khdbpcc53vy"; sha256 = "0rz3c0sflgxjv445xs87b83i7gmjpl2l78jzp6nm3khdbpcc53vy";
}) })
# strcoll() does not exist in mes libc, change it to strcmp. # strcoll() does not exist in mes libc, change it to strcmp.
(builtins.fetchurl { (builtins.fetchurl {
url = "${liveBootstrap}/patches/ls-strcmp.patch"; url = "${liveBootstrap}/patches/ls-strcmp.patch";
sha256 = "0lx8rz4sxq3bvncbbr6jf0kyn5bqwlfv9gxyafp0541dld6l55p6"; sha256 = "0lx8rz4sxq3bvncbbr6jf0kyn5bqwlfv9gxyafp0541dld6l55p6";
}) })
# getdate.c is pre-compiled from getdate.y # getdate.c is pre-compiled from getdate.y
# At this point we don't have bison yet and in any case getdate.y does not # At this point we don't have bison yet and in any case getdate.y does not
# compile when generated with modern bison. # compile when generated with modern bison.
(builtins.fetchurl { (builtins.fetchurl {
url = "${liveBootstrap}/patches/touch-getdate.patch"; url = "${liveBootstrap}/patches/touch-getdate.patch";
sha256 = "1xd3z57lvkj7r8vs5n0hb9cxzlyp58pji7d335snajbxzwy144ma"; sha256 = "1xd3z57lvkj7r8vs5n0hb9cxzlyp58pji7d335snajbxzwy144ma";
}) })
# touch: add -h to change symlink timestamps, where supported # touch: add -h to change symlink timestamps, where supported
(builtins.fetchurl { (builtins.fetchurl {
url = "${liveBootstrap}/patches/touch-dereference.patch"; url = "${liveBootstrap}/patches/touch-dereference.patch";
sha256 = "0wky5r3k028xwyf6g6ycwqxzc7cscgmbymncjg948vv4qxsxlfda"; sha256 = "0wky5r3k028xwyf6g6ycwqxzc7cscgmbymncjg948vv4qxsxlfda";
}) })
# strcoll() does not exist in mes libc, change it to strcmp. # strcoll() does not exist in mes libc, change it to strcmp.
(builtins.fetchurl { (builtins.fetchurl {
url = "${liveBootstrap}/patches/expr-strcmp.patch"; url = "${liveBootstrap}/patches/expr-strcmp.patch";
sha256 = "19f31lfsm1iwqzvp2fyv97lmqg4730prfygz9zip58651jf739a9"; sha256 = "19f31lfsm1iwqzvp2fyv97lmqg4730prfygz9zip58651jf739a9";
}) })
# strcoll() does not exist in mes libc, change it to strcmp. # strcoll() does not exist in mes libc, change it to strcmp.
# hard_LC_COLLATE is used but not declared when HAVE_SETLOCALE is unset. # hard_LC_COLLATE is used but not declared when HAVE_SETLOCALE is unset.
(builtins.fetchurl { (builtins.fetchurl {
url = "${liveBootstrap}/patches/sort-locale.patch"; url = "${liveBootstrap}/patches/sort-locale.patch";
sha256 = "0bdch18mpyyxyl6gyqfs0wb4pap9flr11izqdyxccx1hhz0a2i6c"; sha256 = "0bdch18mpyyxyl6gyqfs0wb4pap9flr11izqdyxccx1hhz0a2i6c";
}) })
# don't assume fopen cannot return stdin or stdout. # don't assume fopen cannot return stdin or stdout.
(builtins.fetchurl { (builtins.fetchurl {
url = "${liveBootstrap}/patches/uniq-fopen.patch"; url = "${liveBootstrap}/patches/uniq-fopen.patch";
sha256 = "0qs6shyxl9j4h34v5j5sgpxrr4gjfljd2hxzw416ghwc3xzv63fp"; sha256 = "0qs6shyxl9j4h34v5j5sgpxrr4gjfljd2hxzw416ghwc3xzv63fp";
}) })
]; ];
in in
builders.kaem.build { builders.kaem.build {
name = "coreutils-boot-${cfg.version}"; name = "coreutils-boot-${cfg.version}";

View file

@ -1,17 +1,14 @@
{ { lib, config }:
lib, let
config,
}: let
cfg = config.aux.foundation.stages.stage1.coreutils; cfg = config.aux.foundation.stages.stage1.coreutils;
platform = config.aux.platform; platform = config.aux.platform;
builders = config.aux.foundation.builders; builders = config.aux.foundation.builders;
stage1 = config.aux.foundation.stages.stage1; stage1 = config.aux.foundation.stages.stage1;
in { in
includes = [ {
./boot.nix includes = [ ./boot.nix ];
];
options.aux.foundation.stages.stage1.coreutils = { options.aux.foundation.stages.stage1.coreutils = {
meta = { meta = {
@ -37,7 +34,7 @@ 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" ];
}; };
}; };
@ -66,17 +63,18 @@ in {
sha256 = "X2ANkJOXOwr+JTk9m8GMRPIjJlf0yg2V6jHHAutmtzk="; sha256 = "X2ANkJOXOwr+JTk9m8GMRPIjJlf0yg2V6jHHAutmtzk=";
}; };
package = let package =
configureFlags = [ let
"--prefix=${builtins.placeholder "out"}" configureFlags = [
"--build=${platform.build}" "--prefix=${builtins.placeholder "out"}"
"--host=${platform.host}" "--build=${platform.build}"
# musl 1.1.x doesn't use 64bit time_t "--host=${platform.host}"
"--disable-year2038" # musl 1.1.x doesn't use 64bit time_t
# libstdbuf.so fails in static builds "--disable-year2038"
"--enable-no-install-program=stdbuf" # libstdbuf.so fails in static builds
]; "--enable-no-install-program=stdbuf"
in ];
in
builders.bash.boot.build { builders.bash.boot.build {
name = "coreutils-${cfg.version}"; name = "coreutils-${cfg.version}";

View file

@ -1,11 +1,10 @@
{ { lib, config }:
lib, let
config,
}: let
cfg = config.aux.foundation.stages.stage1; cfg = config.aux.foundation.stages.stage1;
stage1 = config.aux.foundation.stages.stage1; stage1 = config.aux.foundation.stages.stage1;
in { in
{
includes = [ includes = [
./nyacc ./nyacc
./mes ./mes

View file

@ -1,14 +1,13 @@
{ { lib, config }:
lib, let
config,
}: let
cfg = config.aux.foundation.stages.stage1.diffutils; cfg = config.aux.foundation.stages.stage1.diffutils;
platform = config.aux.platform; platform = config.aux.platform;
builders = config.aux.foundation.builders; builders = config.aux.foundation.builders;
stage1 = config.aux.foundation.stages.stage1; stage1 = config.aux.foundation.stages.stage1;
in { in
{
options.aux.foundation.stages.stage1.diffutils = { options.aux.foundation.stages.stage1.diffutils = {
meta = { meta = {
description = lib.options.create { description = lib.options.create {
@ -33,7 +32,7 @@ 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" ];
}; };
}; };

View file

@ -1,14 +1,13 @@
{ { lib, config }:
lib, let
config,
}: let
cfg = config.aux.foundation.stages.stage1.findutils; cfg = config.aux.foundation.stages.stage1.findutils;
platform = config.aux.platform; platform = config.aux.platform;
builders = config.aux.foundation.builders; builders = config.aux.foundation.builders;
stage1 = config.aux.foundation.stages.stage1; stage1 = config.aux.foundation.stages.stage1;
in { in
{
options.aux.foundation.stages.stage1.findutils = { options.aux.foundation.stages.stage1.findutils = {
meta = { meta = {
description = lib.options.create { description = lib.options.create {
@ -33,7 +32,7 @@ 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" ];
}; };
}; };

View file

@ -1,14 +1,13 @@
{ { lib, config }:
lib, let
config,
}: let
cfg = config.aux.foundation.stages.stage1.gawk.boot; cfg = config.aux.foundation.stages.stage1.gawk.boot;
platform = config.aux.platform; platform = config.aux.platform;
builders = config.aux.foundation.builders; builders = config.aux.foundation.builders;
stage1 = config.aux.foundation.stages.stage1; stage1 = config.aux.foundation.stages.stage1;
in { in
{
options.aux.foundation.stages.stage1.gawk.boot = { options.aux.foundation.stages.stage1.gawk.boot = {
package = lib.options.create { package = lib.options.create {
type = lib.types.derivation; type = lib.types.derivation;
@ -35,12 +34,13 @@ in {
sha256 = "1z4bibjm7ldvjwq3hmyifyb429rs2d9bdwkvs0r171vv1khpdwmb"; sha256 = "1z4bibjm7ldvjwq3hmyifyb429rs2d9bdwkvs0r171vv1khpdwmb";
}; };
package = let package =
patches = [ let
# for reproducibility don't generate date stamp patches = [
./patches/no-stamp.patch # for reproducibility don't generate date stamp
]; ./patches/no-stamp.patch
in ];
in
builders.bash.boot.build { builders.bash.boot.build {
name = "gawk-boot-${cfg.version}"; name = "gawk-boot-${cfg.version}";

View file

@ -1,17 +1,14 @@
{ { lib, config }:
lib, let
config,
}: let
cfg = config.aux.foundation.stages.stage1.gawk; cfg = config.aux.foundation.stages.stage1.gawk;
platform = config.aux.platform; platform = config.aux.platform;
builders = config.aux.foundation.builders; builders = config.aux.foundation.builders;
stage1 = config.aux.foundation.stages.stage1; stage1 = config.aux.foundation.stages.stage1;
in { in
includes = [ {
./boot.nix includes = [ ./boot.nix ];
];
options.aux.foundation.stages.stage1.gawk = { options.aux.foundation.stages.stage1.gawk = {
meta = { meta = {
@ -37,7 +34,7 @@ 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" ];
}; };
mainProgram = lib.options.create { mainProgram = lib.options.create {

View file

@ -1,14 +1,13 @@
{ { lib, config }:
lib, let
config,
}: let
cfg = config.aux.foundation.stages.stage1.gcc; cfg = config.aux.foundation.stages.stage1.gcc;
platform = config.aux.platform; platform = config.aux.platform;
builders = config.aux.foundation.builders; builders = config.aux.foundation.builders;
stage1 = config.aux.foundation.stages.stage1; stage1 = config.aux.foundation.stages.stage1;
in { in
{
includes = [ includes = [
./v4.6.nix ./v4.6.nix
./v4.6.cxx.nix ./v4.6.cxx.nix
@ -39,7 +38,7 @@ 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" ];
}; };
}; };

View file

@ -1,14 +1,13 @@
{ { lib, config }:
lib, let
config,
}: let
cfg = config.aux.foundation.stages.stage1.gcc.v46.cxx; cfg = config.aux.foundation.stages.stage1.gcc.v46.cxx;
platform = config.aux.platform; platform = config.aux.platform;
builders = config.aux.foundation.builders; builders = config.aux.foundation.builders;
stage1 = config.aux.foundation.stages.stage1; stage1 = config.aux.foundation.stages.stage1;
in { in
{
options.aux.foundation.stages.stage1.gcc.v46.cxx = { options.aux.foundation.stages.stage1.gcc.v46.cxx = {
package = lib.options.create { package = lib.options.create {
type = lib.types.derivation; type = lib.types.derivation;
@ -112,12 +111,13 @@ in {
}; };
}; };
package = let package =
patches = [ let
# Remove hardcoded NATIVE_SYSTEM_HEADER_DIR patches = [
./patches/no-system-headers.patch # Remove hardcoded NATIVE_SYSTEM_HEADER_DIR
]; ./patches/no-system-headers.patch
in ];
in
builders.bash.build { builders.bash.build {
name = "gcc-cxx-${cfg.version}"; name = "gcc-cxx-${cfg.version}";

View file

@ -1,14 +1,13 @@
{ { lib, config }:
lib, let
config,
}: let
cfg = config.aux.foundation.stages.stage1.gcc.v46; cfg = config.aux.foundation.stages.stage1.gcc.v46;
platform = config.aux.platform; platform = config.aux.platform;
builders = config.aux.foundation.builders; builders = config.aux.foundation.builders;
stage1 = config.aux.foundation.stages.stage1; stage1 = config.aux.foundation.stages.stage1;
in { in
{
options.aux.foundation.stages.stage1.gcc.v46 = { options.aux.foundation.stages.stage1.gcc.v46 = {
package = lib.options.create { package = lib.options.create {
type = lib.types.derivation; type = lib.types.derivation;
@ -112,12 +111,13 @@ in {
}; };
}; };
package = let package =
patches = [ let
# Remove hardcoded NATIVE_SYSTEM_HEADER_DIR patches = [
./patches/no-system-headers.patch # Remove hardcoded NATIVE_SYSTEM_HEADER_DIR
]; ./patches/no-system-headers.patch
in ];
in
builders.bash.build { builders.bash.build {
name = "gcc-${cfg.version}"; name = "gcc-${cfg.version}";

View file

@ -1,14 +1,13 @@
{ { lib, config }:
lib, let
config,
}: let
cfg = config.aux.foundation.stages.stage1.gcc.v8; cfg = config.aux.foundation.stages.stage1.gcc.v8;
platform = config.aux.platform; platform = config.aux.platform;
builders = config.aux.foundation.builders; builders = config.aux.foundation.builders;
stage1 = config.aux.foundation.stages.stage1; stage1 = config.aux.foundation.stages.stage1;
in { in
{
options.aux.foundation.stages.stage1.gcc.v8 = { options.aux.foundation.stages.stage1.gcc.v8 = {
package = lib.options.create { package = lib.options.create {
type = lib.types.derivation; type = lib.types.derivation;

View file

@ -1,13 +1,12 @@
{ { lib, config }:
lib, let
config,
}: let
cfg = config.aux.foundation.stages.stage1.gnugrep; cfg = config.aux.foundation.stages.stage1.gnugrep;
builders = config.aux.foundation.builders; builders = config.aux.foundation.builders;
stage1 = config.aux.foundation.stages.stage1; stage1 = config.aux.foundation.stages.stage1;
in { in
{
options.aux.foundation.stages.stage1.gnugrep = { options.aux.foundation.stages.stage1.gnugrep = {
meta = { meta = {
description = lib.options.create { description = lib.options.create {
@ -32,7 +31,7 @@ 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" ];
}; };
mainProgram = lib.options.create { mainProgram = lib.options.create {
@ -67,14 +66,15 @@ in {
sha256 = "05iayw5sfclc476vpviz67hdy03na0pz2kb5csa50232nfx34853"; sha256 = "05iayw5sfclc476vpviz67hdy03na0pz2kb5csa50232nfx34853";
}; };
package = let package =
# Thanks to the live-bootstrap project! let
# See https://github.com/fosslinux/live-bootstrap/blob/1bc4296091c51f53a5598050c8956d16e945b0f5/sysa/grep-2.4 # Thanks to the live-bootstrap project!
makefile = builtins.fetchurl { # See https://github.com/fosslinux/live-bootstrap/blob/1bc4296091c51f53a5598050c8956d16e945b0f5/sysa/grep-2.4
url = "https://github.com/fosslinux/live-bootstrap/raw/1bc4296091c51f53a5598050c8956d16e945b0f5/sysa/grep-2.4/mk/main.mk"; makefile = builtins.fetchurl {
sha256 = "08an9ljlqry3p15w28hahm6swnd3jxizsd2188przvvsj093j91k"; url = "https://github.com/fosslinux/live-bootstrap/raw/1bc4296091c51f53a5598050c8956d16e945b0f5/sysa/grep-2.4/mk/main.mk";
}; sha256 = "08an9ljlqry3p15w28hahm6swnd3jxizsd2188przvvsj093j91k";
in };
in
builders.bash.boot.build { builders.bash.boot.build {
name = "gnugrep-${cfg.version}"; name = "gnugrep-${cfg.version}";
meta = cfg.meta; meta = cfg.meta;

View file

@ -1,14 +1,13 @@
{ { lib, config }:
lib, let
config,
}: let
cfg = config.aux.foundation.stages.stage1.gnum4; cfg = config.aux.foundation.stages.stage1.gnum4;
platform = config.aux.platform; platform = config.aux.platform;
builders = config.aux.foundation.builders; builders = config.aux.foundation.builders;
stage1 = config.aux.foundation.stages.stage1; stage1 = config.aux.foundation.stages.stage1;
in { in
{
options.aux.foundation.stages.stage1.gnum4 = { options.aux.foundation.stages.stage1.gnum4 = {
meta = { meta = {
description = lib.options.create { description = lib.options.create {
@ -33,7 +32,7 @@ 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" ];
}; };
}; };

View file

@ -1,13 +1,12 @@
{ { lib, config }:
lib, let
config,
}: let
cfg = config.aux.foundation.stages.stage1.gnumake.boot; cfg = config.aux.foundation.stages.stage1.gnumake.boot;
builders = config.aux.foundation.builders; builders = config.aux.foundation.builders;
stage1 = config.aux.foundation.stages.stage1; stage1 = config.aux.foundation.stages.stage1;
in { in
{
options.aux.foundation.stages.stage1.gnumake.boot = { options.aux.foundation.stages.stage1.gnumake.boot = {
package = lib.options.create { package = lib.options.create {
type = lib.types.derivation; type = lib.types.derivation;
@ -34,88 +33,88 @@ in {
sha256 = "1cwgcmwdn7gqn5da2ia91gkyiqs9birr10sy5ykpkaxzcwfzn5nx"; sha256 = "1cwgcmwdn7gqn5da2ia91gkyiqs9birr10sy5ykpkaxzcwfzn5nx";
}; };
package = let package =
patches = [ let
# Replaces /bin/sh with sh, see patch file for reasoning patches = [
./patches/0001-No-impure-bin-sh.patch # Replaces /bin/sh with sh, see patch file for reasoning
# Purity: don't look for library dependencies (of the form `-lfoo') in /lib ./patches/0001-No-impure-bin-sh.patch
# and /usr/lib. It's a stupid feature anyway. Likewise, when searching for # Purity: don't look for library dependencies (of the form `-lfoo') in /lib
# included Makefiles, don't look in /usr/include and friends. # and /usr/lib. It's a stupid feature anyway. Likewise, when searching for
./patches/0002-remove-impure-dirs.patch # included Makefiles, don't look in /usr/include and friends.
# Fixes for tinycc. See comments in patch file for reasoning ./patches/0002-remove-impure-dirs.patch
./patches/0003-tinycc-support.patch # Fixes for tinycc. See comments in patch file for reasoning
]; ./patches/0003-tinycc-support.patch
];
/* /*
Maintenance notes: Maintenance notes:
Generated by Generated by
./configure \ ./configure \
--build i686-pc-linux-gnu \ --build i686-pc-linux-gnu \
--host i686-pc-linux-gnu \ --host i686-pc-linux-gnu \
CC="${tinycc.compiler}/bin/tcc -B ${tinycc.libs}/lib" \ CC="${tinycc.compiler}/bin/tcc -B ${tinycc.libs}/lib" \
ac_cv_func_dup=no ac_cv_func_dup=no
- `ac_cv_func_dup` disabled as mes-libc doesn't implement tmpfile() - `ac_cv_func_dup` disabled as mes-libc doesn't implement tmpfile()
The output src/config.h was then manually filtered, removing definitions that The output src/config.h was then manually filtered, removing definitions that
didn't have uses in the source code didn't have uses in the source code
*/ */
config = [ config = [
"-DFILE_TIMESTAMP_HI_RES=0" "-DFILE_TIMESTAMP_HI_RES=0"
"-DHAVE_ALLOCA" "-DHAVE_ALLOCA"
"-DHAVE_ALLOCA_H" "-DHAVE_ALLOCA_H"
"-DHAVE_ATEXIT" "-DHAVE_ATEXIT"
"-DHAVE_DECL_BSD_SIGNAL=0" "-DHAVE_DECL_BSD_SIGNAL=0"
"-DHAVE_DECL_GETLOADAVG=0" "-DHAVE_DECL_GETLOADAVG=0"
"-DHAVE_DECL_SYS_SIGLIST=0" "-DHAVE_DECL_SYS_SIGLIST=0"
"-DHAVE_DECL__SYS_SIGLIST=0" "-DHAVE_DECL__SYS_SIGLIST=0"
"-DHAVE_DECL___SYS_SIGLIST=0" "-DHAVE_DECL___SYS_SIGLIST=0"
"-DHAVE_DIRENT_H" "-DHAVE_DIRENT_H"
"-DHAVE_DUP2" "-DHAVE_DUP2"
"-DHAVE_FCNTL_H" "-DHAVE_FCNTL_H"
"-DHAVE_FDOPEN" "-DHAVE_FDOPEN"
"-DHAVE_GETCWD" "-DHAVE_GETCWD"
"-DHAVE_GETTIMEOFDAY" "-DHAVE_GETTIMEOFDAY"
"-DHAVE_INTTYPES_H" "-DHAVE_INTTYPES_H"
"-DHAVE_ISATTY" "-DHAVE_ISATTY"
"-DHAVE_LIMITS_H" "-DHAVE_LIMITS_H"
"-DHAVE_LOCALE_H" "-DHAVE_LOCALE_H"
"-DHAVE_MEMORY_H" "-DHAVE_MEMORY_H"
"-DHAVE_MKTEMP" "-DHAVE_MKTEMP"
"-DHAVE_SA_RESTART" "-DHAVE_SA_RESTART"
"-DHAVE_SETVBUF" "-DHAVE_SETVBUF"
"-DHAVE_SIGACTION" "-DHAVE_SIGACTION"
"-DHAVE_SIGSETMASK" "-DHAVE_SIGSETMASK"
"-DHAVE_STDINT_H" "-DHAVE_STDINT_H"
"-DHAVE_STDLIB_H" "-DHAVE_STDLIB_H"
"-DHAVE_STRDUP" "-DHAVE_STRDUP"
"-DHAVE_STRERROR" "-DHAVE_STRERROR"
"-DHAVE_STRINGS_H" "-DHAVE_STRINGS_H"
"-DHAVE_STRING_H" "-DHAVE_STRING_H"
"-DHAVE_STRTOLL" "-DHAVE_STRTOLL"
"-DHAVE_SYS_FILE_H" "-DHAVE_SYS_FILE_H"
"-DHAVE_SYS_PARAM_H" "-DHAVE_SYS_PARAM_H"
"-DHAVE_SYS_RESOURCE_H" "-DHAVE_SYS_RESOURCE_H"
"-DHAVE_SYS_SELECT_H" "-DHAVE_SYS_SELECT_H"
"-DHAVE_SYS_STAT_H" "-DHAVE_SYS_STAT_H"
"-DHAVE_SYS_TIMEB_H" "-DHAVE_SYS_TIMEB_H"
"-DHAVE_SYS_TIME_H" "-DHAVE_SYS_TIME_H"
"-DHAVE_SYS_WAIT_H" "-DHAVE_SYS_WAIT_H"
"-DHAVE_TTYNAME" "-DHAVE_TTYNAME"
"-DHAVE_UMASK" "-DHAVE_UMASK"
"-DHAVE_UNISTD_H" "-DHAVE_UNISTD_H"
"-DHAVE_WAITPID" "-DHAVE_WAITPID"
"-DMAKE_JOBSERVER" "-DMAKE_JOBSERVER"
"-DMAKE_SYMLINKS" "-DMAKE_SYMLINKS"
"-DPATH_SEPARATOR_CHAR=':'" "-DPATH_SEPARATOR_CHAR=':'"
"-DSCCS_GET=\\\"get\\\"" "-DSCCS_GET=\\\"get\\\""
"-DSTDC_HEADERS" "-DSTDC_HEADERS"
"-Dsig_atomic_t=int" "-Dsig_atomic_t=int"
"-Dvfork=fork" "-Dvfork=fork"
]; ];
cflags = cflags = [
[
"-I./src" "-I./src"
"-I./lib" "-I./lib"
"-DHAVE_CONFIG_H" "-DHAVE_CONFIG_H"
@ -127,67 +126,53 @@ in {
"-DNO_OUTPUT_SYNC=1" "-DNO_OUTPUT_SYNC=1"
# mes-libc doesn't define O_TMPFILE # mes-libc doesn't define O_TMPFILE
"-DO_TMPFILE=020000000" "-DO_TMPFILE=020000000"
] ] ++ config;
++ config;
sources = { sources = {
# Maintenance note: list of source files derived from Basic.mk # Maintenance note: list of source files derived from Basic.mk
make = [ make = [
"src/ar.c" "src/ar.c"
"src/arscan.c" "src/arscan.c"
"src/commands.c" "src/commands.c"
"src/default.c" "src/default.c"
"src/dir.c" "src/dir.c"
"src/expand.c" "src/expand.c"
"src/file.c" "src/file.c"
"src/function.c" "src/function.c"
"src/getopt.c" "src/getopt.c"
"src/getopt1.c" "src/getopt1.c"
"src/guile.c" "src/guile.c"
"src/hash.c" "src/hash.c"
"src/implicit.c" "src/implicit.c"
"src/job.c" "src/job.c"
"src/load.c" "src/load.c"
"src/loadapi.c" "src/loadapi.c"
"src/main.c" "src/main.c"
"src/misc.c" "src/misc.c"
"src/output.c" "src/output.c"
"src/read.c" "src/read.c"
"src/remake.c" "src/remake.c"
"src/rule.c" "src/rule.c"
"src/shuffle.c" "src/shuffle.c"
"src/signame.c" "src/signame.c"
"src/strcache.c" "src/strcache.c"
"src/variable.c" "src/variable.c"
"src/version.c" "src/version.c"
"src/vpath.c" "src/vpath.c"
]; ];
glob = [ glob = [
"lib/fnmatch.c" "lib/fnmatch.c"
"lib/glob.c" "lib/glob.c"
]; ];
remote = [ remote = [ "src/remote-stub.c" ];
"src/remote-stub.c" };
];
};
files = files = sources.make ++ sources.glob ++ sources.remote ++ [ "src/posixos.c" ];
sources.make
++ sources.glob
++ sources.remote
++ [
"src/posixos.c"
];
objects = objects = builtins.map (
builtins.map value: builtins.replaceStrings [ ".c" ] [ ".o" ] (builtins.baseNameOf value)
( ) files;
value: in
builtins.replaceStrings [".c"] [".o"]
(builtins.baseNameOf value)
)
files;
in
builders.kaem.build { builders.kaem.build {
name = "gnumake-${cfg.version}"; name = "gnumake-${cfg.version}";

View file

@ -1,17 +1,14 @@
{ { lib, config }:
lib, let
config,
}: let
cfg = config.aux.foundation.stages.stage1.gnumake; cfg = config.aux.foundation.stages.stage1.gnumake;
platform = config.aux.platform; platform = config.aux.platform;
builders = config.aux.foundation.builders; builders = config.aux.foundation.builders;
stage1 = config.aux.foundation.stages.stage1; stage1 = config.aux.foundation.stages.stage1;
in { in
includes = [ {
./boot.nix includes = [ ./boot.nix ];
];
options.aux.foundation.stages.stage1.gnumake = { options.aux.foundation.stages.stage1.gnumake = {
meta = { meta = {
@ -37,7 +34,7 @@ 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" ];
}; };
}; };
@ -66,16 +63,17 @@ in {
sha256 = "3Rb7HWe/q3mnL16DkHNcSePo5wtJRaFasfgd23hlj7M="; sha256 = "3Rb7HWe/q3mnL16DkHNcSePo5wtJRaFasfgd23hlj7M=";
}; };
package = let package =
patches = [ let
# Replaces /bin/sh with sh, see patch file for reasoning patches = [
./patches/0001-No-impure-bin-sh.patch # Replaces /bin/sh with sh, see patch file for reasoning
# Purity: don't look for library dependencies (of the form `-lfoo') in /lib ./patches/0001-No-impure-bin-sh.patch
# and /usr/lib. It's a stupid feature anyway. Likewise, when searching for # Purity: don't look for library dependencies (of the form `-lfoo') in /lib
# included Makefiles, don't look in /usr/include and friends. # and /usr/lib. It's a stupid feature anyway. Likewise, when searching for
./patches/0002-remove-impure-dirs.patch # included Makefiles, don't look in /usr/include and friends.
]; ./patches/0002-remove-impure-dirs.patch
in ];
in
builders.bash.boot.build { builders.bash.boot.build {
name = "gnumake-${cfg.version}"; name = "gnumake-${cfg.version}";

View file

@ -1,13 +1,12 @@
{ { lib, config }:
lib, let
config,
}: let
cfg = config.aux.foundation.stages.stage1.gnupatch; cfg = config.aux.foundation.stages.stage1.gnupatch;
builders = config.aux.foundation.builders; builders = config.aux.foundation.builders;
stage1 = config.aux.foundation.stages.stage1; stage1 = config.aux.foundation.stages.stage1;
in { in
{
options.aux.foundation.stages.stage1.gnupatch = { options.aux.foundation.stages.stage1.gnupatch = {
meta = { meta = {
description = lib.options.create { description = lib.options.create {
@ -32,7 +31,7 @@ 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" ];
}; };
}; };
@ -61,82 +60,72 @@ in {
sha256 = "12nv7jx3gxfp50y11nxzlnmqqrpicjggw6pcsq0wyavkkm3cddgc"; sha256 = "12nv7jx3gxfp50y11nxzlnmqqrpicjggw6pcsq0wyavkkm3cddgc";
}; };
package = let package =
# Thanks to the live-bootstrap project! let
# https://github.com/fosslinux/live-bootstrap/blob/1bc4296091c51f53a5598050c8956d16e945b0f5/sysa/patch-2.5.9/mk/main.mk # Thanks to the live-bootstrap project!
cflags = [ # https://github.com/fosslinux/live-bootstrap/blob/1bc4296091c51f53a5598050c8956d16e945b0f5/sysa/patch-2.5.9/mk/main.mk
"-I." cflags = [
"-DHAVE_DECL_GETENV" "-I."
"-DHAVE_DECL_MALLOC" "-DHAVE_DECL_GETENV"
"-DHAVE_DIRENT_H" "-DHAVE_DECL_MALLOC"
"-DHAVE_LIMITS_H" "-DHAVE_DIRENT_H"
"-DHAVE_GETEUID" "-DHAVE_LIMITS_H"
"-DHAVE_MKTEMP" "-DHAVE_GETEUID"
"-DPACKAGE_BUGREPORT=" "-DHAVE_MKTEMP"
"-Ded_PROGRAM=\\\"/nullop\\\"" "-DPACKAGE_BUGREPORT="
"-Dmbstate_t=int" # When HAVE_MBRTOWC is not enabled uses of mbstate_t are always a no-op "-Ded_PROGRAM=\\\"/nullop\\\""
"-DRETSIGTYPE=int" "-Dmbstate_t=int" # When HAVE_MBRTOWC is not enabled uses of mbstate_t are always a no-op
"-DHAVE_MKDIR" "-DRETSIGTYPE=int"
"-DHAVE_RMDIR" "-DHAVE_MKDIR"
"-DHAVE_FCNTL_H" "-DHAVE_RMDIR"
"-DPACKAGE_NAME=\\\"patch\\\"" "-DHAVE_FCNTL_H"
"-DPACKAGE_VERSION=\\\"${cfg.version}\\\"" "-DPACKAGE_NAME=\\\"patch\\\""
"-DHAVE_MALLOC" "-DPACKAGE_VERSION=\\\"${cfg.version}\\\""
"-DHAVE_REALLOC" "-DHAVE_MALLOC"
"-DSTDC_HEADERS" "-DHAVE_REALLOC"
"-DHAVE_STRING_H" "-DSTDC_HEADERS"
"-DHAVE_STDLIB_H" "-DHAVE_STRING_H"
]; "-DHAVE_STDLIB_H"
];
# Maintenance note: List of sources from Makefile.in # Maintenance note: List of sources from Makefile.in
files = [ files = [
"addext.c" "addext.c"
"argmatch.c" "argmatch.c"
"backupfile.c" "backupfile.c"
"basename.c" "basename.c"
"dirname.c" "dirname.c"
"getopt.c" "getopt.c"
"getopt1.c" "getopt1.c"
"inp.c" "inp.c"
"maketime.c" "maketime.c"
"partime.c" "partime.c"
"patch.c" "patch.c"
"pch.c" "pch.c"
"quote.c" "quote.c"
"quotearg.c" "quotearg.c"
"quotesys.c" "quotesys.c"
"util.c" "util.c"
"version.c" "version.c"
"xmalloc.c" "xmalloc.c"
]; ];
sources = sources = files ++ [
files
++ [
# mes-libc doesn't implement `error()` # mes-libc doesn't implement `error()`
"error.c" "error.c"
]; ];
objects = objects = builtins.map (
builtins.map value: builtins.replaceStrings [ ".c" ] [ ".o" ] (builtins.baseNameOf value)
( ) sources;
value: in
builtins.replaceStrings
[".c"]
[".o"]
(builtins.baseNameOf value)
)
sources;
in
builders.kaem.build { builders.kaem.build {
name = "gnupatch-${cfg.version}"; name = "gnupatch-${cfg.version}";
meta = cfg.meta; meta = cfg.meta;
src = cfg.src; src = cfg.src;
deps.build.host = [ deps.build.host = [ stage1.tinycc.mes.compiler.package ];
stage1.tinycc.mes.compiler.package
];
script = '' script = ''
# Unpack # Unpack

View file

@ -1,13 +1,12 @@
{ { lib, config }:
lib, let
config,
}: let
cfg = config.aux.foundation.stages.stage1.gnused.boot; cfg = config.aux.foundation.stages.stage1.gnused.boot;
builders = config.aux.foundation.builders; builders = config.aux.foundation.builders;
stage1 = config.aux.foundation.stages.stage1; stage1 = config.aux.foundation.stages.stage1;
in { in
{
options.aux.foundation.stages.stage1.gnused.boot = { options.aux.foundation.stages.stage1.gnused.boot = {
package = lib.options.create { package = lib.options.create {
type = lib.types.derivation; type = lib.types.derivation;
@ -34,14 +33,15 @@ in {
sha256 = "0006gk1dw2582xsvgx6y6rzs9zw8b36rhafjwm288zqqji3qfrf3"; sha256 = "0006gk1dw2582xsvgx6y6rzs9zw8b36rhafjwm288zqqji3qfrf3";
}; };
package = let package =
# Thanks to the live-bootstrap project! let
# See https://github.com/fosslinux/live-bootstrap/blob/1bc4296091c51f53a5598050c8956d16e945b0f5/sysa/sed-4.0.9/sed-4.0.9.kaem # Thanks to the live-bootstrap project!
makefile = builtins.fetchurl { # See https://github.com/fosslinux/live-bootstrap/blob/1bc4296091c51f53a5598050c8956d16e945b0f5/sysa/sed-4.0.9/sed-4.0.9.kaem
url = "https://github.com/fosslinux/live-bootstrap/raw/1bc4296091c51f53a5598050c8956d16e945b0f5/sysa/sed-4.0.9/mk/main.mk"; makefile = builtins.fetchurl {
sha256 = "0w1f5ri0g5zla31m6l6xyzbqwdvandqfnzrsw90dd6ak126w3mya"; url = "https://github.com/fosslinux/live-bootstrap/raw/1bc4296091c51f53a5598050c8956d16e945b0f5/sysa/sed-4.0.9/mk/main.mk";
}; sha256 = "0w1f5ri0g5zla31m6l6xyzbqwdvandqfnzrsw90dd6ak126w3mya";
in };
in
builders.bash.boot.build { builders.bash.boot.build {
name = "gnused-boot-${cfg.version}"; name = "gnused-boot-${cfg.version}";

View file

@ -1,17 +1,14 @@
{ { lib, config }:
lib, let
config,
}: let
cfg = config.aux.foundation.stages.stage1.gnused; cfg = config.aux.foundation.stages.stage1.gnused;
platform = config.aux.platform; platform = config.aux.platform;
builders = config.aux.foundation.builders; builders = config.aux.foundation.builders;
stage1 = config.aux.foundation.stages.stage1; stage1 = config.aux.foundation.stages.stage1;
in { in
includes = [ {
./boot.nix includes = [ ./boot.nix ];
];
options.aux.foundation.stages.stage1.gnused = { options.aux.foundation.stages.stage1.gnused = {
meta = { meta = {
@ -37,7 +34,7 @@ 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" ];
}; };
mainProgram = lib.options.create { mainProgram = lib.options.create {

View file

@ -1,14 +1,13 @@
{ { lib, config }:
lib, let
config,
}: let
cfg = config.aux.foundation.stages.stage1.gnutar.boot; cfg = config.aux.foundation.stages.stage1.gnutar.boot;
platform = config.aux.platform; platform = config.aux.platform;
builders = config.aux.foundation.builders; builders = config.aux.foundation.builders;
stage1 = config.aux.foundation.stages.stage1; stage1 = config.aux.foundation.stages.stage1;
in { in
{
options.aux.foundation.stages.stage1.gnutar.boot = { options.aux.foundation.stages.stage1.gnutar.boot = {
package = lib.options.create { package = lib.options.create {
type = lib.types.derivation; type = lib.types.derivation;
@ -35,8 +34,9 @@ in {
sha256 = "02m6gajm647n8l9a5bnld6fnbgdpyi4i3i83p7xcwv0kif47xhy6"; sha256 = "02m6gajm647n8l9a5bnld6fnbgdpyi4i3i83p7xcwv0kif47xhy6";
}; };
package = let package =
in let
in
builders.bash.boot.build { builders.bash.boot.build {
name = "gnutar-boot-${cfg.version}"; name = "gnutar-boot-${cfg.version}";

View file

@ -1,14 +1,13 @@
{ { lib, config }:
lib, let
config,
}: let
cfg = config.aux.foundation.stages.stage1.gnutar; cfg = config.aux.foundation.stages.stage1.gnutar;
platform = config.aux.platform; platform = config.aux.platform;
builders = config.aux.foundation.builders; builders = config.aux.foundation.builders;
stage1 = config.aux.foundation.stages.stage1; stage1 = config.aux.foundation.stages.stage1;
in { in
{
includes = [ includes = [
./boot.nix ./boot.nix
./musl.nix ./musl.nix
@ -38,7 +37,7 @@ 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" ];
}; };
mainProgram = lib.options.create { mainProgram = lib.options.create {

View file

@ -1,14 +1,13 @@
{ { lib, config }:
lib, let
config,
}: let
cfg = config.aux.foundation.stages.stage1.gnutar.musl; cfg = config.aux.foundation.stages.stage1.gnutar.musl;
platform = config.aux.platform; platform = config.aux.platform;
builders = config.aux.foundation.builders; builders = config.aux.foundation.builders;
stage1 = config.aux.foundation.stages.stage1; stage1 = config.aux.foundation.stages.stage1;
in { in
{
options.aux.foundation.stages.stage1.gnutar.musl = { options.aux.foundation.stages.stage1.gnutar.musl = {
package = lib.options.create { package = lib.options.create {
type = lib.types.derivation; type = lib.types.derivation;

View file

@ -1,13 +1,12 @@
{ { lib, config }:
lib, let
config,
}: let
cfg = config.aux.foundation.stages.stage1.gzip; cfg = config.aux.foundation.stages.stage1.gzip;
builders = config.aux.foundation.builders; builders = config.aux.foundation.builders;
stage1 = config.aux.foundation.stages.stage1; stage1 = config.aux.foundation.stages.stage1;
in { in
{
options.aux.foundation.stages.stage1.gzip = { options.aux.foundation.stages.stage1.gzip = {
meta = { meta = {
description = lib.options.create { description = lib.options.create {
@ -32,7 +31,7 @@ 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" ];
}; };
}; };
@ -61,8 +60,9 @@ in {
sha256 = "0ryr5b00qz3xcdcv03qwjdfji8pasp0007ay3ppmk71wl8c1i90w"; sha256 = "0ryr5b00qz3xcdcv03qwjdfji8pasp0007ay3ppmk71wl8c1i90w";
}; };
package = let package =
in let
in
builders.bash.boot.build { builders.bash.boot.build {
name = "gzip-${cfg.version}"; name = "gzip-${cfg.version}";
meta = cfg.meta; meta = cfg.meta;

View file

@ -1,7 +1,5 @@
{ { lib, config }:
lib, let
config,
}: let
cfg = config.aux.foundation.stages.stage1.heirloom; cfg = config.aux.foundation.stages.stage1.heirloom;
platform = config.aux.platform; platform = config.aux.platform;
@ -9,10 +7,9 @@
stage1 = config.aux.foundation.stages.stage1; stage1 = config.aux.foundation.stages.stage1;
stage2 = config.aux.foundation.stages.stage2; stage2 = config.aux.foundation.stages.stage2;
in { in
includes = [ {
./devtools.nix includes = [ ./devtools.nix ];
];
options.aux.foundation.stages.stage1.heirloom = { options.aux.foundation.stages.stage1.heirloom = {
meta = { meta = {
@ -48,7 +45,7 @@ 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" ];
}; };
}; };
@ -77,61 +74,62 @@ in {
sha256 = "6zP3C8wBmx0OCkHx11UtRcV6FicuThxIY07D5ESWow8="; sha256 = "6zP3C8wBmx0OCkHx11UtRcV6FicuThxIY07D5ESWow8=";
}; };
package = let package =
patches = [ let
# we pre-generate nawk's proctab.c as meslibc is not capable of running maketab patches = [
# during build time (insufficient sscanf support) # we pre-generate nawk's proctab.c as meslibc is not capable of running maketab
./patches/proctab.patch # during build time (insufficient sscanf support)
./patches/proctab.patch
# disable utilities that don't build successfully # disable utilities that don't build successfully
./patches/disable-programs.patch ./patches/disable-programs.patch
# "tcc -ar" doesn't support creating empty archives # "tcc -ar" doesn't support creating empty archives
./patches/tcc-empty-ar.patch ./patches/tcc-empty-ar.patch
# meslibc doesn't have seperate libm # meslibc doesn't have seperate libm
./patches/dont-link-lm.patch ./patches/dont-link-lm.patch
# meslibc's vprintf doesn't support %ll # meslibc's vprintf doesn't support %ll
./patches/vprintf.patch ./patches/vprintf.patch
# meslibc doesn't support sysconf() # meslibc doesn't support sysconf()
./patches/sysconf.patch ./patches/sysconf.patch
# meslibc doesn't support locale # meslibc doesn't support locale
./patches/strcoll.patch ./patches/strcoll.patch
# meslibc doesn't support termios.h # meslibc doesn't support termios.h
./patches/termios.patch ./patches/termios.patch
# meslibc doesn't support utime.h # meslibc doesn't support utime.h
./patches/utime.patch ./patches/utime.patch
# meslibc doesn't support langinfo.h # meslibc doesn't support langinfo.h
./patches/langinfo.patch ./patches/langinfo.patch
# support building with meslibc # support building with meslibc
./patches/meslibc-support.patch ./patches/meslibc-support.patch
# remove socket functionality as unsupported by meslibc # remove socket functionality as unsupported by meslibc
./patches/cp-no-socket.patch ./patches/cp-no-socket.patch
]; ];
makeFlags = [ makeFlags = [
# mk.config build options # mk.config build options
"CC='tcc -B ${stage1.tinycc.mes.libs.package}/lib -include ${./stubs.h} -include ${./musl.h}'" "CC='tcc -B ${stage1.tinycc.mes.libs.package}/lib -include ${./stubs.h} -include ${./musl.h}'"
"AR='tcc -ar'" "AR='tcc -ar'"
"RANLIB=true" "RANLIB=true"
"STRIP=true" "STRIP=true"
"SHELL=${stage1.bash.package}/bin/sh" "SHELL=${stage1.bash.package}/bin/sh"
"POSIX_SHELL=${stage1.bash.package}/bin/sh" "POSIX_SHELL=${stage1.bash.package}/bin/sh"
"DEFBIN=/bin" "DEFBIN=/bin"
"SV3BIN=/5bin" "SV3BIN=/5bin"
"S42BIN=/5bin/s42" "S42BIN=/5bin/s42"
"SUSBIN=/bin" "SUSBIN=/bin"
"SU3BIN=/5bin/posix2001" "SU3BIN=/5bin/posix2001"
"UCBBIN=/ucb" "UCBBIN=/ucb"
"CCSBIN=/ccs/bin" "CCSBIN=/ccs/bin"
"DEFLIB=/lib" "DEFLIB=/lib"
"DEFSBIN=/bin" "DEFSBIN=/bin"
"MANDIR=/share/man" "MANDIR=/share/man"
"LCURS=" # disable ncurses "LCURS=" # disable ncurses
"USE_ZLIB=0" # disable zlib "USE_ZLIB=0" # disable zlib
"IWCHAR='-I../libwchar'" "IWCHAR='-I../libwchar'"
"LWCHAR='-L../libwchar -lwchar'" "LWCHAR='-L../libwchar -lwchar'"
]; ];
in in
builders.bash.boot.build { builders.bash.boot.build {
name = "heirloom-${cfg.version}"; name = "heirloom-${cfg.version}";
meta = cfg.meta; meta = cfg.meta;

View file

@ -1,7 +1,5 @@
{ { lib, config }:
lib, let
config,
}: let
cfg = config.aux.foundation.stages.stage1.heirloom.devtools; cfg = config.aux.foundation.stages.stage1.heirloom.devtools;
platform = config.aux.platform; platform = config.aux.platform;
@ -10,7 +8,8 @@
stage0 = config.aux.foundation.stages.stage0; stage0 = config.aux.foundation.stages.stage0;
stage1 = config.aux.foundation.stages.stage1; stage1 = config.aux.foundation.stages.stage1;
stage2 = config.aux.foundation.stages.stage2; stage2 = config.aux.foundation.stages.stage2;
in { in
{
options.aux.foundation.stages.stage1.heirloom.devtools = { options.aux.foundation.stages.stage1.heirloom.devtools = {
package = lib.options.create { package = lib.options.create {
type = lib.types.derivation; type = lib.types.derivation;
@ -54,7 +53,7 @@ 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" ];
}; };
}; };
}; };
@ -68,24 +67,25 @@ in {
sha256 = "9f233d8b78e4351fe9dd2d50d83958a0e5af36f54e9818521458a08e058691ba"; sha256 = "9f233d8b78e4351fe9dd2d50d83958a0e5af36f54e9818521458a08e058691ba";
}; };
package = let package =
# Thanks to the live-bootstrap project! let
# See https://github.com/fosslinux/live-bootstrap/blob/d918b984ad6fe4fc7680f3be060fd82f8c9fddd9/sysa/heirloom-devtools-070527/heirloom-devtools-070527.kaem # Thanks to the live-bootstrap project!
liveBootstrap = "https://github.com/fosslinux/live-bootstrap/raw/d918b984ad6fe4fc7680f3be060fd82f8c9fddd9/sysa/heirloom-devtools-070527"; # See https://github.com/fosslinux/live-bootstrap/blob/d918b984ad6fe4fc7680f3be060fd82f8c9fddd9/sysa/heirloom-devtools-070527/heirloom-devtools-070527.kaem
liveBootstrap = "https://github.com/fosslinux/live-bootstrap/raw/d918b984ad6fe4fc7680f3be060fd82f8c9fddd9/sysa/heirloom-devtools-070527";
patches = [ patches = [
# Remove all kinds of wchar support. Mes Libc does not support wchar in any form # Remove all kinds of wchar support. Mes Libc does not support wchar in any form
(builtins.fetchurl { (builtins.fetchurl {
url = "${liveBootstrap}/patches/yacc_remove_wchar.patch"; url = "${liveBootstrap}/patches/yacc_remove_wchar.patch";
sha256 = "0wgiz02bb7xzjy2gnbjp8y31qy6rc4b29v01zi32zh9lw54j68hc"; sha256 = "0wgiz02bb7xzjy2gnbjp8y31qy6rc4b29v01zi32zh9lw54j68hc";
}) })
# Similarly to yacc, remove wchar. See yacc patch for further information # Similarly to yacc, remove wchar. See yacc patch for further information
(builtins.fetchurl { (builtins.fetchurl {
url = "${liveBootstrap}/patches/lex_remove_wchar.patch"; url = "${liveBootstrap}/patches/lex_remove_wchar.patch";
sha256 = "168dfngi51ljjqgd55wbvmffaq61gk48gak50ymnl1br92qkp4zh"; sha256 = "168dfngi51ljjqgd55wbvmffaq61gk48gak50ymnl1br92qkp4zh";
}) })
]; ];
in in
builders.kaem.build { builders.kaem.build {
name = "heirloom-${cfg.version}"; name = "heirloom-${cfg.version}";
meta = cfg.meta; meta = cfg.meta;

View file

@ -1,14 +1,13 @@
{ { lib, config }:
lib, let
config,
}: let
cfg = config.aux.foundation.stages.stage1.linux-headers; cfg = config.aux.foundation.stages.stage1.linux-headers;
platform = config.aux.platform; platform = config.aux.platform;
builders = config.aux.foundation.builders; builders = config.aux.foundation.builders;
stage1 = config.aux.foundation.stages.stage1; stage1 = config.aux.foundation.stages.stage1;
in { in
{
options.aux.foundation.stages.stage1.linux-headers = { options.aux.foundation.stages.stage1.linux-headers = {
meta = { meta = {
description = lib.options.create { description = lib.options.create {
@ -27,7 +26,7 @@ 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" ];
}; };
}; };

View file

@ -1,14 +1,13 @@
{ { lib, config }:
lib, let
config,
}: let
cfg = config.aux.foundation.stages.stage1.ln-boot; cfg = config.aux.foundation.stages.stage1.ln-boot;
builders = config.aux.foundation.builders; builders = config.aux.foundation.builders;
stage0 = config.aux.foundation.stages.stage0; stage0 = config.aux.foundation.stages.stage0;
stage1 = config.aux.foundation.stages.stage1; stage1 = config.aux.foundation.stages.stage1;
in { in
{
options.aux.foundation.stages.stage1.ln-boot = { options.aux.foundation.stages.stage1.ln-boot = {
meta = { meta = {
description = lib.options.create { description = lib.options.create {
@ -33,7 +32,7 @@ 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" ];
}; };
}; };

View file

@ -1,7 +1,5 @@
{ { lib, config }:
lib, let
config,
}: let
cfg = config.aux.foundation.stages.stage1.mes.compiler; cfg = config.aux.foundation.stages.stage1.mes.compiler;
system = config.aux.system; system = config.aux.system;
@ -9,7 +7,8 @@
stage0 = config.aux.foundation.stages.stage0; stage0 = config.aux.foundation.stages.stage0;
stage1 = config.aux.foundation.stages.stage1; stage1 = config.aux.foundation.stages.stage1;
in { in
{
options.aux.foundation.stages.stage1.mes.compiler = { options.aux.foundation.stages.stage1.mes.compiler = {
meta = { meta = {
description = lib.options.create { description = lib.options.create {
@ -34,7 +33,7 @@ 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" ];
}; };
}; };
@ -46,45 +45,46 @@ in {
config = { config = {
aux.foundation.stages.stage1.mes.compiler = { aux.foundation.stages.stage1.mes.compiler = {
package = let package =
compile = path: let let
file = builtins.baseNameOf path; compile =
fileWithoutExtension = builtins.replaceStrings [".c"] [""] file; path:
let
file = builtins.baseNameOf path;
fileWithoutExtension = builtins.replaceStrings [ ".c" ] [ "" ] file;
cc = builtins.concatStringsSep " " [ cc = builtins.concatStringsSep " " [
"${stage1.mes.libs.src.bin}/bin/mes-m2" "${stage1.mes.libs.src.bin}/bin/mes-m2"
"-e" "-e"
"main" "main"
"${stage1.mes.libs.src.bin}/bin/mescc.scm" "${stage1.mes.libs.src.bin}/bin/mescc.scm"
"--" "--"
"-D" "-D"
"HAVE_CONFIG_H=1" "HAVE_CONFIG_H=1"
"-I" "-I"
"${stage1.mes.libs.prefix}/include" "${stage1.mes.libs.prefix}/include"
"-I" "-I"
"${stage1.mes.libs.prefix}/include/linux/x86" "${stage1.mes.libs.prefix}/include/linux/x86"
]; ];
in
builders.kaem.build {
name = fileWithoutExtension;
script = ''
mkdir ''${out}
cd ''${out}
${cc} -c ${stage1.mes.libs.prefix}/${path}
'';
};
getSourcePath = suffix: source: "${source}/${source.name}${suffix}";
sources = import ./sources.nix;
files = lib.strings.concatMapSep " " (getSourcePath ".o") (
builtins.map compile sources.x86.linux.mescc.mes
);
in in
builders.kaem.build {
name = fileWithoutExtension;
script = ''
mkdir ''${out}
cd ''${out}
${cc} -c ${stage1.mes.libs.prefix}/${path}
'';
};
getSourcePath = suffix: source: "${source}/${source.name}${suffix}";
sources = import ./sources.nix;
files =
lib.strings.concatMapSep
" "
(getSourcePath ".o")
(builtins.map compile sources.x86.linux.mescc.mes);
in
builders.kaem.build { builders.kaem.build {
name = "mes-${stage1.mes.version}"; name = "mes-${stage1.mes.version}";

View file

@ -1,12 +1,11 @@
{ { lib, config }:
lib, let
config,
}: let
cfg = config.aux.foundation.stages.stage1.mes; cfg = config.aux.foundation.stages.stage1.mes;
system = config.aux.system; system = config.aux.system;
builders = config.aux.foundation.builders; builders = config.aux.foundation.builders;
in { in
{
includes = [ includes = [
./compiler.nix ./compiler.nix
./libs.nix ./libs.nix

View file

@ -1,13 +1,12 @@
{ { lib, config }:
lib, let
config,
}: let
cfg = config.aux.foundation.stages.stage1.mes.libc; cfg = config.aux.foundation.stages.stage1.mes.libc;
builders = config.aux.foundation.builders; builders = config.aux.foundation.builders;
stage1 = config.aux.foundation.stages.stage1; stage1 = config.aux.foundation.stages.stage1;
in { in
{
options.aux.foundation.stages.stage1.mes.libc = { options.aux.foundation.stages.stage1.mes.libc = {
meta = { meta = {
description = lib.options.create { description = lib.options.create {
@ -32,7 +31,7 @@ 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" ];
}; };
}; };
@ -44,22 +43,21 @@ in {
config = { config = {
aux.foundation.stages.stage1.mes.libc = { aux.foundation.stages.stage1.mes.libc = {
package = let package =
sources = import ./sources.nix; let
sources = import ./sources.nix;
libtcc1 = sources.x86.linux.gcc.libtcc1; libtcc1 = sources.x86.linux.gcc.libtcc1;
first = lib.lists.take 100 sources.x86.linux.gcc.libc_gnu; first = lib.lists.take 100 sources.x86.linux.gcc.libc_gnu;
last = lib.lists.drop 100 sources.x86.linux.gcc.libc_gnu; last = lib.lists.drop 100 sources.x86.linux.gcc.libc_gnu;
in in
builders.kaem.build { builders.kaem.build {
name = "mes-libc-${stage1.mes.version}"; name = "mes-libc-${stage1.mes.version}";
meta = cfg.meta; meta = cfg.meta;
deps.build.host = [ deps.build.host = [ stage1.ln-boot.package ];
stage1.ln-boot.package
];
script = '' script = ''
cd ${stage1.mes.libs.prefix} cd ${stage1.mes.libs.prefix}

View file

@ -1,7 +1,5 @@
{ { lib, config }:
lib, let
config,
}: let
cfg = config.aux.foundation.stages.stage1.mes.libs; cfg = config.aux.foundation.stages.stage1.mes.libs;
system = config.aux.system; system = config.aux.system;
@ -9,7 +7,8 @@
stage0 = config.aux.foundation.stages.stage0; stage0 = config.aux.foundation.stages.stage0;
stage1 = config.aux.foundation.stages.stage1; stage1 = config.aux.foundation.stages.stage1;
in { in
{
options.aux.foundation.stages.stage1.mes.libs = { options.aux.foundation.stages.stage1.mes.libs = {
meta = { meta = {
description = lib.options.create { description = lib.options.create {
@ -34,7 +33,7 @@ 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" ];
}; };
}; };
@ -58,12 +57,13 @@ in {
aux.foundation.stages.stage1.mes.libs = { aux.foundation.stages.stage1.mes.libs = {
prefix = "${cfg.src.out}/mes-${stage1.mes.version}"; prefix = "${cfg.src.out}/mes-${stage1.mes.version}";
src = let src =
config_h = builtins.toFile "config.h" '' let
#undef SYSTEM_LIBC config_h = builtins.toFile "config.h" ''
#define MES_VERSION "${stage1.mes.version}" #undef SYSTEM_LIBC
''; #define MES_VERSION "${stage1.mes.version}"
in '';
in
builders.kaem.build { builders.kaem.build {
name = "mes-src-${stage1.mes.version}"; name = "mes-src-${stage1.mes.version}";
@ -140,71 +140,82 @@ in {
''; '';
}; };
package = let package =
compile = path: let let
file = builtins.baseNameOf path; compile =
fileWithoutExtension = builtins.replaceStrings [".c"] [""] file; path:
let
file = builtins.baseNameOf path;
fileWithoutExtension = builtins.replaceStrings [ ".c" ] [ "" ] file;
cc = builtins.concatStringsSep " " [ cc = builtins.concatStringsSep " " [
"${cfg.src.bin}/bin/mes-m2" "${cfg.src.bin}/bin/mes-m2"
"-e" "-e"
"main" "main"
"${cfg.src.bin}/bin/mescc.scm" "${cfg.src.bin}/bin/mescc.scm"
"--" "--"
"-D" "-D"
"HAVE_CONFIG_H=1" "HAVE_CONFIG_H=1"
"-I" "-I"
"${cfg.prefix}/include" "${cfg.prefix}/include"
"-I" "-I"
"${cfg.prefix}/include/linux/x86" "${cfg.prefix}/include/linux/x86"
]; ];
in
builders.kaem.build {
name = fileWithoutExtension;
script = ''
mkdir ''${out}
cd ''${out}
${cc} -c ${cfg.prefix}/${path}
'';
};
getSourcePath = suffix: source: "${source}/${source.name}${suffix}";
archive =
destination: sources:
"catm ${destination} ${lib.strings.concatMapSep " " (getSourcePath ".o") sources}";
source =
destination: sources:
"catm ${destination} ${lib.strings.concatMapSep " " (getSourcePath ".s") sources}";
createLib =
name: sources:
let
compiled = builtins.map compile sources;
in
builders.kaem.build {
name = "mes-${name}-${stage1.mes.version}";
meta = cfg.meta;
script = ''
LIBDIR=''${out}/lib
mkdir -p ''${LIBDIR}
cd ''${LIBDIR}
${archive "${name}.a" compiled}
${source "${name}.s" compiled}
'';
};
sources = import ./sources.nix;
crt1 = compile "lib/linux/x86-mes-mescc/crt1.c";
libc-mini = createLib "libc-mini" sources.x86.linux.mescc.libc_mini;
libmescc = createLib "libmescc" sources.x86.linux.mescc.libmescc;
libc = createLib "libc" sources.x86.linux.mescc.libc;
libc_tcc = createLib "libc+tcc" (
sources.x86.linux.mescc.libc_tcc
++ [
# We need `symlink` support for `ln-boot` to work.
"lib/linux/symlink.c"
]
);
in in
builders.kaem.build {
name = fileWithoutExtension;
script = ''
mkdir ''${out}
cd ''${out}
${cc} -c ${cfg.prefix}/${path}
'';
};
getSourcePath = suffix: source: "${source}/${source.name}${suffix}";
archive = destination: sources: "catm ${destination} ${lib.strings.concatMapSep " " (getSourcePath ".o") sources}";
source = destination: sources: "catm ${destination} ${lib.strings.concatMapSep " " (getSourcePath ".s") sources}";
createLib = name: sources: let
compiled = builtins.map compile sources;
in
builders.kaem.build {
name = "mes-${name}-${stage1.mes.version}";
meta = cfg.meta;
script = ''
LIBDIR=''${out}/lib
mkdir -p ''${LIBDIR}
cd ''${LIBDIR}
${archive "${name}.a" compiled}
${source "${name}.s" compiled}
'';
};
sources = import ./sources.nix;
crt1 = compile "lib/linux/x86-mes-mescc/crt1.c";
libc-mini = createLib "libc-mini" sources.x86.linux.mescc.libc_mini;
libmescc = createLib "libmescc" sources.x86.linux.mescc.libmescc;
libc = createLib "libc" sources.x86.linux.mescc.libc;
libc_tcc = createLib "libc+tcc" (sources.x86.linux.mescc.libc_tcc
++ [
# We need `symlink` support for `ln-boot` to work.
"lib/linux/symlink.c"
]);
in
builders.kaem.build { builders.kaem.build {
name = "mes-m2-libs-${stage1.mes.version}"; name = "mes-m2-libs-${stage1.mes.version}";

View file

@ -18,9 +18,7 @@
"lib/mes/globals.c" "lib/mes/globals.c"
"lib/linux/x86-mes-mescc/syscall-internal.c" "lib/linux/x86-mes-mescc/syscall-internal.c"
]; ];
libtcc1 = [ libtcc1 = [ "lib/libtcc1.c" ];
"lib/libtcc1.c"
];
libc = [ libc = [
"lib/mes/__init_io.c" "lib/mes/__init_io.c"
"lib/mes/eputs.c" "lib/mes/eputs.c"
@ -546,9 +544,7 @@
"lib/mes/globals.c" "lib/mes/globals.c"
"lib/linux/x86-mes-gcc/syscall-internal.c" "lib/linux/x86-mes-gcc/syscall-internal.c"
]; ];
libtcc1 = [ libtcc1 = [ "lib/libtcc1.c" ];
"lib/libtcc1.c"
];
libc = [ libc = [
"lib/mes/__init_io.c" "lib/mes/__init_io.c"
"lib/mes/eputs.c" "lib/mes/eputs.c"

View file

@ -1,14 +1,13 @@
{ { lib, config }:
lib, let
config,
}: let
cfg = config.aux.foundation.stages.stage1.musl.boot; cfg = config.aux.foundation.stages.stage1.musl.boot;
platform = config.aux.platform; platform = config.aux.platform;
builders = config.aux.foundation.builders; builders = config.aux.foundation.builders;
stage1 = config.aux.foundation.stages.stage1; stage1 = config.aux.foundation.stages.stage1;
in { in
{
options.aux.foundation.stages.stage1.musl.boot = { options.aux.foundation.stages.stage1.musl.boot = {
package = lib.options.create { package = lib.options.create {
type = lib.types.derivation; type = lib.types.derivation;
@ -35,52 +34,53 @@ in {
sha256 = "E3DJqBKyzyp9koAlEMygBYzDfmanvt1wBR8KNAFQIqM="; sha256 = "E3DJqBKyzyp9koAlEMygBYzDfmanvt1wBR8KNAFQIqM=";
}; };
package = let package =
# Thanks to the live-bootstrap project! let
# See https://github.com/fosslinux/live-bootstrap/blob/d98f97e21413efc32c770d0356f1feda66025686/sysa/musl-1.1.24/musl-1.1.24.sh # Thanks to the live-bootstrap project!
liveBootstrap = "https://github.com/fosslinux/live-bootstrap/raw/d98f97e21413efc32c770d0356f1feda66025686/sysa/musl-1.1.24"; # See https://github.com/fosslinux/live-bootstrap/blob/d98f97e21413efc32c770d0356f1feda66025686/sysa/musl-1.1.24/musl-1.1.24.sh
patches = [ liveBootstrap = "https://github.com/fosslinux/live-bootstrap/raw/d98f97e21413efc32c770d0356f1feda66025686/sysa/musl-1.1.24";
(builtins.fetchurl { patches = [
url = "${liveBootstrap}/patches/avoid_set_thread_area.patch"; (builtins.fetchurl {
sha256 = "TsbBZXk4/KMZG9EKi7cF+sullVXrxlizLNH0UHGXsPs="; url = "${liveBootstrap}/patches/avoid_set_thread_area.patch";
}) sha256 = "TsbBZXk4/KMZG9EKi7cF+sullVXrxlizLNH0UHGXsPs=";
(builtins.fetchurl { })
url = "${liveBootstrap}/patches/avoid_sys_clone.patch"; (builtins.fetchurl {
sha256 = "/ZmH64J57MmbxdfQ4RNjamAiBdkImMTlHsHdgV4gMj4="; url = "${liveBootstrap}/patches/avoid_sys_clone.patch";
}) sha256 = "/ZmH64J57MmbxdfQ4RNjamAiBdkImMTlHsHdgV4gMj4=";
(builtins.fetchurl { })
url = "${liveBootstrap}/patches/fenv.patch"; (builtins.fetchurl {
sha256 = "vMVGjoN4deAJW5gsSqA207SJqAbvhrnOsGK49DdEiTI="; url = "${liveBootstrap}/patches/fenv.patch";
}) sha256 = "vMVGjoN4deAJW5gsSqA207SJqAbvhrnOsGK49DdEiTI=";
(builtins.fetchurl { })
url = "${liveBootstrap}/patches/makefile.patch"; (builtins.fetchurl {
sha256 = "03iYBAUnsrEdLIIhhhq5mM6BGnPn2EfUmIHu51opxbw="; url = "${liveBootstrap}/patches/makefile.patch";
}) sha256 = "03iYBAUnsrEdLIIhhhq5mM6BGnPn2EfUmIHu51opxbw=";
(builtins.fetchurl { })
url = "${liveBootstrap}/patches/musl_weak_symbols.patch"; (builtins.fetchurl {
sha256 = "/d9a2eUkpe9uyi1ye6T4CiYc9MR3FZ9na0Gb90+g4v0="; url = "${liveBootstrap}/patches/musl_weak_symbols.patch";
}) sha256 = "/d9a2eUkpe9uyi1ye6T4CiYc9MR3FZ9na0Gb90+g4v0=";
(builtins.fetchurl { })
url = "${liveBootstrap}/patches/set_thread_area.patch"; (builtins.fetchurl {
sha256 = "RIZYqbbRSx4X/0iFUhriwwBRmoXVR295GNBUjf2UrM0="; url = "${liveBootstrap}/patches/set_thread_area.patch";
}) sha256 = "RIZYqbbRSx4X/0iFUhriwwBRmoXVR295GNBUjf2UrM0=";
(builtins.fetchurl { })
url = "${liveBootstrap}/patches/sigsetjmp.patch"; (builtins.fetchurl {
sha256 = "wd2Aev1zPJXy3q933aiup5p1IMKzVJBquAyl3gbK4PU="; url = "${liveBootstrap}/patches/sigsetjmp.patch";
}) sha256 = "wd2Aev1zPJXy3q933aiup5p1IMKzVJBquAyl3gbK4PU=";
# FIXME: this patch causes the build to fail })
# (builtins.fetchurl { # FIXME: this patch causes the build to fail
# url = "${liveBootstrap}/patches/stdio_flush_on_exit.patch"; # (builtins.fetchurl {
# sha256 = "/z5ze3h3QTysay8nRvyvwPv3pmTcKptdkBIaMCoeLDg="; # url = "${liveBootstrap}/patches/stdio_flush_on_exit.patch";
# }) # sha256 = "/z5ze3h3QTysay8nRvyvwPv3pmTcKptdkBIaMCoeLDg=";
# HACK: always flush stdio immediately # })
./patches/always-flush.patch # HACK: always flush stdio immediately
(builtins.fetchurl { ./patches/always-flush.patch
url = "${liveBootstrap}/patches/va_list.patch"; (builtins.fetchurl {
sha256 = "UmcMIl+YCi3wIeVvjbsCyqFlkyYsM4ECNwTfXP+s7vg="; url = "${liveBootstrap}/patches/va_list.patch";
}) sha256 = "UmcMIl+YCi3wIeVvjbsCyqFlkyYsM4ECNwTfXP+s7vg=";
]; })
in ];
in
builders.bash.boot.build { builders.bash.boot.build {
name = "musl-boot-${cfg.version}"; name = "musl-boot-${cfg.version}";

View file

@ -1,17 +1,14 @@
{ { lib, config }:
lib, let
config,
}: let
cfg = config.aux.foundation.stages.stage1.musl; cfg = config.aux.foundation.stages.stage1.musl;
platform = config.aux.platform; platform = config.aux.platform;
builders = config.aux.foundation.builders; builders = config.aux.foundation.builders;
stage1 = config.aux.foundation.stages.stage1; stage1 = config.aux.foundation.stages.stage1;
in { in
includes = [ {
./boot.nix includes = [ ./boot.nix ];
];
options.aux.foundation.stages.stage1.musl = { options.aux.foundation.stages.stage1.musl = {
meta = { meta = {
@ -38,7 +35,7 @@ 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" ];
}; };
}; };

View file

@ -1,7 +1,5 @@
{ { lib, config }:
lib, let
config,
}: let
cfg = config.aux.foundation.stages.stage1.nyacc; cfg = config.aux.foundation.stages.stage1.nyacc;
builders = config.aux.foundation.builders; builders = config.aux.foundation.builders;
@ -10,7 +8,8 @@
pname = "nyacc"; pname = "nyacc";
version = "1.00.2"; version = "1.00.2";
in { in
{
options.aux.foundation.stages.stage1.nyacc = { options.aux.foundation.stages.stage1.nyacc = {
meta = { meta = {
description = lib.options.create { description = lib.options.create {
@ -35,7 +34,7 @@ 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" ];
}; };
}; };

View file

@ -1,14 +1,13 @@
{ { lib, config }:
lib, let
config,
}: let
cfg = config.aux.foundation.stages.stage1.python; cfg = config.aux.foundation.stages.stage1.python;
platform = config.aux.platform; platform = config.aux.platform;
builders = config.aux.foundation.builders; builders = config.aux.foundation.builders;
stage1 = config.aux.foundation.stages.stage1; stage1 = config.aux.foundation.stages.stage1;
in { in
{
options.aux.foundation.stages.stage1.python = { options.aux.foundation.stages.stage1.python = {
meta = { meta = {
description = lib.options.create { description = lib.options.create {
@ -33,7 +32,7 @@ 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" ];
}; };
}; };
@ -62,16 +61,17 @@ in {
sha256 = "eVw09E30Wg6blxDIxxwVxnGHFSTNQSyhTe8hLozLFV0="; sha256 = "eVw09E30Wg6blxDIxxwVxnGHFSTNQSyhTe8hLozLFV0=";
}; };
package = let package =
patches = [ let
# Disable the use of ldconfig in ctypes.util.find_library (since patches = [
# ldconfig doesn't work on NixOS), and don't use # Disable the use of ldconfig in ctypes.util.find_library (since
# ctypes.util.find_library during the loading of the uuid module # ldconfig doesn't work on NixOS), and don't use
# (since it will do a futile invocation of gcc (!) to find # ctypes.util.find_library during the loading of the uuid module
# libuuid, slowing down program startup a lot). # (since it will do a futile invocation of gcc (!) to find
./patches/no-ldconfig.patch # libuuid, slowing down program startup a lot).
]; ./patches/no-ldconfig.patch
in ];
in
builders.bash.build { builders.bash.build {
name = "python-${cfg.version}"; name = "python-${cfg.version}";
meta = cfg.meta; meta = cfg.meta;

View file

@ -1,7 +1,5 @@
args @ { args@{ lib, config }:
lib, let
config,
}: let
cfg = config.aux.foundation.stages.stage1.tinycc.boot; cfg = config.aux.foundation.stages.stage1.tinycc.boot;
builders = config.aux.foundation.builders; builders = config.aux.foundation.builders;
@ -11,7 +9,8 @@ args @ {
pname = "tinycc-boot"; pname = "tinycc-boot";
helpers = lib.fp.withDynamicArgs (import ./helpers.nix) args; helpers = lib.fp.withDynamicArgs (import ./helpers.nix) args;
in { in
{
options.aux.foundation.stages.stage1.tinycc.boot = { options.aux.foundation.stages.stage1.tinycc.boot = {
meta = { meta = {
description = lib.options.create { description = lib.options.create {
@ -36,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 = ["x86_64-linux" "i686-linux"]; default.value = [
"x86_64-linux"
"i686-linux"
];
}; };
}; };
@ -66,129 +68,130 @@ in {
}; };
config = { config = {
aux.foundation.stages.stage1.tinycc.boot = let aux.foundation.stages.stage1.tinycc.boot =
tinycc-boot = let let
tinycc-mes-bootstrappable = helpers.createBoot { tinycc-boot =
pname = "tinycc-mes-bootstrappable"; let
version = stage1.tinycc.version; tinycc-mes-bootstrappable = helpers.createBoot {
src = cfg.src; pname = "tinycc-mes-bootstrappable";
}; version = stage1.tinycc.version;
src = cfg.src;
};
tinycc-boot0 = helpers.createTinyccMes { tinycc-boot0 = helpers.createTinyccMes {
pname = "tinycc-boot0"; pname = "tinycc-boot0";
version = stage1.tinycc.version; version = stage1.tinycc.version;
src = cfg.src; src = cfg.src;
args = [ args = [
"-D HAVE_LONG_LONG_STUB=1" "-D HAVE_LONG_LONG_STUB=1"
"-D HAVE_SETJMP=1" "-D HAVE_SETJMP=1"
]; ];
lib.args = [ lib.args = [ "-D HAVE_LONG_LONG_STUB=1" ];
"-D HAVE_LONG_LONG_STUB=1" boot = tinycc-mes-bootstrappable;
]; meta = cfg.meta;
boot = tinycc-mes-bootstrappable; };
meta = cfg.meta;
};
tinycc-boot1 = helpers.createTinyccMes { tinycc-boot1 = helpers.createTinyccMes {
pname = "tinycc-boot1"; pname = "tinycc-boot1";
version = stage1.tinycc.version; version = stage1.tinycc.version;
src = cfg.src; src = cfg.src;
args = [ args = [
"-D HAVE_BITFIELD=1" "-D HAVE_BITFIELD=1"
"-D HAVE_LONG_LONG=1" "-D HAVE_LONG_LONG=1"
"-D HAVE_SETJMP=1" "-D HAVE_SETJMP=1"
]; ];
lib.args = [ lib.args = [ "-D HAVE_LONG_LONG=1" ];
"-D HAVE_LONG_LONG=1" boot = tinycc-boot0;
]; meta = cfg.meta;
boot = tinycc-boot0; };
meta = cfg.meta;
};
tinycc-boot2 = helpers.createTinyccMes { tinycc-boot2 = helpers.createTinyccMes {
pname = "tinycc-boot2"; pname = "tinycc-boot2";
version = stage1.tinycc.version; version = stage1.tinycc.version;
src = cfg.src; src = cfg.src;
args = [ args = [
"-D HAVE_BITFIELD=1" "-D HAVE_BITFIELD=1"
"-D HAVE_FLOAT_STUB=1" "-D HAVE_FLOAT_STUB=1"
"-D HAVE_LONG_LONG=1" "-D HAVE_LONG_LONG=1"
"-D HAVE_SETJMP=1" "-D HAVE_SETJMP=1"
]; ];
lib.args = [ lib.args = [
"-D HAVE_FLOAT_STUB=1" "-D HAVE_FLOAT_STUB=1"
"-D HAVE_LONG_LONG=1" "-D HAVE_LONG_LONG=1"
]; ];
boot = tinycc-boot1; boot = tinycc-boot1;
meta = cfg.meta; meta = cfg.meta;
}; };
tinycc-boot3 = helpers.createTinyccMes { tinycc-boot3 = helpers.createTinyccMes {
pname = "tinycc-boot3"; pname = "tinycc-boot3";
version = stage1.tinycc.version; version = stage1.tinycc.version;
src = cfg.src; src = cfg.src;
args = [ args = [
"-D HAVE_BITFIELD=1" "-D HAVE_BITFIELD=1"
"-D HAVE_FLOAT=1" "-D HAVE_FLOAT=1"
"-D HAVE_LONG_LONG=1" "-D HAVE_LONG_LONG=1"
"-D HAVE_SETJMP=1" "-D HAVE_SETJMP=1"
]; ];
lib.args = [ lib.args = [
"-D HAVE_FLOAT=1" "-D HAVE_FLOAT=1"
"-D HAVE_LONG_LONG=1" "-D HAVE_LONG_LONG=1"
]; ];
boot = tinycc-boot2; boot = tinycc-boot2;
meta = cfg.meta; meta = cfg.meta;
}; };
in
helpers.createTinyccMes {
pname = "tinycc-boot";
version = stage1.tinycc.version;
src = cfg.src;
args = [
"-D HAVE_BITFIELD=1"
"-D HAVE_FLOAT=1"
"-D HAVE_LONG_LONG=1"
"-D HAVE_SETJMP=1"
];
lib.args = [
"-D HAVE_FLOAT=1"
"-D HAVE_LONG_LONG=1"
];
boot = tinycc-boot3;
meta = cfg.meta;
};
in in
helpers.createTinyccMes { {
pname = "tinycc-boot"; revision = "80114c4da6b17fbaabb399cc29f427e368309bc8";
version = stage1.tinycc.version;
src = cfg.src;
args = [
"-D HAVE_BITFIELD=1"
"-D HAVE_FLOAT=1"
"-D HAVE_LONG_LONG=1"
"-D HAVE_SETJMP=1"
];
lib.args = [
"-D HAVE_FLOAT=1"
"-D HAVE_LONG_LONG=1"
];
boot = tinycc-boot3;
meta = cfg.meta;
};
in {
revision = "80114c4da6b17fbaabb399cc29f427e368309bc8";
libs.package = tinycc-boot.libs; libs.package = tinycc-boot.libs;
compiler.package = tinycc-boot.compiler; compiler.package = tinycc-boot.compiler;
src = let src =
tarball = builtins.fetchurl { let
url = "https://gitlab.com/janneke/tinycc/-/archive/${cfg.revision}/tinycc-${cfg.revision}.tar.gz"; tarball = builtins.fetchurl {
sha256 = "1a0cw9a62qc76qqn5sjmp3xrbbvsz2dxrw21lrnx9q0s74mwaxbq"; url = "https://gitlab.com/janneke/tinycc/-/archive/${cfg.revision}/tinycc-${cfg.revision}.tar.gz";
}; sha256 = "1a0cw9a62qc76qqn5sjmp3xrbbvsz2dxrw21lrnx9q0s74mwaxbq";
};
patched = builders.kaem.build { patched = builders.kaem.build {
name = "${pname}-src"; name = "${pname}-src";
meta = stage1.tinycc.meta; meta = stage1.tinycc.meta;
script = '' script = ''
ungz --file ${tarball} --output tinycc.tar ungz --file ${tarball} --output tinycc.tar
mkdir -p ''${out} mkdir -p ''${out}
cd ''${out} cd ''${out}
untar --file ''${NIX_BUILD_TOP}/tinycc.tar untar --file ''${NIX_BUILD_TOP}/tinycc.tar
# Patch # Patch
cd tinycc-${cfg.revision} cd tinycc-${cfg.revision}
# Static link by default # Static link by default
replace --file libtcc.c --output libtcc.c --match-on "s->ms_extensions = 1;" --replace-with "s->ms_extensions = 1; s->static_link = 1;" replace --file libtcc.c --output libtcc.c --match-on "s->ms_extensions = 1;" --replace-with "s->ms_extensions = 1; s->static_link = 1;"
''; '';
}; };
in "${patched}/tinycc-${cfg.revision}"; in
}; "${patched}/tinycc-${cfg.revision}";
};
}; };
} }

View file

@ -1,13 +1,12 @@
{ { lib, config }:
lib, let
config,
}: let
cfg = config.aux.foundation.stages.stage1.tinycc; cfg = config.aux.foundation.stages.stage1.tinycc;
builders = config.aux.foundation.builders; builders = config.aux.foundation.builders;
stage1 = config.aux.foundation.stages.stage1; stage1 = config.aux.foundation.stages.stage1;
in { in
{
includes = [ includes = [
./boot.nix ./boot.nix
./mes.nix ./mes.nix
@ -38,7 +37,7 @@ 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" ];
}; };
}; };

View file

@ -1,7 +1,5 @@
{ { lib, config }:
lib, let
config,
}: let
cfg = config.aux.foundation.stages.stage1.tinycc.boot; cfg = config.aux.foundation.stages.stage1.tinycc.boot;
builders = config.aux.foundation.builders; builders = config.aux.foundation.builders;
@ -9,151 +7,163 @@
stage1 = config.aux.foundation.stages.stage1; stage1 = config.aux.foundation.stages.stage1;
cflags = stage1.mes.libc.package.extras.CFLAGS; cflags = stage1.mes.libc.package.extras.CFLAGS;
createBoot = { createBoot =
pname, {
version, pname,
src, version,
}: let src,
compiler = builders.kaem.build { }:
name = "${pname}-${version}"; let
compiler = builders.kaem.build {
script = '' name = "${pname}-${version}";
catm config.h
${stage1.mes.compiler.package}/bin/mes --no-auto-compile -e main ${stage1.mes.libs.src.bin}/bin/mescc.scm -- \
-S \
-o tcc.s \
-I . \
-D BOOTSTRAP=1 \
-I ${src} \
-D TCC_TARGET_I386=1 \
-D inline= \
-D CONFIG_TCCDIR=\"\" \
-D CONFIG_SYSROOT=\"\" \
-D CONFIG_TCC_CRTPREFIX=\"{B}\" \
-D CONFIG_TCC_ELFINTERP=\"/mes/loader\" \
-D CONFIG_TCC_LIBPATHS=\"{B}\" \
-D CONFIG_TCC_SYSINCLUDEPATHS=\"${stage1.mes.libc.package}/include\" \
-D TCC_LIBGCC=\"${stage1.mes.libc.package}/lib/x86-mes/libc.a\" \
-D CONFIG_TCC_LIBTCC1_MES=0 \
-D CONFIG_TCCBOOT=1 \
-D CONFIG_TCC_STATIC=1 \
-D CONFIG_USE_LIBGCC=1 \
-D TCC_MES_LIBC=1 \
-D TCC_VERSION=\"${version}\" \
-D ONE_SOURCE=1 \
${src}/tcc.c
mkdir -p ''${out}/bin
${stage1.mes.compiler.package}/bin/mes --no-auto-compile -e main ${stage1.mes.libs.src.bin}/bin/mescc.scm -- \
-L ${stage1.mes.libs.package}/lib \
-l c+tcc \
-o ''${out}/bin/tcc \
tcc.s
'';
};
libs = createLibc {
inherit pname version;
src = stage1.mes.libc.package;
args = cflags;
tinycc = compiler;
};
in {inherit compiler libs;};
createTinyccMes = {
pname,
version,
src,
args,
boot,
lib ? {},
meta,
}: let
compiler = builders.kaem.build {
name = "${pname}-${version}";
inherit meta;
#
script = ''
catm config.h
mkdir -p ''${out}/bin
${boot.compiler}/bin/tcc \
-B ${boot.libs}/lib \
-g \
-v \
-o ''${out}/bin/tcc \
-D BOOTSTRAP=1 \
${builtins.concatStringsSep " " args} \
-I . \
-I ${src} \
-D TCC_TARGET_I386=1 \
-D CONFIG_TCCDIR=\"\" \
-D CONFIG_SYSROOT=\"\" \
-D CONFIG_TCC_CRTPREFIX=\"{B}\" \
-D CONFIG_TCC_ELFINTERP=\"\" \
-D CONFIG_TCC_LIBPATHS=\"{B}\" \
-D CONFIG_TCC_SYSINCLUDEPATHS=\"${stage1.mes.libc.package}/include\" \
-D TCC_LIBGCC=\"libc.a\" \
-D TCC_LIBTCC1=\"libtcc1.a\" \
-D CONFIG_TCCBOOT=1 \
-D CONFIG_TCC_STATIC=1 \
-D CONFIG_USE_LIBGCC=1 \
-D TCC_MES_LIBC=1 \
-D TCC_VERSION=\"${version}\" \
-D ONE_SOURCE=1 \
${src}/tcc.c
'';
};
libs = createLibc {
inherit pname version src;
args =
builtins.concatStringsSep
" "
(
["-c" "-D" "TCC_TARGET_I386=1"]
++ (lib.args or [])
);
tinycc = compiler;
};
in {
inherit compiler libs boot;
};
createLibc = {
pname,
version,
src,
args,
tinycc,
}: let
createLibrary = name: args: source:
builders.kaem.build {
name = "${name}.a";
script = '' script = ''
${tinycc}/bin/tcc ${args} -c -o ${name}.o ${source} catm config.h
${tinycc}/bin/tcc -ar cr ''${out} ${name}.o ${stage1.mes.compiler.package}/bin/mes --no-auto-compile -e main ${stage1.mes.libs.src.bin}/bin/mescc.scm -- \
-S \
-o tcc.s \
-I . \
-D BOOTSTRAP=1 \
-I ${src} \
-D TCC_TARGET_I386=1 \
-D inline= \
-D CONFIG_TCCDIR=\"\" \
-D CONFIG_SYSROOT=\"\" \
-D CONFIG_TCC_CRTPREFIX=\"{B}\" \
-D CONFIG_TCC_ELFINTERP=\"/mes/loader\" \
-D CONFIG_TCC_LIBPATHS=\"{B}\" \
-D CONFIG_TCC_SYSINCLUDEPATHS=\"${stage1.mes.libc.package}/include\" \
-D TCC_LIBGCC=\"${stage1.mes.libc.package}/lib/x86-mes/libc.a\" \
-D CONFIG_TCC_LIBTCC1_MES=0 \
-D CONFIG_TCCBOOT=1 \
-D CONFIG_TCC_STATIC=1 \
-D CONFIG_USE_LIBGCC=1 \
-D TCC_MES_LIBC=1 \
-D TCC_VERSION=\"${version}\" \
-D ONE_SOURCE=1 \
${src}/tcc.c
mkdir -p ''${out}/bin
${stage1.mes.compiler.package}/bin/mes --no-auto-compile -e main ${stage1.mes.libs.src.bin}/bin/mescc.scm -- \
-L ${stage1.mes.libs.package}/lib \
-l c+tcc \
-o ''${out}/bin/tcc \
tcc.s
''; '';
}; };
crt = builders.kaem.build { libs = createLibc {
name = "crt"; inherit pname version;
src = stage1.mes.libc.package;
script = '' args = cflags;
mkdir -p ''${out}/lib tinycc = compiler;
${tinycc}/bin/tcc ${cflags} -c -o ''${out}/lib/crt1.o ${stage1.mes.libc.package}/lib/crt1.c };
${tinycc}/bin/tcc ${cflags} -c -o ''${out}/lib/crtn.o ${stage1.mes.libc.package}/lib/crtn.c in
${tinycc}/bin/tcc ${cflags} -c -o ''${out}/lib/crti.o ${stage1.mes.libc.package}/lib/crti.c {
''; inherit compiler libs;
}; };
libtcc1 = createLibrary "libtcc1" args "${src}/lib/libtcc1.c"; createTinyccMes =
libc = createLibrary "libc" cflags "${stage1.mes.libc.package}/lib/libc.c"; {
libgetopt = createLibrary "libgetopt" cflags "${stage1.mes.libc.package}/lib/libgetopt.c"; pname,
in version,
src,
args,
boot,
lib ? { },
meta,
}:
let
compiler = builders.kaem.build {
name = "${pname}-${version}";
inherit meta;
#
script = ''
catm config.h
mkdir -p ''${out}/bin
${boot.compiler}/bin/tcc \
-B ${boot.libs}/lib \
-g \
-v \
-o ''${out}/bin/tcc \
-D BOOTSTRAP=1 \
${builtins.concatStringsSep " " args} \
-I . \
-I ${src} \
-D TCC_TARGET_I386=1 \
-D CONFIG_TCCDIR=\"\" \
-D CONFIG_SYSROOT=\"\" \
-D CONFIG_TCC_CRTPREFIX=\"{B}\" \
-D CONFIG_TCC_ELFINTERP=\"\" \
-D CONFIG_TCC_LIBPATHS=\"{B}\" \
-D CONFIG_TCC_SYSINCLUDEPATHS=\"${stage1.mes.libc.package}/include\" \
-D TCC_LIBGCC=\"libc.a\" \
-D TCC_LIBTCC1=\"libtcc1.a\" \
-D CONFIG_TCCBOOT=1 \
-D CONFIG_TCC_STATIC=1 \
-D CONFIG_USE_LIBGCC=1 \
-D TCC_MES_LIBC=1 \
-D TCC_VERSION=\"${version}\" \
-D ONE_SOURCE=1 \
${src}/tcc.c
'';
};
libs = createLibc {
inherit pname version src;
args = builtins.concatStringsSep " " (
[
"-c"
"-D"
"TCC_TARGET_I386=1"
]
++ (lib.args or [ ])
);
tinycc = compiler;
};
in
{
inherit compiler libs boot;
};
createLibc =
{
pname,
version,
src,
args,
tinycc,
}:
let
createLibrary =
name: args: source:
builders.kaem.build {
name = "${name}.a";
script = ''
${tinycc}/bin/tcc ${args} -c -o ${name}.o ${source}
${tinycc}/bin/tcc -ar cr ''${out} ${name}.o
'';
};
crt = builders.kaem.build {
name = "crt";
script = ''
mkdir -p ''${out}/lib
${tinycc}/bin/tcc ${cflags} -c -o ''${out}/lib/crt1.o ${stage1.mes.libc.package}/lib/crt1.c
${tinycc}/bin/tcc ${cflags} -c -o ''${out}/lib/crtn.o ${stage1.mes.libc.package}/lib/crtn.c
${tinycc}/bin/tcc ${cflags} -c -o ''${out}/lib/crti.o ${stage1.mes.libc.package}/lib/crti.c
'';
};
libtcc1 = createLibrary "libtcc1" args "${src}/lib/libtcc1.c";
libc = createLibrary "libc" cflags "${stage1.mes.libc.package}/lib/libc.c";
libgetopt = createLibrary "libgetopt" cflags "${stage1.mes.libc.package}/lib/libgetopt.c";
in
builders.kaem.build { builders.kaem.build {
name = "${pname}-libs-${version}"; name = "${pname}-libs-${version}";
@ -167,10 +177,7 @@
cp ${libgetopt} ''${out}/lib/libgetopt.a cp ${libgetopt} ''${out}/lib/libgetopt.a
''; '';
}; };
in { in
inherit {
createBoot inherit createBoot createTinyccMes createLibc;
createTinyccMes
createLibc
;
} }

View file

@ -1,7 +1,5 @@
args @ { args@{ lib, config }:
lib, let
config,
}: let
cfg = config.aux.foundation.stages.stage1.tinycc.mes; cfg = config.aux.foundation.stages.stage1.tinycc.mes;
builders = config.aux.foundation.builders; builders = config.aux.foundation.builders;
@ -11,7 +9,8 @@ args @ {
pname = "tinycc-mes"; pname = "tinycc-mes";
helpers = lib.fp.withDynamicArgs (import ./helpers.nix) args; helpers = lib.fp.withDynamicArgs (import ./helpers.nix) args;
in { in
{
options.aux.foundation.stages.stage1.tinycc.mes = { options.aux.foundation.stages.stage1.tinycc.mes = {
compiler = { compiler = {
package = lib.options.create { package = lib.options.create {
@ -39,104 +38,109 @@ in {
}; };
config = { config = {
aux.foundation.stages.stage1.tinycc.mes = let aux.foundation.stages.stage1.tinycc.mes =
tinycc-mes = let let
tccdefs = builders.kaem.build { tinycc-mes =
name = "tccdefs-${stage1.tinycc.version}"; let
tccdefs = builders.kaem.build {
name = "tccdefs-${stage1.tinycc.version}";
script = '' script = ''
mkdir ''${out} mkdir ''${out}
${stage1.tinycc.boot.compiler.package}/bin/tcc \ ${stage1.tinycc.boot.compiler.package}/bin/tcc \
-B ${stage1.tinycc.boot.libs.package}/lib \ -B ${stage1.tinycc.boot.libs.package}/lib \
-DC2STR \ -DC2STR \
-o c2str \ -o c2str \
${cfg.src}/conftest.c ${cfg.src}/conftest.c
./c2str ${cfg.src}/include/tccdefs.h ''${out}/tccdefs_.h ./c2str ${cfg.src}/include/tccdefs.h ''${out}/tccdefs_.h
''; '';
}; };
tinycc-mes-boot = helpers.createTinyccMes { tinycc-mes-boot = helpers.createTinyccMes {
pname = "${pname}-boot"; pname = "${pname}-boot";
version = stage1.tinycc.version; version = stage1.tinycc.version;
src = cfg.src; src = cfg.src;
args = [ args = [
"-D HAVE_BITFIELD=1" "-D HAVE_BITFIELD=1"
"-D HAVE_FLOAT=1" "-D HAVE_FLOAT=1"
"-D HAVE_LONG_LONG=1" "-D HAVE_LONG_LONG=1"
"-D HAVE_SETJMP=1" "-D HAVE_SETJMP=1"
"-D CONFIG_TCC_PREDEFS=1" "-D CONFIG_TCC_PREDEFS=1"
"-I ${tccdefs}" "-I ${tccdefs}"
"-D CONFIG_TCC_SEMLOCK=0" "-D CONFIG_TCC_SEMLOCK=0"
]; ];
lib.args = [ lib.args = [
"-D HAVE_FLOAT=1" "-D HAVE_FLOAT=1"
"-D HAVE_LONG_LONG=1" "-D HAVE_LONG_LONG=1"
"-D CONFIG_TCC_PREDEFS=1" "-D CONFIG_TCC_PREDEFS=1"
"-I ${tccdefs}" "-I ${tccdefs}"
"-D CONFIG_TCC_SEMLOCK=0" "-D CONFIG_TCC_SEMLOCK=0"
]; ];
boot = { boot = {
libs = stage1.tinycc.boot.libs.package; libs = stage1.tinycc.boot.libs.package;
compiler = stage1.tinycc.boot.compiler.package; compiler = stage1.tinycc.boot.compiler.package;
};
meta = stage1.tinycc.meta;
};
in
helpers.createTinyccMes {
inherit pname;
version = stage1.tinycc.version;
src = cfg.src;
args = [
"-std=c99"
"-D HAVE_BITFIELD=1"
"-D HAVE_FLOAT=1"
"-D HAVE_LONG_LONG=1"
"-D HAVE_SETJMP=1"
"-D CONFIG_TCC_PREDEFS=1"
"-I ${tccdefs}"
"-D CONFIG_TCC_SEMLOCK=0"
];
lib.args = [
"-D HAVE_FLOAT=1"
"-D HAVE_LONG_LONG=1"
"-D CONFIG_TCC_PREDEFS=1"
"-I ${tccdefs}"
"-D CONFIG_TCC_SEMLOCK=0"
];
boot = tinycc-mes-boot;
meta = stage1.tinycc.meta;
}; };
meta = stage1.tinycc.meta;
};
in in
helpers.createTinyccMes { {
inherit pname; revision = "86f3d8e33105435946383aee52487b5ddf918140";
version = stage1.tinycc.version;
src = cfg.src;
args = [
"-std=c99"
"-D HAVE_BITFIELD=1"
"-D HAVE_FLOAT=1"
"-D HAVE_LONG_LONG=1"
"-D HAVE_SETJMP=1"
"-D CONFIG_TCC_PREDEFS=1"
"-I ${tccdefs}"
"-D CONFIG_TCC_SEMLOCK=0"
];
lib.args = [
"-D HAVE_FLOAT=1"
"-D HAVE_LONG_LONG=1"
"-D CONFIG_TCC_PREDEFS=1"
"-I ${tccdefs}"
"-D CONFIG_TCC_SEMLOCK=0"
];
boot = tinycc-mes-boot;
meta = stage1.tinycc.meta;
};
in {
revision = "86f3d8e33105435946383aee52487b5ddf918140";
libs.package = tinycc-mes.libs; libs.package = tinycc-mes.libs;
compiler.package = tinycc-mes.compiler; compiler.package = tinycc-mes.compiler;
src = let src =
tarball = builtins.fetchurl { let
url = "https://repo.or.cz/tinycc.git/snapshot/${cfg.revision}.tar.gz"; tarball = builtins.fetchurl {
sha256 = "11idrvbwfgj1d03crv994mpbbbyg63j1k64lw1gjy7mkiifw2xap"; url = "https://repo.or.cz/tinycc.git/snapshot/${cfg.revision}.tar.gz";
}; sha256 = "11idrvbwfgj1d03crv994mpbbbyg63j1k64lw1gjy7mkiifw2xap";
};
patched = builders.kaem.build { patched = builders.kaem.build {
name = "${pname}-src"; name = "${pname}-src";
meta = stage1.tinycc.meta; meta = stage1.tinycc.meta;
script = '' script = ''
ungz --file ${tarball} --output tinycc.tar ungz --file ${tarball} --output tinycc.tar
mkdir -p ''${out} mkdir -p ''${out}
cd ''${out} cd ''${out}
untar --file ''${NIX_BUILD_TOP}/tinycc.tar untar --file ''${NIX_BUILD_TOP}/tinycc.tar
# Patch # Patch
cd tinycc-${builtins.substring 0 7 cfg.revision} cd tinycc-${builtins.substring 0 7 cfg.revision}
# Static link by default # Static link by default
replace --file libtcc.c --output libtcc.c --match-on "s->ms_extensions = 1;" --replace-with "s->ms_extensions = 1; s->static_link = 1;" replace --file libtcc.c --output libtcc.c --match-on "s->ms_extensions = 1;" --replace-with "s->ms_extensions = 1; s->static_link = 1;"
''; '';
}; };
in "${patched}/tinycc-${builtins.substring 0 7 cfg.revision}"; in
}; "${patched}/tinycc-${builtins.substring 0 7 cfg.revision}";
};
}; };
} }

View file

@ -1,7 +1,5 @@
args @ { args@{ lib, config }:
lib, let
config,
}: let
cfg = config.aux.foundation.stages.stage1.tinycc.musl; cfg = config.aux.foundation.stages.stage1.tinycc.musl;
builders = config.aux.foundation.builders; builders = config.aux.foundation.builders;
@ -11,7 +9,8 @@ args @ {
pname = "tinycc-musl"; pname = "tinycc-musl";
helpers = lib.fp.withDynamicArgs (import ./helpers.nix) args; helpers = lib.fp.withDynamicArgs (import ./helpers.nix) args;
in { in
{
options.aux.foundation.stages.stage1.tinycc.musl = { options.aux.foundation.stages.stage1.tinycc.musl = {
compiler = { compiler = {
package = lib.options.create { package = lib.options.create {
@ -39,139 +38,141 @@ in {
}; };
config = { config = {
aux.foundation.stages.stage1.tinycc.musl = let aux.foundation.stages.stage1.tinycc.musl =
patches = [ let
./patches/ignore-duplicate-symbols.patch patches = [
./patches/ignore-static-inside-array.patch ./patches/ignore-duplicate-symbols.patch
./patches/static-link.patch ./patches/ignore-static-inside-array.patch
]; ./patches/static-link.patch
tinycc-musl = builders.bash.boot.build {
name = "${pname}-${stage1.tinycc.version}";
meta = stage1.tinycc.meta;
deps.build.host = [
stage1.tinycc.boot.compiler.package
stage1.gnupatch.package
stage1.gnutar.boot.package
stage1.gzip.package
]; ];
script = '' tinycc-musl = builders.bash.boot.build {
# Unpack name = "${pname}-${stage1.tinycc.version}";
tar xzf ${cfg.src}
cd tinycc-${builtins.substring 0 7 cfg.revision}
# Patch meta = stage1.tinycc.meta;
${lib.strings.concatMapSep "\n" (file: "patch -Np0 -i ${file}") patches}
# Configure deps.build.host = [
touch config.h stage1.tinycc.boot.compiler.package
stage1.gnupatch.package
stage1.gnutar.boot.package
stage1.gzip.package
];
# Build script = ''
# We first have to recompile using tcc-0.9.26 as tcc-0.9.27 is not self-hosting, # Unpack
# but when linked with musl it is. tar xzf ${cfg.src}
ln -s ${stage1.musl.boot.package}/lib/libtcc1.a ./libtcc1.a cd tinycc-${builtins.substring 0 7 cfg.revision}
tcc \ # Patch
-B ${stage1.tinycc.boot.libs.package}/lib \ ${lib.strings.concatMapSep "\n" (file: "patch -Np0 -i ${file}") patches}
-DC2STR \
-o c2str \
conftest.c
./c2str include/tccdefs.h tccdefs_.h
tcc -v \ # Configure
-static \ touch config.h
-o tcc-musl \
-D TCC_TARGET_I386=1 \
-D CONFIG_TCCDIR=\"\" \
-D CONFIG_TCC_CRTPREFIX=\"{B}\" \
-D CONFIG_TCC_ELFINTERP=\"/musl/loader\" \
-D CONFIG_TCC_LIBPATHS=\"{B}\" \
-D CONFIG_TCC_SYSINCLUDEPATHS=\"${stage1.musl.boot.package}/include\" \
-D TCC_LIBGCC=\"libc.a\" \
-D TCC_LIBTCC1=\"libtcc1.a\" \
-D CONFIG_TCC_STATIC=1 \
-D CONFIG_USE_LIBGCC=1 \
-D TCC_VERSION=\"0.9.27\" \
-D ONE_SOURCE=1 \
-D TCC_MUSL=1 \
-D CONFIG_TCC_PREDEFS=1 \
-D CONFIG_TCC_SEMLOCK=0 \
-B . \
-B ${stage1.tinycc.boot.libs.package}/lib \
tcc.c
# libtcc1.a
rm -f libtcc1.a
tcc -c -D HAVE_CONFIG_H=1 lib/libtcc1.c
tcc -ar cr libtcc1.a libtcc1.o
# Rebuild tcc-musl with itself # Build
./tcc-musl \ # We first have to recompile using tcc-0.9.26 as tcc-0.9.27 is not self-hosting,
-v \ # but when linked with musl it is.
-static \ ln -s ${stage1.musl.boot.package}/lib/libtcc1.a ./libtcc1.a
-o tcc-musl \
-D TCC_TARGET_I386=1 \
-D CONFIG_TCCDIR=\"\" \
-D CONFIG_TCC_CRTPREFIX=\"{B}\" \
-D CONFIG_TCC_ELFINTERP=\"/musl/loader\" \
-D CONFIG_TCC_LIBPATHS=\"{B}\" \
-D CONFIG_TCC_SYSINCLUDEPATHS=\"${stage1.musl.boot.package}/include\" \
-D TCC_LIBGCC=\"libc.a\" \
-D TCC_LIBTCC1=\"libtcc1.a\" \
-D CONFIG_TCC_STATIC=1 \
-D CONFIG_USE_LIBGCC=1 \
-D TCC_VERSION=\"0.9.27\" \
-D ONE_SOURCE=1 \
-D TCC_MUSL=1 \
-D CONFIG_TCC_PREDEFS=1 \
-D CONFIG_TCC_SEMLOCK=0 \
-B . \
-B ${stage1.musl.boot.package}/lib \
tcc.c
# libtcc1.a
rm -f libtcc1.a
./tcc-musl -c -D HAVE_CONFIG_H=1 lib/libtcc1.c
./tcc-musl -c -D HAVE_CONFIG_H=1 lib/alloca.S
./tcc-musl -ar cr libtcc1.a libtcc1.o alloca.o
# Install tcc \
install -D tcc-musl $out/bin/tcc -B ${stage1.tinycc.boot.libs.package}/lib \
install -Dm444 libtcc1.a $out/lib/libtcc1.a -DC2STR \
''; -o c2str \
conftest.c
./c2str include/tccdefs.h tccdefs_.h
tcc -v \
-static \
-o tcc-musl \
-D TCC_TARGET_I386=1 \
-D CONFIG_TCCDIR=\"\" \
-D CONFIG_TCC_CRTPREFIX=\"{B}\" \
-D CONFIG_TCC_ELFINTERP=\"/musl/loader\" \
-D CONFIG_TCC_LIBPATHS=\"{B}\" \
-D CONFIG_TCC_SYSINCLUDEPATHS=\"${stage1.musl.boot.package}/include\" \
-D TCC_LIBGCC=\"libc.a\" \
-D TCC_LIBTCC1=\"libtcc1.a\" \
-D CONFIG_TCC_STATIC=1 \
-D CONFIG_USE_LIBGCC=1 \
-D TCC_VERSION=\"0.9.27\" \
-D ONE_SOURCE=1 \
-D TCC_MUSL=1 \
-D CONFIG_TCC_PREDEFS=1 \
-D CONFIG_TCC_SEMLOCK=0 \
-B . \
-B ${stage1.tinycc.boot.libs.package}/lib \
tcc.c
# libtcc1.a
rm -f libtcc1.a
tcc -c -D HAVE_CONFIG_H=1 lib/libtcc1.c
tcc -ar cr libtcc1.a libtcc1.o
# Rebuild tcc-musl with itself
./tcc-musl \
-v \
-static \
-o tcc-musl \
-D TCC_TARGET_I386=1 \
-D CONFIG_TCCDIR=\"\" \
-D CONFIG_TCC_CRTPREFIX=\"{B}\" \
-D CONFIG_TCC_ELFINTERP=\"/musl/loader\" \
-D CONFIG_TCC_LIBPATHS=\"{B}\" \
-D CONFIG_TCC_SYSINCLUDEPATHS=\"${stage1.musl.boot.package}/include\" \
-D TCC_LIBGCC=\"libc.a\" \
-D TCC_LIBTCC1=\"libtcc1.a\" \
-D CONFIG_TCC_STATIC=1 \
-D CONFIG_USE_LIBGCC=1 \
-D TCC_VERSION=\"0.9.27\" \
-D ONE_SOURCE=1 \
-D TCC_MUSL=1 \
-D CONFIG_TCC_PREDEFS=1 \
-D CONFIG_TCC_SEMLOCK=0 \
-B . \
-B ${stage1.musl.boot.package}/lib \
tcc.c
# libtcc1.a
rm -f libtcc1.a
./tcc-musl -c -D HAVE_CONFIG_H=1 lib/libtcc1.c
./tcc-musl -c -D HAVE_CONFIG_H=1 lib/alloca.S
./tcc-musl -ar cr libtcc1.a libtcc1.o alloca.o
# Install
install -D tcc-musl $out/bin/tcc
install -Dm444 libtcc1.a $out/lib/libtcc1.a
'';
};
in
{
revision = "fd6d2180c5c801bb0b4c5dde27d61503059fc97d";
src = builtins.fetchurl {
url = "https://repo.or.cz/tinycc.git/snapshot/${cfg.revision}.tar.gz";
sha256 = "R81SNbEmh4s9FNQxCWZwUiMCYRkkwOHAdRf0aMnnRiA=";
};
compiler.package = builders.bash.boot.build {
name = "${pname}-${stage1.tinycc.version}-compiler";
meta = stage1.tinycc.meta;
script = ''
install -D ${tinycc-musl}/bin/tcc $out/bin/tcc
'';
};
libs.package = builders.bash.boot.build {
name = "${pname}-${stage1.tinycc.version}-libs";
meta = stage1.tinycc.meta;
script = ''
mkdir $out
cp -r ${stage1.musl.boot.package}/* $out
chmod +w $out/lib/libtcc1.a
cp ${tinycc-musl}/lib/libtcc1.a $out/lib/libtcc1.a
'';
};
}; };
in {
revision = "fd6d2180c5c801bb0b4c5dde27d61503059fc97d";
src = builtins.fetchurl {
url = "https://repo.or.cz/tinycc.git/snapshot/${cfg.revision}.tar.gz";
sha256 = "R81SNbEmh4s9FNQxCWZwUiMCYRkkwOHAdRf0aMnnRiA=";
};
compiler.package = builders.bash.boot.build {
name = "${pname}-${stage1.tinycc.version}-compiler";
meta = stage1.tinycc.meta;
script = ''
install -D ${tinycc-musl}/bin/tcc $out/bin/tcc
'';
};
libs.package = builders.bash.boot.build {
name = "${pname}-${stage1.tinycc.version}-libs";
meta = stage1.tinycc.meta;
script = ''
mkdir $out
cp -r ${stage1.musl.boot.package}/* $out
chmod +w $out/lib/libtcc1.a
cp ${tinycc-musl}/lib/libtcc1.a $out/lib/libtcc1.a
'';
};
};
}; };
} }

View file

@ -1,14 +1,13 @@
{ { lib, config }:
lib, let
config,
}: let
cfg = config.aux.foundation.stages.stage1.xz; cfg = config.aux.foundation.stages.stage1.xz;
platform = config.aux.platform; platform = config.aux.platform;
builders = config.aux.foundation.builders; builders = config.aux.foundation.builders;
stage1 = config.aux.foundation.stages.stage1; stage1 = config.aux.foundation.stages.stage1;
in { in
{
options.aux.foundation.stages.stage1.xz = { options.aux.foundation.stages.stage1.xz = {
meta = { meta = {
description = lib.options.create { description = lib.options.create {
@ -36,7 +35,7 @@ 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" ];
}; };
}; };

View file

@ -1,14 +1,13 @@
{ { lib, config }:
lib, let
config,
}: let
cfg = config.aux.foundation.stages.stage1.zlib; cfg = config.aux.foundation.stages.stage1.zlib;
platform = config.aux.platform; platform = config.aux.platform;
builders = config.aux.foundation.builders; builders = config.aux.foundation.builders;
stage1 = config.aux.foundation.stages.stage1; stage1 = config.aux.foundation.stages.stage1;
in { in
{
options.aux.foundation.stages.stage1.zlib = { options.aux.foundation.stages.stage1.zlib = {
meta = { meta = {
description = lib.options.create { description = lib.options.create {
@ -33,7 +32,7 @@ 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" ];
}; };
}; };

View file

@ -1,14 +1,13 @@
{ { lib, config }:
lib, let
config,
}: let
cfg = config.aux.foundation.stages.stage2.bash; cfg = config.aux.foundation.stages.stage2.bash;
platform = config.aux.platform; platform = config.aux.platform;
builders = config.aux.foundation.builders; builders = config.aux.foundation.builders;
stage1 = config.aux.foundation.stages.stage1; stage1 = config.aux.foundation.stages.stage1;
in { in
{
options.aux.foundation.stages.stage2.bash = { options.aux.foundation.stages.stage2.bash = {
meta = { meta = {
description = lib.options.create { description = lib.options.create {
@ -33,7 +32,7 @@ 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" ];
}; };
mainProgram = lib.options.create { mainProgram = lib.options.create {

View file

@ -1,14 +1,13 @@
{ { lib, config }:
lib, let
config,
}: let
cfg = config.aux.foundation.stages.stage2.binutils; cfg = config.aux.foundation.stages.stage2.binutils;
platform = config.aux.platform; platform = config.aux.platform;
builders = config.aux.foundation.builders; builders = config.aux.foundation.builders;
stage1 = config.aux.foundation.stages.stage1; stage1 = config.aux.foundation.stages.stage1;
in { in
{
options.aux.foundation.stages.stage2.binutils = { options.aux.foundation.stages.stage2.binutils = {
meta = { meta = {
description = lib.options.create { description = lib.options.create {
@ -33,7 +32,7 @@ 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" ];
}; };
}; };
@ -62,35 +61,36 @@ in {
sha256 = "rppXieI0WeWWBuZxRyPy0//DHAMXQZHvDQFb3wYAdFA="; sha256 = "rppXieI0WeWWBuZxRyPy0//DHAMXQZHvDQFb3wYAdFA=";
}; };
package = let package =
patches = [ let
# Make binutils output deterministic by default. patches = [
./patches/deterministic.patch # Make binutils output deterministic by default.
]; ./patches/deterministic.patch
];
configureFlags = [ configureFlags = [
"CC=musl-gcc" "CC=musl-gcc"
"LDFLAGS=--static" "LDFLAGS=--static"
"--prefix=${builtins.placeholder "out"}" "--prefix=${builtins.placeholder "out"}"
"--build=${platform.build}" "--build=${platform.build}"
"--host=${platform.host}" "--host=${platform.host}"
"--with-sysroot=/" "--with-sysroot=/"
"--enable-deterministic-archives" "--enable-deterministic-archives"
# depends on bison # depends on bison
"--disable-gprofng" "--disable-gprofng"
# Turn on --enable-new-dtags by default to make the linker set # Turn on --enable-new-dtags by default to make the linker set
# RUNPATH instead of RPATH on binaries. This is important because # RUNPATH instead of RPATH on binaries. This is important because
# RUNPATH can be overridden using LD_LIBRARY_PATH at runtime. # RUNPATH can be overridden using LD_LIBRARY_PATH at runtime.
"--enable-new-dtags" "--enable-new-dtags"
# By default binutils searches $libdir for libraries. This brings in # By default binutils searches $libdir for libraries. This brings in
# libbfd and libopcodes into a default visibility. Drop default lib # libbfd and libopcodes into a default visibility. Drop default lib
# path to force users to declare their use of these libraries. # path to force users to declare their use of these libraries.
"--with-lib-path=:" "--with-lib-path=:"
]; ];
in in
builders.bash.build { builders.bash.build {
name = "binutils-static-${cfg.version}"; name = "binutils-static-${cfg.version}";

View file

@ -1,7 +1,5 @@
{ { lib, config }:
lib, let
config,
}: let
cfg = config.aux.foundation.stages.stage2.busybox; cfg = config.aux.foundation.stages.stage2.busybox;
platform = config.aux.platform; platform = config.aux.platform;
@ -9,7 +7,8 @@
stage1 = config.aux.foundation.stages.stage1; stage1 = config.aux.foundation.stages.stage1;
stage2 = config.aux.foundation.stages.stage2; stage2 = config.aux.foundation.stages.stage2;
in { in
{
options.aux.foundation.stages.stage2.busybox = { options.aux.foundation.stages.stage2.busybox = {
meta = { meta = {
description = lib.options.create { description = lib.options.create {
@ -34,7 +33,7 @@ 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" ];
}; };
}; };
@ -63,20 +62,19 @@ in {
sha256 = "uMwkyVdNgJ5yecO+NJeVxdXOtv3xnKcJ+AzeUOR94xQ="; sha256 = "uMwkyVdNgJ5yecO+NJeVxdXOtv3xnKcJ+AzeUOR94xQ=";
}; };
package = let package =
patches = [ let
./patches/busybox-in-store.patch patches = [ ./patches/busybox-in-store.patch ];
];
busyboxConfig = [ busyboxConfig = [
"CC=musl-gcc" "CC=musl-gcc"
"HOSTCC=musl-gcc" "HOSTCC=musl-gcc"
"CFLAGS=-I${stage1.linux-headers.package}/include" "CFLAGS=-I${stage1.linux-headers.package}/include"
"KCONFIG_NOTIMESTAMP=y" "KCONFIG_NOTIMESTAMP=y"
"CONFIG_PREFIX=${builtins.placeholder "out"}" "CONFIG_PREFIX=${builtins.placeholder "out"}"
"CONFIG_STATIC=y" "CONFIG_STATIC=y"
]; ];
in in
builders.bash.build { builders.bash.build {
name = "busybox-static-${cfg.version}"; name = "busybox-static-${cfg.version}";
meta = cfg.meta; meta = cfg.meta;

View file

@ -1,14 +1,13 @@
{ { lib, config }:
lib, let
config,
}: let
cfg = config.aux.foundation.stages.stage2.bzip2; cfg = config.aux.foundation.stages.stage2.bzip2;
platform = config.aux.platform; platform = config.aux.platform;
builders = config.aux.foundation.builders; builders = config.aux.foundation.builders;
stage1 = config.aux.foundation.stages.stage1; stage1 = config.aux.foundation.stages.stage1;
in { in
{
options.aux.foundation.stages.stage2.bzip2 = { options.aux.foundation.stages.stage2.bzip2 = {
meta = { meta = {
description = lib.options.create { description = lib.options.create {
@ -34,7 +33,7 @@ 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" ];
}; };
}; };

View file

@ -1,14 +1,13 @@
{ { lib, config }:
lib, let
config,
}: let
cfg = config.aux.foundation.stages.stage2.coreutils; cfg = config.aux.foundation.stages.stage2.coreutils;
platform = config.aux.platform; platform = config.aux.platform;
builders = config.aux.foundation.builders; builders = config.aux.foundation.builders;
stage1 = config.aux.foundation.stages.stage1; stage1 = config.aux.foundation.stages.stage1;
in { in
{
options.aux.foundation.stages.stage2.coreutils = { options.aux.foundation.stages.stage2.coreutils = {
meta = { meta = {
description = lib.options.create { description = lib.options.create {
@ -33,7 +32,7 @@ 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" ];
}; };
}; };
@ -62,18 +61,19 @@ in {
sha256 = "X2ANkJOXOwr+JTk9m8GMRPIjJlf0yg2V6jHHAutmtzk="; sha256 = "X2ANkJOXOwr+JTk9m8GMRPIjJlf0yg2V6jHHAutmtzk=";
}; };
package = let package =
configureFlags = [ let
"--prefix=${builtins.placeholder "out"}" configureFlags = [
"--build=${platform.build}" "--prefix=${builtins.placeholder "out"}"
"--host=${platform.host}" "--build=${platform.build}"
# libstdbuf.so fails in static builds "--host=${platform.host}"
"--enable-no-install-program=stdbuf" # libstdbuf.so fails in static builds
"--enable-single-binary=symlinks" "--enable-no-install-program=stdbuf"
"CC=musl-gcc" "--enable-single-binary=symlinks"
"CFLAGS=-static" "CC=musl-gcc"
]; "CFLAGS=-static"
in ];
in
builders.bash.build { builders.bash.build {
name = "coreutils-${cfg.version}"; name = "coreutils-${cfg.version}";

View file

@ -1,9 +1,8 @@
{ { lib, config }:
lib, let
config,
}: let
stage2 = config.aux.foundation.stages.stage2; stage2 = config.aux.foundation.stages.stage2;
in { in
{
includes = [ includes = [
./bash ./bash
./binutils ./binutils

View file

@ -1,14 +1,13 @@
{ { lib, config }:
lib, let
config,
}: let
cfg = config.aux.foundation.stages.stage2.diffutils; cfg = config.aux.foundation.stages.stage2.diffutils;
platform = config.aux.platform; platform = config.aux.platform;
builders = config.aux.foundation.builders; builders = config.aux.foundation.builders;
stage1 = config.aux.foundation.stages.stage1; stage1 = config.aux.foundation.stages.stage1;
in { in
{
options.aux.foundation.stages.stage2.diffutils = { options.aux.foundation.stages.stage2.diffutils = {
meta = { meta = {
description = lib.options.create { description = lib.options.create {
@ -33,7 +32,7 @@ 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" ];
}; };
}; };

View file

@ -1,14 +1,13 @@
{ { lib, config }:
lib, let
config,
}: let
cfg = config.aux.foundation.stages.stage2.findutils; cfg = config.aux.foundation.stages.stage2.findutils;
platform = config.aux.platform; platform = config.aux.platform;
builders = config.aux.foundation.builders; builders = config.aux.foundation.builders;
stage1 = config.aux.foundation.stages.stage1; stage1 = config.aux.foundation.stages.stage1;
in { in
{
options.aux.foundation.stages.stage2.findutils = { options.aux.foundation.stages.stage2.findutils = {
meta = { meta = {
description = lib.options.create { description = lib.options.create {
@ -33,7 +32,7 @@ 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" ];
}; };
}; };

View file

@ -1,14 +1,13 @@
{ { lib, config }:
lib, let
config,
}: let
cfg = config.aux.foundation.stages.stage2.gawk; cfg = config.aux.foundation.stages.stage2.gawk;
platform = config.aux.platform; platform = config.aux.platform;
builders = config.aux.foundation.builders; builders = config.aux.foundation.builders;
stage1 = config.aux.foundation.stages.stage1; stage1 = config.aux.foundation.stages.stage1;
in { in
{
options.aux.foundation.stages.stage2.gawk = { options.aux.foundation.stages.stage2.gawk = {
meta = { meta = {
description = lib.options.create { description = lib.options.create {
@ -33,7 +32,7 @@ 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" ];
}; };
mainProgram = lib.options.create { mainProgram = lib.options.create {

View file

@ -1,14 +1,13 @@
{ { lib, config }:
lib, let
config,
}: let
cfg = config.aux.foundation.stages.stage2.gcc; cfg = config.aux.foundation.stages.stage2.gcc;
platform = config.aux.platform; platform = config.aux.platform;
builders = config.aux.foundation.builders; builders = config.aux.foundation.builders;
stage1 = config.aux.foundation.stages.stage1; stage1 = config.aux.foundation.stages.stage1;
in { in
{
options.aux.foundation.stages.stage2.gcc = { options.aux.foundation.stages.stage2.gcc = {
meta = { meta = {
description = lib.options.create { description = lib.options.create {
@ -33,7 +32,7 @@ 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" ];
}; };
}; };

View file

@ -1,7 +1,5 @@
{ { lib, config }:
lib, let
config,
}: let
cfg = config.aux.foundation.stages.stage2.glibc; cfg = config.aux.foundation.stages.stage2.glibc;
platform = config.aux.platform; platform = config.aux.platform;
@ -9,7 +7,8 @@
stage1 = config.aux.foundation.stages.stage1; stage1 = config.aux.foundation.stages.stage1;
stage2 = config.aux.foundation.stages.stage2; stage2 = config.aux.foundation.stages.stage2;
in { in
{
options.aux.foundation.stages.stage2.glibc = { options.aux.foundation.stages.stage2.glibc = {
meta = { meta = {
description = lib.options.create { description = lib.options.create {
@ -34,7 +33,7 @@ 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" ];
}; };
}; };

View file

@ -1,14 +1,13 @@
{ { lib, config }:
lib, let
config,
}: let
cfg = config.aux.foundation.stages.stage2.gnugrep; cfg = config.aux.foundation.stages.stage2.gnugrep;
platform = config.aux.platform; platform = config.aux.platform;
builders = config.aux.foundation.builders; builders = config.aux.foundation.builders;
stage1 = config.aux.foundation.stages.stage1; stage1 = config.aux.foundation.stages.stage1;
in { in
{
options.aux.foundation.stages.stage2.gnugrep = { options.aux.foundation.stages.stage2.gnugrep = {
meta = { meta = {
description = lib.options.create { description = lib.options.create {
@ -33,7 +32,7 @@ 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" ];
}; };
mainProgram = lib.options.create { mainProgram = lib.options.create {

View file

@ -1,7 +1,5 @@
{ { lib, config }:
lib, let
config,
}: let
cfg = config.aux.foundation.stages.stage2.gnumake; cfg = config.aux.foundation.stages.stage2.gnumake;
platform = config.aux.platform; platform = config.aux.platform;
@ -9,7 +7,8 @@
stage1 = config.aux.foundation.stages.stage1; stage1 = config.aux.foundation.stages.stage1;
stage2 = config.aux.foundation.stages.stage2; stage2 = config.aux.foundation.stages.stage2;
in { in
{
options.aux.foundation.stages.stage2.gnumake = { options.aux.foundation.stages.stage2.gnumake = {
meta = { meta = {
description = lib.options.create { description = lib.options.create {
@ -34,7 +33,7 @@ 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" ];
}; };
}; };
@ -63,16 +62,17 @@ in {
sha256 = "3Rb7HWe/q3mnL16DkHNcSePo5wtJRaFasfgd23hlj7M="; sha256 = "3Rb7HWe/q3mnL16DkHNcSePo5wtJRaFasfgd23hlj7M=";
}; };
package = let package =
patches = [ let
# Replaces /bin/sh with sh, see patch file for reasoning patches = [
./patches/0001-No-impure-bin-sh.patch # Replaces /bin/sh with sh, see patch file for reasoning
# Purity: don't look for library dependencies (of the form `-lfoo') in /lib ./patches/0001-No-impure-bin-sh.patch
# and /usr/lib. It's a stupid feature anyway. Likewise, when searching for # Purity: don't look for library dependencies (of the form `-lfoo') in /lib
# included Makefiles, don't look in /usr/include and friends. # and /usr/lib. It's a stupid feature anyway. Likewise, when searching for
./patches/0002-remove-impure-dirs.patch # included Makefiles, don't look in /usr/include and friends.
]; ./patches/0002-remove-impure-dirs.patch
in ];
in
builders.bash.boot.build { builders.bash.boot.build {
name = "gnumake-static-${cfg.version}"; name = "gnumake-static-${cfg.version}";

View file

@ -1,14 +1,13 @@
{ { lib, config }:
lib, let
config,
}: let
cfg = config.aux.foundation.stages.stage2.gnupatch; cfg = config.aux.foundation.stages.stage2.gnupatch;
platform = config.aux.platform; platform = config.aux.platform;
builders = config.aux.foundation.builders; builders = config.aux.foundation.builders;
stage1 = config.aux.foundation.stages.stage1; stage1 = config.aux.foundation.stages.stage1;
in { in
{
options.aux.foundation.stages.stage2.gnupatch = { options.aux.foundation.stages.stage2.gnupatch = {
meta = { meta = {
description = lib.options.create { description = lib.options.create {
@ -33,7 +32,7 @@ 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" ];
}; };
}; };

View file

@ -1,14 +1,13 @@
{ { lib, config }:
lib, let
config,
}: let
cfg = config.aux.foundation.stages.stage2.gnused; cfg = config.aux.foundation.stages.stage2.gnused;
platform = config.aux.platform; platform = config.aux.platform;
builders = config.aux.foundation.builders; builders = config.aux.foundation.builders;
stage1 = config.aux.foundation.stages.stage1; stage1 = config.aux.foundation.stages.stage1;
in { in
{
options.aux.foundation.stages.stage2.gnused = { options.aux.foundation.stages.stage2.gnused = {
meta = { meta = {
description = lib.options.create { description = lib.options.create {
@ -33,7 +32,7 @@ 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" ];
}; };
mainProgram = lib.options.create { mainProgram = lib.options.create {

View file

@ -1,14 +1,13 @@
{ { lib, config }:
lib, let
config,
}: let
cfg = config.aux.foundation.stages.stage2.gnutar; cfg = config.aux.foundation.stages.stage2.gnutar;
platform = config.aux.platform; platform = config.aux.platform;
builders = config.aux.foundation.builders; builders = config.aux.foundation.builders;
stage1 = config.aux.foundation.stages.stage1; stage1 = config.aux.foundation.stages.stage1;
in { in
{
options.aux.foundation.stages.stage2.gnutar = { options.aux.foundation.stages.stage2.gnutar = {
meta = { meta = {
description = lib.options.create { description = lib.options.create {
@ -33,7 +32,7 @@ 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" ];
}; };
mainProgram = lib.options.create { mainProgram = lib.options.create {

View file

@ -1,14 +1,13 @@
{ { lib, config }:
lib, let
config,
}: let
cfg = config.aux.foundation.stages.stage2.gzip; cfg = config.aux.foundation.stages.stage2.gzip;
platform = config.aux.platform; platform = config.aux.platform;
builders = config.aux.foundation.builders; builders = config.aux.foundation.builders;
stage1 = config.aux.foundation.stages.stage1; stage1 = config.aux.foundation.stages.stage1;
in { in
{
options.aux.foundation.stages.stage2.gzip = { options.aux.foundation.stages.stage2.gzip = {
meta = { meta = {
description = lib.options.create { description = lib.options.create {
@ -33,7 +32,7 @@ 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" ];
}; };
}; };

View file

@ -1,7 +1,5 @@
{ { lib, config }:
lib, let
config,
}: let
cfg = config.aux.foundation.stages.stage2.patchelf; cfg = config.aux.foundation.stages.stage2.patchelf;
platform = config.aux.platform; platform = config.aux.platform;
@ -9,7 +7,8 @@
stage1 = config.aux.foundation.stages.stage1; stage1 = config.aux.foundation.stages.stage1;
stage2 = config.aux.foundation.stages.stage2; stage2 = config.aux.foundation.stages.stage2;
in { in
{
options.aux.foundation.stages.stage2.patchelf = { options.aux.foundation.stages.stage2.patchelf = {
meta = { meta = {
description = lib.options.create { description = lib.options.create {
@ -34,7 +33,7 @@ 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" ];
}; };
}; };

View file

@ -1,4 +1,5 @@
{lib}: { { lib }:
{
options.aux = { options.aux = {
system = lib.options.create { system = lib.options.create {
type = lib.types.string; type = lib.types.string;

View file

@ -10,185 +10,205 @@ lib: {
## from `y` first if it exists and then `x` otherwise. ## from `y` first if it exists and then `x` otherwise.
## ##
## @type Attrs a b c => (String -> Any -> Any -> Bool) -> a -> b -> c ## @type Attrs a b c => (String -> Any -> Any -> Bool) -> a -> b -> c
mergeRecursiveUntil = predicate: x: y: let mergeRecursiveUntil =
process = path: predicate: x: y:
builtins.zipAttrsWith ( let
name: values: let process =
currentPath = path ++ [name]; path:
isSingleValue = builtins.length values == 1; builtins.zipAttrsWith (
isComplete = name: values:
predicate currentPath let
(builtins.elemAt values 1) currentPath = path ++ [ name ];
(builtins.elemAt values 0); isSingleValue = builtins.length values == 1;
in isComplete = predicate currentPath (builtins.elemAt values 1) (builtins.elemAt values 0);
if isSingleValue in
then builtins.elemAt values 0 if isSingleValue then
else if isComplete builtins.elemAt values 0
then builtins.elemAt values 1 else if isComplete then
else process currentPath values builtins.elemAt values 1
); else
in process currentPath values
process [] [x y]; );
in
process [ ] [
x
y
];
## Merge two attribute sets recursively. Any values that are _not_ attribute sets ## Merge two attribute sets recursively. Any values that are _not_ attribute sets
## will be overridden with the value from `y` first if it exists and then `x` ## will be overridden with the value from `y` first if it exists and then `x`
## otherwise. ## otherwise.
## ##
## @type Attrs a b c => a -> b -> c ## @type Attrs a b c => a -> b -> c
mergeRecursive = mergeRecursive = lib.attrs.mergeRecursiveUntil (
lib.attrs.mergeRecursiveUntil path: x: y:
(path: x: y: !(builtins.isAttrs x && builtins.isAttrs y)
!(builtins.isAttrs x && builtins.isAttrs y)); );
## Get a value from an attribute set by a path. If the path does not exist, ## Get a value from an attribute set by a path. If the path does not exist,
## a fallback value will be returned instead. ## a fallback value will be returned instead.
## ##
## @type (List String) -> a -> Attrs -> a | b ## @type (List String) -> a -> Attrs -> a | b
select = path: fallback: target: let select =
name = builtins.head path; path: fallback: target:
rest = builtins.tail path; let
in name = builtins.head path;
if path == [] rest = builtins.tail path;
then target in
else if target ? ${name} if path == [ ] then
then lib.attrs.select rest fallback target.${name} target
else fallback; else if target ? ${name} then
lib.attrs.select rest fallback target.${name}
else
fallback;
## Get a value from an attribute set by a path. If the path does not exist, ## Get a value from an attribute set by a path. If the path does not exist,
## an error will be thrown. ## an error will be thrown.
## ##
## @type (List String) -> Attrs -> a ## @type (List String) -> Attrs -> a
selectOrThrow = path: target: let selectOrThrow =
pathAsString = builtins.concatStringsSep "." path; path: target:
error = builtins.throw "Path not found in attribute set: ${pathAsString}"; let
in pathAsString = builtins.concatStringsSep "." path;
if lib.attrs.has path target error = builtins.throw "Path not found in attribute set: ${pathAsString}";
then lib.attrs.select path null target in
else error; if lib.attrs.has path target then lib.attrs.select path null target else error;
## Zip specific attributes from a list of attribute sets. ## Zip specific attributes from a list of attribute sets.
## ##
## @type List String -> (List Any -> Any) -> List Attrs -> Attrs ## @type List String -> (List Any -> Any) -> List Attrs -> Attrs
zipWithNames = names: f: list: let zipWithNames =
transform = name: { names: f: list:
inherit name; let
value = f name (builtins.catAttrs name list); transform = name: {
}; inherit name;
results = builtins.map transform names; value = f name (builtins.catAttrs name list);
in };
results = builtins.map transform names;
in
builtins.listToAttrs results; builtins.listToAttrs results;
## Match an attribute set against a pattern. ## Match an attribute set against a pattern.
## ##
## @type Attrs -> Attrs -> Bool ## @type Attrs -> Attrs -> Bool
match = pattern: value: let match =
process = name: values: let pattern: value:
first = builtins.elemAt values 0; let
second = builtins.elemAt values 1; process =
in name: values:
if builtins.length values == 1 let
then false first = builtins.elemAt values 0;
else if builtins.isAttrs first second = builtins.elemAt values 1;
then builtins.isAttrs second && lib.attrs.match first second in
else first == second; if builtins.length values == 1 then
false
else if builtins.isAttrs first then
builtins.isAttrs second && lib.attrs.match first second
else
first == second;
result = lib.attrs.zipWithNames (builtins.attrNames pattern) process [pattern value]; result = lib.attrs.zipWithNames (builtins.attrNames pattern) process [
in pattern
value
];
in
assert lib.errors.trace (builtins.isAttrs pattern) "Pattern must be an attribute set"; assert lib.errors.trace (builtins.isAttrs pattern) "Pattern must be an attribute set";
assert lib.errors.trace (builtins.isAttrs value) "Value must be an attribute set"; assert lib.errors.trace (builtins.isAttrs value) "Value must be an attribute set";
builtins.all lib.fp.id (builtins.attrValues result); builtins.all lib.fp.id (builtins.attrValues result);
## Create a nested attribute set with a value as the leaf node. ## Create a nested attribute set with a value as the leaf node.
## ##
## @type (List String) -> a -> Attrs ## @type (List String) -> a -> Attrs
set = path: value: let set =
length = builtins.length path; path: value:
process = depth: let
if depth == length length = builtins.length path;
then value process =
else { depth: if depth == length then value else { ${builtins.elemAt path depth} = process (depth + 1); };
${builtins.elemAt path depth} = process (depth + 1); in
};
in
process 0; process 0;
## Check if a path exists in an attribute set. ## Check if a path exists in an attribute set.
## ##
## @type (List String) -> Attrs -> Bool ## @type (List String) -> Attrs -> Bool
has = path: target: let has =
name = builtins.head path; path: target:
rest = builtins.tail path; let
in name = builtins.head path;
if path == [] rest = builtins.tail path;
then true in
else if target ? ${name} if path == [ ] then
then lib.attrs.has rest target.${name} true
else false; else if target ? ${name} then
lib.attrs.has rest target.${name}
else
false;
## Depending on a given condition, either use the given value or an empty ## Depending on a given condition, either use the given value or an empty
## attribute set. ## attribute set.
## ##
## @type Attrs a b => Bool -> a -> a | b ## @type Attrs a b => Bool -> a -> a | b
when = condition: value: when = condition: value: if condition then value else { };
if condition
then value
else {};
## Map an attribute set's names and values to a list. ## Map an attribute set's names and values to a list.
## ##
## @type Any a => (String -> Any -> a) -> Attrs -> List a ## @type Any a => (String -> Any -> a) -> Attrs -> List a
mapToList = f: target: mapToList = f: target: builtins.map (name: f name target.${name}) (builtins.attrNames target);
builtins.map (name: f name target.${name}) (builtins.attrNames target);
## Map an attribute set recursively. Only non-set leaf nodes will be mapped. ## Map an attribute set recursively. Only non-set leaf nodes will be mapped.
## ##
## @type (List String -> Any -> Any) -> Attrs -> Attrs ## @type (List String -> Any -> Any) -> Attrs -> Attrs
mapRecursive = f: target: mapRecursive = f: target: lib.attrs.mapRecursiveWhen (lib.fp.const true) f target;
lib.attrs.mapRecursiveWhen (lib.fp.const true) f target;
## Map an attribute set recursively when a given predicate returns true. ## Map an attribute set recursively when a given predicate returns true.
## Only leaf nodes according to the predicate will be mapped. ## Only leaf nodes according to the predicate will be mapped.
## ##
## @type (Attrs -> Bool) -> (List String -> Any -> Any) -> Attrs -> Attrs ## @type (Attrs -> Bool) -> (List String -> Any -> Any) -> Attrs -> Attrs
mapRecursiveWhen = predicate: f: target: let mapRecursiveWhen =
process = path: predicate: f: target:
builtins.mapAttrs ( let
name: value: process =
if builtins.isAttrs value && predicate value path:
then process (path ++ [name]) value builtins.mapAttrs (
else f (path ++ [name]) value name: value:
); if builtins.isAttrs value && predicate value then
in process (path ++ [ name ]) value
process [] target; else
f (path ++ [ name ]) value
);
in
process [ ] target;
## Filter an attribute set by a given predicate. The filter is only performed ## Filter an attribute set by a given predicate. The filter is only performed
## on the base level of the attribute set. ## on the base level of the attribute set.
## ##
## @type (String -> Any -> Bool) -> Attrs -> Attrs ## @type (String -> Any -> Bool) -> Attrs -> Attrs
filter = predicate: target: let filter =
names = builtins.attrNames target; predicate: target:
process = name: let let
value = target.${name}; names = builtins.attrNames target;
process =
name:
let
value = target.${name};
in
if predicate name value then [ { inherit name value; } ] else [ ];
valid = builtins.concatMap process names;
in in
if predicate name value
then [{inherit name value;}]
else [];
valid = builtins.concatMap process names;
in
builtins.listToAttrs valid; builtins.listToAttrs valid;
## Generate an attribute set from a list of names and a function that is ## Generate an attribute set from a list of names and a function that is
## applied to each name. ## applied to each name.
## ##
## @type (List String) -> (String -> Any) -> Attrs ## @type (List String) -> (String -> Any) -> Attrs
generate = names: f: let generate =
pairs = names: f:
builtins.map (name: { let
pairs = builtins.map (name: {
inherit name; inherit name;
value = f name; value = f name;
}) }) names;
names; in
in
builtins.listToAttrs pairs; builtins.listToAttrs pairs;
}; };
} }

View file

@ -1,329 +1,342 @@
let let
lib = import ./../default.nix; lib = import ./../default.nix;
in { in
{
"merge" = { "merge" = {
"merges two shallow sets" = let "merges two shallow sets" =
expected = { let
x = 1; expected = {
y = 2; x = 1;
}; y = 2;
};
actual = lib.attrs.merge {x = 1;} {y = 2;}; actual = lib.attrs.merge { x = 1; } { y = 2; };
in in
expected == actual; expected == actual;
"overwrites values from the first set" = let "overwrites values from the first set" =
expected = { let
x = 2; expected = {
}; x = 2;
actual = lib.attrs.merge {x = 1;} {x = 2;}; };
in actual = lib.attrs.merge { x = 1; } { x = 2; };
in
actual == expected; actual == expected;
"does not merge nested sets" = let "does not merge nested sets" =
expected = { let
x.y = 2; expected = {
}; x.y = 2;
actual = lib.attrs.merge {x.z = 1;} {x.y = 2;}; };
in actual = lib.attrs.merge { x.z = 1; } { x.y = 2; };
in
actual == expected; actual == expected;
}; };
"mergeRecursiveUntil" = { "mergeRecursiveUntil" = {
"merges with predicate" = let "merges with predicate" =
expected = { let
x.y.z = 1; expected = {
}; x.y.z = 1;
actual = };
lib.attrs.mergeRecursiveUntil actual = lib.attrs.mergeRecursiveUntil (
(path: x: y: lib.lists.last path == "z") path: x: y:
{x.y.z = 2;} lib.lists.last path == "z"
{x.y.z = 1;}; ) { x.y.z = 2; } { x.y.z = 1; };
in in
actual == expected; actual == expected;
"handles shallow merges" = let "handles shallow merges" =
expected = { let
x.y.z = 1; expected = {
}; x.y.z = 1;
actual = };
lib.attrs.mergeRecursiveUntil actual =
(path: x: y: true) lib.attrs.mergeRecursiveUntil
{ (
x = { path: x: y:
y.z = 2; true
)
{
x = {
y.z = 2;
a = false; a = false;
}; };
} }
{x.y.z = 1;}; { x.y.z = 1; };
in in
actual == expected; actual == expected;
}; };
"mergeRecursive" = { "mergeRecursive" = {
"merges two sets deeply" = let "merges two sets deeply" =
expected = { let
x.y.z = 1; expected = {
}; x.y.z = 1;
actual = };
lib.attrs.mergeRecursive actual = lib.attrs.mergeRecursive { x.y.z = 2; } { x.y.z = 1; };
{x.y.z = 2;} in
{x.y.z = 1;};
in
actual == expected; actual == expected;
}; };
"select" = { "select" = {
"selects a nested value" = let "selects a nested value" =
expected = "value"; let
actual = expected = "value";
lib.attrs.select actual = lib.attrs.select [
["x" "y" "z"] "x"
null "y"
{ "z"
x.y.z = expected; ] null { x.y.z = expected; };
}; in
in
actual == expected; actual == expected;
"handles empty path" = let "handles empty path" =
expected = { let
x = { expected = {
y = {
z = 1;
};
};
};
actual =
lib.attrs.select
[]
null
{
x = { x = {
y = { y = {
z = 1; z = 1;
}; };
}; };
}; };
in actual = lib.attrs.select [ ] null {
x = {
y = {
z = 1;
};
};
};
in
actual == expected; actual == expected;
"handles fallback value" = let "handles fallback value" =
expected = "fallback"; let
actual = expected = "fallback";
lib.attrs.select actual = lib.attrs.select [
["x" "y" "z"] "x"
expected "y"
{}; "z"
in ] expected { };
in
actual == expected; actual == expected;
}; };
"selectOrThrow" = { "selectOrThrow" = {
"selects a nested value" = let "selects a nested value" =
expected = "value"; let
actual = expected = "value";
lib.attrs.selectOrThrow actual = lib.attrs.selectOrThrow [
["x" "y" "z"] "x"
{ "y"
x.y.z = expected; "z"
}; ] { x.y.z = expected; };
in in
actual == expected; actual == expected;
"handles empty path" = let "handles empty path" =
expected = { let
x = { expected = {
y = {
z = 1;
};
};
};
actual =
lib.attrs.selectOrThrow
[]
{
x = { x = {
y = { y = {
z = 1; z = 1;
}; };
}; };
}; };
in actual = lib.attrs.selectOrThrow [ ] {
x = {
y = {
z = 1;
};
};
};
in
actual == expected; actual == expected;
"throws on nonexistent path" = let "throws on nonexistent path" =
actual = let
lib.attrs.selectOrThrow actual = lib.attrs.selectOrThrow [
["x" "y" "z"] "x"
{}; "y"
"z"
] { };
evaluated = builtins.tryEval (builtins.deepSeq actual actual); evaluated = builtins.tryEval (builtins.deepSeq actual actual);
in in
!evaluated.success; !evaluated.success;
}; };
"set" = { "set" = {
"creates a nested set" = let "creates a nested set" =
expected = { let
x = { expected = {
y = { x = {
z = 1; y = {
z = 1;
};
}; };
}; };
}; actual = lib.attrs.set [
actual = lib.attrs.set ["x" "y" "z"] 1; "x"
in "y"
"z"
] 1;
in
actual == expected; actual == expected;
"handles empty path" = let "handles empty path" =
expected = 1; let
actual = lib.attrs.set [] 1; expected = 1;
in actual = lib.attrs.set [ ] 1;
in
actual == expected; actual == expected;
}; };
"has" = { "has" = {
"returns true for a nested value" = let "returns true for a nested value" =
exists = lib.attrs.has ["x" "y" "z"] {x.y.z = 1;}; let
in exists = lib.attrs.has [
"x"
"y"
"z"
] { x.y.z = 1; };
in
exists; exists;
"returns false for a nonexistent value" = let "returns false for a nonexistent value" =
exists = lib.attrs.has ["x" "y" "z"] {}; let
in exists = lib.attrs.has [
"x"
"y"
"z"
] { };
in
!exists; !exists;
"handles empty path" = let "handles empty path" =
exists = lib.attrs.has [] {}; let
in exists = lib.attrs.has [ ] { };
in
exists; exists;
}; };
"when" = { "when" = {
"returns the value when condition is true" = let "returns the value when condition is true" =
expected = "value"; let
actual = lib.attrs.when true expected; expected = "value";
in actual = lib.attrs.when true expected;
in
actual == expected; actual == expected;
"returns an empty set when condition is false" = let "returns an empty set when condition is false" =
expected = {}; let
actual = lib.attrs.when false "value"; expected = { };
in actual = lib.attrs.when false "value";
in
actual == expected; actual == expected;
}; };
"mapToList" = { "mapToList" = {
"converts a set to a list" = let "converts a set to a list" =
expected = [ let
{ expected = [
name = "x"; {
value = 1; name = "x";
} value = 1;
{ }
name = "y"; {
value = 2; name = "y";
} value = 2;
]; }
actual = ];
lib.attrs.mapToList actual = lib.attrs.mapToList (name: value: { inherit name value; }) {
(name: value: {inherit name value;})
{
x = 1; x = 1;
y = 2; y = 2;
}; };
in in
actual == expected; actual == expected;
}; };
"mapRecursiveWhen" = { "mapRecursiveWhen" = {
"maps a set recursively" = let "maps a set recursively" =
expected = { let
x = { expected = {
y = { x = {
z = 2; y = {
z = 2;
};
}; };
}; };
}; actual = lib.attrs.mapRecursiveWhen (value: true) (path: value: value + 1) {
actual =
lib.attrs.mapRecursiveWhen
(value: true)
(path: value: value + 1)
{
x = { x = {
y = { y = {
z = 1; z = 1;
}; };
}; };
}; };
in in
actual == expected; actual == expected;
"maps a set given a condition" = let "maps a set given a condition" =
expected = { let
x = { expected = {
y = {
z = 1;
};
};
};
actual =
lib.attrs.mapRecursiveWhen
(value: !(value ? z))
(path: value:
# We map before we get to a non-set value
if builtins.isAttrs value
then value
else value + 1)
{
x = { x = {
y = { y = {
z = 1; z = 1;
}; };
}; };
}; };
in actual =
lib.attrs.mapRecursiveWhen (value: !(value ? z))
(
path: value:
# We map before we get to a non-set value
if builtins.isAttrs value then value else value + 1
)
{
x = {
y = {
z = 1;
};
};
};
in
actual == expected; actual == expected;
}; };
"mapRecursive" = { "mapRecursive" = {
"maps a set recursively" = let "maps a set recursively" =
expected = { let
x = { expected = {
y = { x = {
z = 2; y = {
z = 2;
};
}; };
}; };
}; actual = lib.attrs.mapRecursive (path: value: value + 1) {
actual =
lib.attrs.mapRecursive
(path: value: value + 1)
{
x = { x = {
y = { y = {
z = 1; z = 1;
}; };
}; };
}; };
in in
actual == expected; actual == expected;
}; };
"filter" = { "filter" = {
"filters a set" = let "filters a set" =
expected = { let
y = 2; expected = {
}; y = 2;
actual = };
lib.attrs.filter actual = lib.attrs.filter (name: value: name == "y") {
(name: value: name == "y")
{
x = 1; x = 1;
y = 2; y = 2;
}; };
in in
actual == expected; actual == expected;
}; };
} }

View file

@ -4,28 +4,21 @@ lib: {
## Convert a boolean value into a string. ## Convert a boolean value into a string.
## ##
## @type Bool -> String ## @type Bool -> String
string = value: string = value: if value then "true" else "false";
if value
then "true"
else "false";
## Convert a boolean into either the string "yes" or "no". ## Convert a boolean into either the string "yes" or "no".
## ##
## @type Bool -> String ## @type Bool -> String
yesno = value: yesno = value: if value then "yes" else "no";
if value
then "yes"
else "no";
}; };
## Choose between two values based on a condition. When true, the first value ## Choose between two values based on a condition. When true, the first value
## is returned, otherwise the second value is returned. ## is returned, otherwise the second value is returned.
## ##
## @type Bool -> a -> b -> a | b ## @type Bool -> a -> b -> a | b
when = condition: x: y: when =
if condition condition: x: y:
then x if condition then x else y;
else y;
## Perform a logical AND operation on two values. ## Perform a logical AND operation on two values.
## ##
@ -35,9 +28,7 @@ lib: {
## Perform a logical AND operation on two functions being applied to a value. ## Perform a logical AND operation on two functions being applied to a value.
## ##
## @type (a -> Bool) -> (a -> Bool) -> a -> Bool ## @type (a -> Bool) -> (a -> Bool) -> a -> Bool
and' = f: g: ( and' = f: g: (x: (f x) && (g x));
x: (f x) && (g x)
);
## Perform a logical OR operation on two values. ## Perform a logical OR operation on two values.
## ##
@ -47,9 +38,7 @@ lib: {
## Perform a logical OR operation on two functions being applied to a value. ## Perform a logical OR operation on two functions being applied to a value.
## ##
## @type (a -> Bool) -> (a -> Bool) -> a -> Bool ## @type (a -> Bool) -> (a -> Bool) -> a -> Bool
or' = f: g: ( or' = f: g: (x: (f x) || (g x));
x: (f x) || (g x)
);
## Perform a logical NOT operation on a value. ## Perform a logical NOT operation on a value.
## ##

View file

@ -1,161 +1,190 @@
let let
lib = import ./../default.nix; lib = import ./../default.nix;
in { in
{
"into" = { "into" = {
"string" = { "string" = {
"handles true" = let "handles true" =
expected = "true"; let
actual = lib.bools.into.string true; expected = "true";
in actual = lib.bools.into.string true;
in
actual == expected; actual == expected;
"handles false" = let "handles false" =
expected = "false"; let
actual = lib.bools.into.string false; expected = "false";
in actual = lib.bools.into.string false;
in
actual == expected; actual == expected;
}; };
"yesno" = { "yesno" = {
"handles true" = let "handles true" =
expected = "yes"; let
actual = lib.bools.into.yesno true; expected = "yes";
in actual = lib.bools.into.yesno true;
in
actual == expected; actual == expected;
"handles false" = let "handles false" =
expected = "no"; let
actual = lib.bools.into.yesno false; expected = "no";
in actual = lib.bools.into.yesno false;
in
actual == expected; actual == expected;
}; };
}; };
"when" = { "when" = {
"returns first value when true" = let "returns first value when true" =
expected = "foo"; let
actual = lib.bools.when true expected "bar"; expected = "foo";
in actual = lib.bools.when true expected "bar";
in
actual == expected; actual == expected;
"returns second value when false" = let "returns second value when false" =
expected = "bar"; let
actual = lib.bools.when false "foo" expected; expected = "bar";
in actual = lib.bools.when false "foo" expected;
in
actual == expected; actual == expected;
}; };
"and" = { "and" = {
"returns true when both are true" = let "returns true when both are true" =
expected = true; let
actual = lib.bools.and true true; expected = true;
in actual = lib.bools.and true true;
in
actual == expected; actual == expected;
"returns false when first is false" = let "returns false when first is false" =
expected = false; let
actual = lib.bools.and false true; expected = false;
in actual = lib.bools.and false true;
in
actual == expected; actual == expected;
"returns false when second is false" = let "returns false when second is false" =
expected = false; let
actual = lib.bools.and true false; expected = false;
in actual = lib.bools.and true false;
in
actual == expected; actual == expected;
"returns false when both are false" = let "returns false when both are false" =
expected = false; let
actual = lib.bools.and false false; expected = false;
in actual = lib.bools.and false false;
in
actual == expected; actual == expected;
}; };
"and'" = let "and'" =
getTrue = _: true; let
getFalse = _: false; getTrue = _: true;
in { getFalse = _: false;
"returns true when both are true" = let
expected = true;
actual = lib.bools.and' getTrue getTrue null;
in in
actual == expected; {
"returns true when both are true" =
let
expected = true;
actual = lib.bools.and' getTrue getTrue null;
in
actual == expected;
"returns false when first is false" = let "returns false when first is false" =
expected = false; let
actual = lib.bools.and' getFalse getTrue null; expected = false;
in actual = lib.bools.and' getFalse getTrue null;
actual == expected; in
actual == expected;
"returns false when second is false" = let "returns false when second is false" =
expected = false; let
actual = lib.bools.and' getTrue getFalse null; expected = false;
in actual = lib.bools.and' getTrue getFalse null;
actual == expected; in
actual == expected;
"returns false when both are false" = let "returns false when both are false" =
expected = false; let
actual = lib.bools.and' getFalse getFalse null; expected = false;
in actual = lib.bools.and' getFalse getFalse null;
actual == expected; in
}; actual == expected;
};
"or" = { "or" = {
"returns true when both are true" = let "returns true when both are true" =
expected = true; let
actual = lib.bools.or true true; expected = true;
in actual = lib.bools.or true true;
in
actual == expected; actual == expected;
"returns true when first is true" = let "returns true when first is true" =
expected = true; let
actual = lib.bools.or true false; expected = true;
in actual = lib.bools.or true false;
in
actual == expected; actual == expected;
"returns true when second is true" = let "returns true when second is true" =
expected = true; let
actual = lib.bools.or false true; expected = true;
in actual = lib.bools.or false true;
in
actual == expected; actual == expected;
"returns false when both are false" = let "returns false when both are false" =
expected = false; let
actual = lib.bools.or false false; expected = false;
in actual = lib.bools.or false false;
in
actual == expected; actual == expected;
}; };
"or'" = let "or'" =
getTrue = _: true; let
getFalse = _: false; getTrue = _: true;
in { getFalse = _: false;
"returns true when both are true" = let
expected = true;
actual = lib.bools.or' getTrue getTrue null;
in in
actual == expected; {
"returns true when first is true" = let "returns true when both are true" =
expected = true; let
actual = lib.bools.or' getTrue getFalse null; expected = true;
in actual = lib.bools.or' getTrue getTrue null;
actual == expected; in
"returns true when second is true" = let actual == expected;
expected = true; "returns true when first is true" =
actual = lib.bools.or' getFalse getTrue null; let
in expected = true;
actual == expected; actual = lib.bools.or' getTrue getFalse null;
"returns false when both are false" = let in
expected = false; actual == expected;
actual = lib.bools.or' getFalse getFalse null; "returns true when second is true" =
in let
actual == expected; expected = true;
}; actual = lib.bools.or' getFalse getTrue null;
in
actual == expected;
"returns false when both are false" =
let
expected = false;
actual = lib.bools.or' getFalse getFalse null;
in
actual == expected;
};
"not" = { "not" = {
"returns false when true" = let "returns false when true" =
expected = false; let
actual = lib.bools.not true; expected = false;
in actual = lib.bools.not true;
in
actual == expected; actual == expected;
"returns true when false" = let "returns true when false" =
expected = true; let
actual = lib.bools.not false; expected = true;
in actual = lib.bools.not false;
in
actual == expected; actual == expected;
}; };
} }

View file

@ -4,58 +4,56 @@ lib: {
## Check that a value is a DAG entry. ## Check that a value is a DAG entry.
## ##
## @type a -> Bool ## @type a -> Bool
entry = value: entry = value: (value ? value) && (value ? before) && (value ? after);
(value ? value)
&& (value ? before)
&& (value ? after);
## Check that a value is a DAG. ## Check that a value is a DAG.
## ##
## @type a -> Bool ## @type a -> Bool
graph = value: let graph =
isContentsValid = builtins.all lib.dag.validate.entry (builtins.attrValues value); value:
in let
builtins.isAttrs value isContentsValid = builtins.all lib.dag.validate.entry (builtins.attrValues value);
&& isContentsValid; in
builtins.isAttrs value && isContentsValid;
}; };
sort = { sort = {
## 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 }
topographic = graph: let topographic =
getEntriesBefore = graph: name: let graph:
before = let
lib.attrs.filter getEntriesBefore =
(key: value: builtins.elem name value.before) graph: name:
graph; let
before = lib.attrs.filter (key: value: builtins.elem name value.before) graph;
in
builtins.attrNames before;
normalize = name: value: {
inherit name;
value = value.value;
after = value.after ++ (getEntriesBefore graph name);
};
normalized = builtins.mapAttrs normalize graph;
entries = builtins.attrValues normalized;
isBefore = a: b: builtins.elem a.name b.after;
sorted = lib.lists.sort.topographic isBefore entries;
in in
builtins.attrNames before; if sorted ? result then
{
normalize = name: value: { result = builtins.map (value: {
inherit name;
value = value.value;
after = value.after ++ (getEntriesBefore graph name);
};
normalized = builtins.mapAttrs normalize graph;
entries = builtins.attrValues normalized;
isBefore = a: b: builtins.elem a.name b.after;
sorted = lib.lists.sort.topographic isBefore entries;
in
if sorted ? result
then {
result =
builtins.map (value: {
name = value.name; name = value.name;
value = value.value; value = value.value;
}) }) sorted.result;
sorted.result; }
} else
else sorted; sorted;
}; };
apply = { apply = {
@ -63,107 +61,95 @@ lib: {
## and any entries that do exist are given the appropriate `before` and `after` values. ## and any entries that do exist are given the appropriate `before` and `after` values.
## ##
## @type Dag a -> Dag a -> Dag a ## @type Dag a -> Dag a -> Dag a
defaults = graph: defaults: let defaults =
result = graph: defaults:
builtins.mapAttrs let
( result = builtins.mapAttrs (
name: entry: name: entry:
if defaults ? ${name} if defaults ? ${name} then
then if builtins.isString entry then
if builtins.isString entry {
then {
value = entry; value = entry;
before = defaults.${name}.before or []; before = defaults.${name}.before or [ ];
after = defaults.${name}.after or []; after = defaults.${name}.after or [ ];
} }
else else
entry entry
// { // {
before = (entry.before or []) ++ (defaults.${name}.before or []); before = (entry.before or [ ]) ++ (defaults.${name}.before or [ ]);
after = (entry.after or []) ++ (defaults.${name}.after or []); after = (entry.after or [ ]) ++ (defaults.${name}.after or [ ]);
} }
else entry else
) entry
graph; ) graph;
in in
defaults // result; defaults // result;
}; };
## Map over the entries in a DAG and modify their values. ## Map over the entries in a DAG and modify their values.
## ##
## @type (String -> a -> b) -> Dag a -> Dag b ## @type (String -> a -> b) -> Dag a -> Dag b
map = f: map = f: builtins.mapAttrs (name: value: value // { value = f name value.value; });
builtins.mapAttrs
(name: value:
value
// {
value = f name value.value;
});
entry = { entry = {
## 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 = before: after: value: { between = before: after: value: { inherit before after value; };
inherit before after value;
};
## Create a new DAG entry with no dependencies. ## Create a new DAG entry with no dependencies.
## ##
## @type a -> { before :: List String, after :: List String, value :: a } ## @type a -> { before :: List String, after :: List String, value :: a }
anywhere = lib.dag.entry.between [] []; anywhere = lib.dag.entry.between [ ] [ ];
## 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 = lib.dag.entry.between []; after = lib.dag.entry.between [ ];
}; };
entries = { entries = {
## Create a DAG from a list of entries, prefixed with a tag. ## Create a DAG from a list of entries, prefixed with a tag.
## ##
## @type String -> List String -> List String -> List a -> Dag a ## @type String -> List String -> List String -> List a -> Dag a
between = tag: let between =
process = i: before: after: entries: let tag:
name = "${tag}-${builtins.toString i}"; let
entry = builtins.head entries; process =
rest = builtins.tail entries; i: before: after: entries:
let
name = "${tag}-${builtins.toString i}";
entry = builtins.head entries;
rest = builtins.tail entries;
in
if builtins.length entries == 0 then
{ }
else if builtins.length entries == 1 then
{ "${name}" = lib.dag.entry.between before after entry; }
else
{ "${name}" = lib.dag.entry.after after entry; } // (process (i + 1) before [ name ] rest);
in in
if builtins.length entries == 0
then {}
else if builtins.length entries == 1
then {
"${name}" = lib.dag.entry.between before after entry;
}
else
{
"${name}" = lib.dag.entry.after after entry;
}
// (
process (i + 1) before [name] rest
);
in
process 0; process 0;
## Create a DAG from a list of entries, prefixed with a tag, that can occur anywhere. ## Create a DAG from a list of entries, prefixed with a tag, that can occur anywhere.
## ##
## @type String -> List a -> Dag a ## @type String -> List a -> Dag a
anywhere = tag: lib.dag.entries.between tag [] []; anywhere = tag: lib.dag.entries.between tag [ ] [ ];
## 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: lib.dag.entries.between tag []; after = tag: lib.dag.entries.between tag [ ];
}; };
}; };
} }

Some files were not shown because too many files have changed in this diff Show more