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
#!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,
}: let
{ lib, config }:
let
system = config.aux.system;
builders = config.aux.foundation.builders;
stage0 = config.aux.foundation.stages.stage0;
stage1 = config.aux.foundation.stages.stage1;
in {
in
{
options.aux.foundation.builders.bash.boot = {
build = lib.options.create {
type = lib.types.function lib.types.derivation;
@ -17,61 +16,67 @@ in {
config = {
aux.foundation.builders.bash.boot = {
build = settings @ {
name,
script,
meta ? {},
extras ? {},
env ? {},
deps ? {},
...
}: let
package = builtins.derivation (
(builtins.removeAttrs settings ["meta" "extras" "executable" "env" "deps" "script"])
// env
// {
inherit name system script;
build =
settings@{
name,
script,
meta ? { },
extras ? { },
env ? { },
deps ? { },
...
}:
let
package = builtins.derivation (
(builtins.removeAttrs settings [
"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 = [
"-e"
(builtins.toFile "bash-builder.sh" ''
export CONFIG_SHELL=$SHELL
args = [
"-e"
(builtins.toFile "bash-builder.sh" ''
export CONFIG_SHELL=$SHELL
# 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
# 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.
NIX_BUILD_CORES="''${NIX_BUILD_CORES:-1}"
if [ $NIX_BUILD_CORES -le 0 ]; then
NIX_BUILD_CORES=1
fi
export NIX_BUILD_CORES
# 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
# 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.
NIX_BUILD_CORES="''${NIX_BUILD_CORES:-1}"
if [ $NIX_BUILD_CORES -le 0 ]; then
NIX_BUILD_CORES=1
fi
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 (
(deps.build.host or [])
++ [
stage1.bash.boot.package
stage1.coreutils.boot.package
stage0.mescc-tools-extra.package
]
);
}
);
in
package
// {
inherit meta extras;
};
PATH = lib.paths.bin (
(deps.build.host or [ ])
++ [
stage1.bash.boot.package
stage1.coreutils.boot.package
stage0.mescc-tools-extra.package
]
);
}
);
in
package // { inherit meta extras; };
};
};
}

View file

@ -1,15 +1,12 @@
{
lib,
config,
}: let
{ lib, config }:
let
system = config.aux.system;
builders = config.aux.foundation.builders;
stage1 = config.aux.foundation.stages.stage1;
in {
includes = [
./boot.nix
];
in
{
includes = [ ./boot.nix ];
options.aux.foundation.builders.bash = {
build = lib.options.create {
@ -20,60 +17,66 @@ in {
config = {
aux.foundation.builders.bash = {
build = settings @ {
name,
script,
meta ? {},
extras ? {},
env ? {},
deps ? {},
...
}: let
package = builtins.derivation (
(builtins.removeAttrs settings ["meta" "extras" "executable" "env" "deps" "script"])
// env
// {
inherit name system script;
build =
settings@{
name,
script,
meta ? { },
extras ? { },
env ? { },
deps ? { },
...
}:
let
package = builtins.derivation (
(builtins.removeAttrs settings [
"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 = [
"-e"
(builtins.toFile "bash-builder.sh" ''
export CONFIG_SHELL=$SHELL
args = [
"-e"
(builtins.toFile "bash-builder.sh" ''
export CONFIG_SHELL=$SHELL
# 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
# available CPU cores at run-time.
NIX_BUILD_CORES="''${NIX_BUILD_CORES:-1}"
if ((NIX_BUILD_CORES <= 0)); then
guess=$(nproc 2>/dev/null || true)
((NIX_BUILD_CORES = guess <= 0 ? 1 : guess))
fi
export NIX_BUILD_CORES
# 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
# available CPU cores at run-time.
NIX_BUILD_CORES="''${NIX_BUILD_CORES:-1}"
if ((NIX_BUILD_CORES <= 0)); then
guess=$(nproc 2>/dev/null || true)
((NIX_BUILD_CORES = guess <= 0 ? 1 : guess))
fi
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 (
(deps.build.host or [])
++ [
stage1.bash.package
stage1.coreutils.package
]
);
}
);
in
package
// {
inherit meta extras;
};
PATH = lib.paths.bin (
(deps.build.host or [ ])
++ [
stage1.bash.package
stage1.coreutils.package
]
);
}
);
in
package // { inherit meta extras; };
};
};
}

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,7 +1,5 @@
{
lib,
config,
}: let
{ lib, config }:
let
cfg = config.aux.foundation.stages.stage0.kaem;
system = config.aux.system;
@ -10,7 +8,8 @@
kaem-unwrapped = config.aux.foundation.stages.stage0.kaem-unwrapped;
mescc-tools = config.aux.foundation.stages.stage0.mescc-tools;
mescc-tools-extra = config.aux.foundation.stages.stage0.mescc-tools-extra;
in {
in
{
options.aux.foundation.stages.stage0.kaem = {
meta = {
description = lib.options.create {
@ -35,7 +34,7 @@ in {
platforms = lib.options.create {
type = lib.types.list.of lib.types.string;
description = "Platforms the package supports.";
default.value = ["i686-linux"];
default.value = [ "i686-linux" ];
};
};
@ -47,24 +46,26 @@ in {
config = {
aux.foundation.stages.stage0.kaem = {
package = lib.modules.overrides.default (builders.raw.build {
pname = "kaem";
version = "1.6.0";
package = lib.modules.overrides.default (
builders.raw.build {
pname = "kaem";
version = "1.6.0";
meta = cfg.meta;
meta = cfg.meta;
executable = kaem-unwrapped.package;
executable = kaem-unwrapped.package;
args = [
"--verbose"
"--strict"
"--file"
./build.kaem
];
args = [
"--verbose"
"--strict"
"--file"
./build.kaem
];
kaemUnwrapped = kaem-unwrapped.package;
PATH = lib.paths.bin [mescc-tools-extra.package];
});
kaemUnwrapped = kaem-unwrapped.package;
PATH = lib.paths.bin [ mescc-tools-extra.package ];
}
);
};
};
}

View file

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

View file

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

View file

@ -1,7 +1,5 @@
{
lib,
config,
}: let
{ lib, config }:
let
cfg = config.aux.foundation.stages.stage0.hex0;
system = config.aux.system;
@ -9,14 +7,16 @@
sources = config.aux.foundation.stages.stage0.sources;
architecture =
if system == "x86_64-linux"
then "AMD64"
else if system == "aarch64-linux"
then "AArch64"
else if system == "i686-linux"
then "x86"
else builtins.throw "Unsupported system for stage0: ${system}";
in {
if system == "x86_64-linux" then
"AMD64"
else if system == "aarch64-linux" then
"AArch64"
else if system == "i686-linux" then
"x86"
else
builtins.throw "Unsupported system for stage0: ${system}";
in
{
options.aux.foundation.stages.stage0.hex0 = {
meta = {
description = lib.options.create {
@ -41,7 +41,7 @@ in {
platforms = lib.options.create {
type = lib.types.list.of lib.types.string;
description = "Platforms the package supports.";
default.value = ["i686-linux"];
default.value = [ "i686-linux" ];
};
};
@ -66,40 +66,45 @@ in {
config = {
aux.foundation.stages.stage0.hex0 = {
package = lib.modules.overrides.default (builders.raw.build {
pname = "hex0";
version = "1.6.0";
package = lib.modules.overrides.default (
builders.raw.build {
pname = "hex0";
version = "1.6.0";
meta = cfg.meta;
meta = cfg.meta;
executable = cfg.executable;
executable = cfg.executable;
args = [
"${sources.base}/hex0_${architecture}.hex0"
(builtins.placeholder "out")
];
args = [
"${sources.base}/hex0_${architecture}.hex0"
(builtins.placeholder "out")
];
outputHashMode = "recursive";
outputHashAlgo = "sha256";
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
outputHashMode = "recursive";
outputHashAlgo = "sha256";
outputHash = cfg.hash;
}
);
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;
});
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> {
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,
}: let
{ lib, config }:
let
cfg = config.aux.foundation.stages.stage0.hex1;
hex0 = config.aux.foundation.stages.stage0.hex0;
@ -9,7 +7,8 @@
builders = config.aux.foundation.builders;
sources = config.aux.foundation.stages.stage0.sources;
architecture = config.aux.foundation.stages.stage0.architecture;
in {
in
{
options.aux.foundation.stages.stage0.hex1 = {
meta = {
description = lib.options.create {
@ -34,7 +33,7 @@ in {
platforms = lib.options.create {
type = lib.types.list.of lib.types.string;
description = "Platforms the package supports.";
default.value = ["i686-linux"];
default.value = [ "i686-linux" ];
};
};
@ -46,19 +45,21 @@ in {
config = {
aux.foundation.stages.stage0.hex1 = {
package = lib.modules.overrides.default (builders.raw.build {
pname = "hex1";
version = "1.6.0";
package = lib.modules.overrides.default (
builders.raw.build {
pname = "hex1";
version = "1.6.0";
meta = cfg.meta;
meta = cfg.meta;
executable = hex0.package;
executable = hex0.package;
args = [
"${sources.base}/hex1_${architecture.base}.hex0"
(builtins.placeholder "out")
];
});
args = [
"${sources.base}/hex1_${architecture.base}.hex0"
(builtins.placeholder "out")
];
}
);
};
};
}

View file

@ -1,7 +1,5 @@
{
lib,
config,
}: let
{ lib, config }:
let
cfg = config.aux.foundation.stages.stage0.hex2-0;
hex0 = config.aux.foundation.stages.stage0.hex0;
hex1 = config.aux.foundation.stages.stage0.hex1;
@ -10,7 +8,8 @@
builders = config.aux.foundation.builders;
sources = config.aux.foundation.stages.stage0.sources;
architecture = config.aux.foundation.stages.stage0.architecture;
in {
in
{
options.aux.foundation.stages.stage0.hex2-0 = {
meta = {
description = lib.options.create {
@ -35,7 +34,7 @@ in {
platforms = lib.options.create {
type = lib.types.list.of lib.types.string;
description = "Platforms the package supports.";
default.value = ["i686-linux"];
default.value = [ "i686-linux" ];
};
};
@ -47,19 +46,21 @@ in {
config = {
aux.foundation.stages.stage0.hex2-0 = {
package = lib.modules.overrides.default (builders.raw.build {
pname = "hex2-0";
version = "1.6.0";
package = lib.modules.overrides.default (
builders.raw.build {
pname = "hex2-0";
version = "1.6.0";
meta = cfg.meta;
meta = cfg.meta;
executable = hex1.package;
executable = hex1.package;
args = [
"${sources.base}/hex2_${architecture.base}.hex1"
(builtins.placeholder "out")
];
});
args = [
"${sources.base}/hex2_${architecture.base}.hex1"
(builtins.placeholder "out")
];
}
);
};
};
}

View file

@ -1,7 +1,5 @@
{
lib,
config,
}: let
{ lib, config }:
let
cfg = config.aux.foundation.stages.stage0.catm;
hex0 = config.aux.foundation.stages.stage0.hex0;
hex1 = config.aux.foundation.stages.stage0.hex1;
@ -11,7 +9,8 @@
builders = config.aux.foundation.builders;
sources = config.aux.foundation.stages.stage0.sources;
architecture = config.aux.foundation.stages.stage0.architecture;
in {
in
{
options.aux.foundation.stages.stage0.catm = {
meta = {
description = lib.options.create {
@ -36,7 +35,7 @@ in {
platforms = lib.options.create {
type = lib.types.list.of lib.types.string;
description = "Platforms the package supports.";
default.value = ["i686-linux"];
default.value = [ "i686-linux" ];
};
};
@ -48,28 +47,28 @@ in {
config = {
aux.foundation.stages.stage0.catm = {
package = lib.modules.overrides.default (builders.raw.build {
pname = "catm";
version = "1.6.0";
package = lib.modules.overrides.default (
builders.raw.build {
pname = "catm";
version = "1.6.0";
meta = cfg.meta;
meta = cfg.meta;
executable =
if architecture.base == "AArch64"
then hex1.package
else hex2-0.package;
executable = if architecture.base == "AArch64" then hex1.package else hex2-0.package;
args =
if architecture.base == "AArch64"
then [
"${sources.base}/catm_${architecture.base}.hex1"
(builtins.placeholder "out")
]
else [
"${sources.base}/catm_${architecture.base}.hex2"
(builtins.placeholder "out")
];
});
args =
if architecture.base == "AArch64" then
[
"${sources.base}/catm_${architecture.base}.hex1"
(builtins.placeholder "out")
]
else
[
"${sources.base}/catm_${architecture.base}.hex2"
(builtins.placeholder "out")
];
}
);
};
};
}

View file

@ -1,7 +1,5 @@
{
lib,
config,
}: let
{ lib, config }:
let
cfg = config.aux.foundation.stages.stage0.M0;
hex0 = config.aux.foundation.stages.stage0.hex0;
hex2-0 = config.aux.foundation.stages.stage0.hex2-0;
@ -11,7 +9,8 @@
builders = config.aux.foundation.builders;
sources = config.aux.foundation.stages.stage0.sources;
architecture = config.aux.foundation.stages.stage0.architecture;
in {
in
{
options.aux.foundation.stages.stage0.M0 = {
meta = {
description = lib.options.create {
@ -36,7 +35,7 @@ in {
platforms = lib.options.create {
type = lib.types.list.of lib.types.string;
description = "Platforms the package supports.";
default.value = ["i686-linux"];
default.value = [ "i686-linux" ];
};
};
@ -48,34 +47,38 @@ in {
config = {
aux.foundation.stages.stage0.M0 = {
package = lib.modules.overrides.default (builders.raw.build {
pname = "M0";
version = "1.6.0";
package = lib.modules.overrides.default (
builders.raw.build {
pname = "M0";
version = "1.6.0";
meta = cfg.meta;
meta = cfg.meta;
executable = hex2-0.package;
executable = hex2-0.package;
args = let
M0_hex2-0 = builders.raw.build {
pname = "M0_hex2-0";
version = "1.6.0";
args =
let
M0_hex2-0 = builders.raw.build {
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")
"${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,
}: let
{ lib, config }:
let
cfg = config.aux.foundation.stages.stage0.cc_arch;
hex0 = config.aux.foundation.stages.stage0.hex0;
hex2-0 = config.aux.foundation.stages.stage0.hex2-0;
@ -12,7 +10,8 @@
builders = config.aux.foundation.builders;
sources = config.aux.foundation.stages.stage0.sources;
architecture = config.aux.foundation.stages.stage0.architecture;
in {
in
{
options.aux.foundation.stages.stage0.cc_arch = {
meta = {
description = lib.options.create {
@ -37,7 +36,7 @@ in {
platforms = lib.options.create {
type = lib.types.list.of lib.types.string;
description = "Platforms the package supports.";
default.value = ["i686-linux"];
default.value = [ "i686-linux" ];
};
};
@ -49,47 +48,51 @@ in {
config = {
aux.foundation.stages.stage0.cc_arch = {
package = lib.modules.overrides.default (builders.raw.build {
pname = "cc_arch";
version = "1.6.0";
package = lib.modules.overrides.default (
builders.raw.build {
pname = "cc_arch";
version = "1.6.0";
meta = cfg.meta;
meta = cfg.meta;
executable = hex2-0.package;
executable = hex2-0.package;
args = let
cc_arch0_hex2-0 = builders.raw.build {
pname = "cc_arch0_hex2-0";
version = "1.6.0";
args =
let
cc_arch0_hex2-0 = builders.raw.build {
pname = "cc_arch0_hex2-0";
version = "1.6.0";
meta = cfg.meta;
meta = cfg.meta;
executable = M0.package;
executable = M0.package;
args = [
"${sources.base}/cc_${architecture.m2libc}.M1"
args = [
"${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")
];
};
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,
}: let
{ lib, config }:
let
cfg = config.aux.foundation.stages.stage0.M2;
hex0 = config.aux.foundation.stages.stage0.hex0;
hex2-0 = config.aux.foundation.stages.stage0.hex2-0;
@ -13,7 +11,8 @@
builders = config.aux.foundation.builders;
sources = config.aux.foundation.stages.stage0.sources;
architecture = config.aux.foundation.stages.stage0.architecture;
in {
in
{
options.aux.foundation.stages.stage0.M2 = {
meta = {
description = lib.options.create {
@ -38,7 +37,7 @@ in {
platforms = lib.options.create {
type = lib.types.list.of lib.types.string;
description = "Platforms the package supports.";
default.value = ["i686-linux"];
default.value = [ "i686-linux" ];
};
};
@ -50,97 +49,101 @@ in {
config = {
aux.foundation.stages.stage0.M2 = {
package = lib.modules.overrides.default (builders.raw.build {
pname = "M2";
version = "1.6.0";
package = lib.modules.overrides.default (
builders.raw.build {
pname = "M2";
version = "1.6.0";
meta = cfg.meta;
meta = cfg.meta;
executable = hex2-0.package;
executable = hex2-0.package;
args = let
M2_c = builders.raw.build {
pname = "M2_c";
version = "1.6.0";
args =
let
M2_c = builders.raw.build {
pname = "M2_c";
version = "1.6.0";
meta = cfg.meta;
meta = cfg.meta;
executable = catm.package;
executable = catm.package;
args = [
(builtins.placeholder "out")
"${sources.m2libc}/${architecture.m2libc}/linux/bootstrap.c"
"${sources.m2planet}/cc.h"
"${sources.m2libc}/bootstrappable.c"
"${sources.m2planet}/cc_globals.c"
"${sources.m2planet}/cc_reader.c"
"${sources.m2planet}/cc_strings.c"
"${sources.m2planet}/cc_types.c"
"${sources.m2planet}/cc_core.c"
"${sources.m2planet}/cc_macro.c"
"${sources.m2planet}/cc.c"
];
};
M2_M1 = builders.raw.build {
pname = "M2_M1";
version = "1.6.0";
args = [
(builtins.placeholder "out")
"${sources.m2libc}/${architecture.m2libc}/linux/bootstrap.c"
"${sources.m2planet}/cc.h"
"${sources.m2libc}/bootstrappable.c"
"${sources.m2planet}/cc_globals.c"
"${sources.m2planet}/cc_reader.c"
"${sources.m2planet}/cc_strings.c"
"${sources.m2planet}/cc_types.c"
"${sources.m2planet}/cc_core.c"
"${sources.m2planet}/cc_macro.c"
"${sources.m2planet}/cc.c"
];
};
M2_M1 = builders.raw.build {
pname = "M2_M1";
version = "1.6.0";
meta = cfg.meta;
meta = cfg.meta;
executable = cc_arch.package;
executable = cc_arch.package;
args = [
M2_c
args = [
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")
];
};
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,
}: let
{ lib, config }:
let
cfg = config.aux.foundation.stages.stage0.blood-elf;
hex0 = config.aux.foundation.stages.stage0.hex0;
hex2-0 = config.aux.foundation.stages.stage0.hex2-0;
@ -14,7 +12,8 @@
builders = config.aux.foundation.builders;
sources = config.aux.foundation.stages.stage0.sources;
architecture = config.aux.foundation.stages.stage0.architecture;
in {
in
{
options.aux.foundation.stages.stage0.blood-elf = {
meta = {
description = lib.options.create {
@ -39,7 +38,7 @@ in {
platforms = lib.options.create {
type = lib.types.list.of lib.types.string;
description = "Platforms the package supports.";
default.value = ["i686-linux"];
default.value = [ "i686-linux" ];
};
};
@ -51,86 +50,90 @@ in {
config = {
aux.foundation.stages.stage0.blood-elf = {
package = lib.modules.overrides.default (builders.raw.build {
pname = "blood-elf";
version = "1.6.0";
package = lib.modules.overrides.default (
builders.raw.build {
pname = "blood-elf";
version = "1.6.0";
meta = cfg.meta;
meta = cfg.meta;
executable = hex2-0.package;
executable = hex2-0.package;
args = let
blood-elf_M1 = builders.raw.build {
pname = "blood-elf_M1";
version = "1.6.0";
args =
let
blood-elf_M1 = builders.raw.build {
pname = "blood-elf_M1";
version = "1.6.0";
meta = cfg.meta;
meta = cfg.meta;
executable = M2.package;
executable = M2.package;
args = [
"--architecture"
architecture.m2libc
"-f"
"${sources.m2libc}/${architecture.m2libc}/linux/bootstrap.c"
"-f"
"${sources.m2libc}/bootstrappable.c"
"-f"
"${sources.mescc-tools}/stringify.c"
"-f"
"${sources.mescc-tools}/blood-elf.c"
"--bootstrap-mode"
"-o"
args = [
"--architecture"
architecture.m2libc
"-f"
"${sources.m2libc}/${architecture.m2libc}/linux/bootstrap.c"
"-f"
"${sources.m2libc}/bootstrappable.c"
"-f"
"${sources.mescc-tools}/stringify.c"
"-f"
"${sources.mescc-tools}/blood-elf.c"
"--bootstrap-mode"
"-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")
];
};
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,
}: let
{ lib, config }:
let
cfg = config.aux.foundation.stages.stage0.M1-0;
hex0 = config.aux.foundation.stages.stage0.hex0;
hex2-0 = config.aux.foundation.stages.stage0.hex2-0;
@ -15,7 +13,8 @@
builders = config.aux.foundation.builders;
sources = config.aux.foundation.stages.stage0.sources;
architecture = config.aux.foundation.stages.stage0.architecture;
in {
in
{
options.aux.foundation.stages.stage0.M1-0 = {
meta = {
description = lib.options.create {
@ -40,7 +39,7 @@ in {
platforms = lib.options.create {
type = lib.types.list.of lib.types.string;
description = "Platforms the package supports.";
default.value = ["i686-linux"];
default.value = [ "i686-linux" ];
};
};
@ -52,110 +51,108 @@ in {
config = {
aux.foundation.stages.stage0.M1-0 = {
package = lib.modules.overrides.default (builders.raw.build {
pname = "M1-0";
version = "1.6.0";
package = lib.modules.overrides.default (
builders.raw.build {
pname = "M1-0";
version = "1.6.0";
meta = cfg.meta;
meta = cfg.meta;
executable = hex2-0.package;
executable = hex2-0.package;
args = let
M1-macro-0_M1 = builders.raw.build {
pname = "M1-macro-0_M1";
version = "1.6.0";
args =
let
M1-macro-0_M1 = builders.raw.build {
pname = "M1-macro-0_M1";
version = "1.6.0";
meta = cfg.meta;
meta = cfg.meta;
executable = M2.package;
executable = M2.package;
args = [
"--architecture"
architecture.m2libc
"-f"
"${sources.m2libc}/${architecture.m2libc}/linux/bootstrap.c"
"-f"
"${sources.m2libc}/bootstrappable.c"
"-f"
"${sources.mescc-tools}/stringify.c"
"-f"
"${sources.mescc-tools}/M1-macro.c"
"--bootstrap-mode"
"--debug"
"-o"
args = [
"--architecture"
architecture.m2libc
"-f"
"${sources.m2libc}/${architecture.m2libc}/linux/bootstrap.c"
"-f"
"${sources.m2libc}/bootstrappable.c"
"-f"
"${sources.mescc-tools}/stringify.c"
"-f"
"${sources.mescc-tools}/M1-macro.c"
"--bootstrap-mode"
"--debug"
"-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")
];
};
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,
}: let
{ lib, config }:
let
cfg = config.aux.foundation.stages.stage0.hex2-1;
hex0 = config.aux.foundation.stages.stage0.hex0;
hex2-0 = config.aux.foundation.stages.stage0.hex2-0;
@ -16,7 +14,8 @@
builders = config.aux.foundation.builders;
sources = config.aux.foundation.stages.stage0.sources;
architecture = config.aux.foundation.stages.stage0.architecture;
in {
in
{
options.aux.foundation.stages.stage0.hex2-1 = {
meta = {
description = lib.options.create {
@ -41,7 +40,7 @@ in {
platforms = lib.options.create {
type = lib.types.list.of lib.types.string;
description = "Platforms the package supports.";
default.value = ["i686-linux"];
default.value = [ "i686-linux" ];
};
};
@ -53,128 +52,122 @@ in {
config = {
aux.foundation.stages.stage0.hex2-1 = {
package = lib.modules.overrides.default (builders.raw.build {
pname = "hex2-1";
version = "1.6.0";
package = lib.modules.overrides.default (
builders.raw.build {
pname = "hex2-1";
version = "1.6.0";
meta = cfg.meta;
meta = cfg.meta;
executable = hex2-0.package;
executable = hex2-0.package;
args = let
hex2_linker_M1 = builders.raw.build {
pname = "hex2_linker_M1";
version = "1.6.0";
args =
let
hex2_linker_M1 = builders.raw.build {
pname = "hex2_linker_M1";
version = "1.6.0";
meta = cfg.meta;
meta = cfg.meta;
executable = M2.package;
executable = M2.package;
args = [
"--architecture"
architecture.m2libc
"-f"
"${sources.m2libc}/sys/types.h"
"-f"
"${sources.m2libc}/stddef.h"
"-f"
"${sources.m2libc}/${architecture.m2libc}/linux/unistd.c"
"-f"
"${sources.m2libc}/${architecture.m2libc}/linux/fcntl.c"
"-f"
"${sources.m2libc}/fcntl.c"
"-f"
"${sources.m2libc}/${architecture.m2libc}/linux/sys/stat.c"
"-f"
"${sources.m2libc}/stdlib.c"
"-f"
"${sources.m2libc}/stdio.h"
"-f"
"${sources.m2libc}/stdio.c"
"-f"
"${sources.m2libc}/bootstrappable.c"
"-f"
"${sources.mescc-tools}/hex2.h"
"-f"
"${sources.mescc-tools}/hex2_linker.c"
"-f"
"${sources.mescc-tools}/hex2_word.c"
"-f"
"${sources.mescc-tools}/hex2.c"
"--debug"
"-o"
args = [
"--architecture"
architecture.m2libc
"-f"
"${sources.m2libc}/sys/types.h"
"-f"
"${sources.m2libc}/stddef.h"
"-f"
"${sources.m2libc}/${architecture.m2libc}/linux/unistd.c"
"-f"
"${sources.m2libc}/${architecture.m2libc}/linux/fcntl.c"
"-f"
"${sources.m2libc}/fcntl.c"
"-f"
"${sources.m2libc}/${architecture.m2libc}/linux/sys/stat.c"
"-f"
"${sources.m2libc}/stdlib.c"
"-f"
"${sources.m2libc}/stdio.h"
"-f"
"${sources.m2libc}/stdio.c"
"-f"
"${sources.m2libc}/bootstrappable.c"
"-f"
"${sources.mescc-tools}/hex2.h"
"-f"
"${sources.mescc-tools}/hex2_linker.c"
"-f"
"${sources.mescc-tools}/hex2_word.c"
"-f"
"${sources.mescc-tools}/hex2.c"
"--debug"
"-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")
];
};
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,
}: let
{ lib, config }:
let
cfg = config.aux.foundation.stages.stage0.M1;
hex0 = config.aux.foundation.stages.stage0.hex0;
hex2-0 = config.aux.foundation.stages.stage0.hex2-0;
@ -17,7 +15,8 @@
builders = config.aux.foundation.builders;
sources = config.aux.foundation.stages.stage0.sources;
architecture = config.aux.foundation.stages.stage0.architecture;
in {
in
{
options.aux.foundation.stages.stage0.M1 = {
meta = {
description = lib.options.create {
@ -42,7 +41,7 @@ in {
platforms = lib.options.create {
type = lib.types.list.of lib.types.string;
description = "Platforms the package supports.";
default.value = ["i686-linux"];
default.value = [ "i686-linux" ];
};
};
@ -54,133 +53,124 @@ in {
config = {
aux.foundation.stages.stage0.M1 = {
package = lib.modules.overrides.default (builders.raw.build {
pname = "M1";
version = "1.6.0";
package = lib.modules.overrides.default (
builders.raw.build {
pname = "M1";
version = "1.6.0";
meta = cfg.meta;
meta = cfg.meta;
executable = hex2-1.package;
executable = hex2-1.package;
args = let
M1-macro_M1 = builders.raw.build {
pname = "M1-macro_M1";
version = "1.6.0";
args =
let
M1-macro_M1 = builders.raw.build {
pname = "M1-macro_M1";
version = "1.6.0";
meta = cfg.meta;
meta = cfg.meta;
executable = M2.package;
executable = M2.package;
args = [
"--architecture"
architecture.m2libc
"-f"
"${sources.m2libc}/sys/types.h"
"-f"
"${sources.m2libc}/stddef.h"
"-f"
"${sources.m2libc}/${architecture.m2libc}/linux/unistd.c"
"-f"
"${sources.m2libc}/${architecture.m2libc}/linux/fcntl.c"
"-f"
"${sources.m2libc}/fcntl.c"
"-f"
"${sources.m2libc}/${architecture.m2libc}/linux/sys/stat.c"
"-f"
"${sources.m2libc}/string.c"
"-f"
"${sources.m2libc}/stdlib.c"
"-f"
"${sources.m2libc}/stdio.h"
"-f"
"${sources.m2libc}/stdio.c"
"-f"
"${sources.m2libc}/bootstrappable.c"
"-f"
"${sources.mescc-tools}/stringify.c"
"-f"
"${sources.mescc-tools}/M1-macro.c"
"--debug"
"-o"
(builtins.placeholder "out")
];
};
M1-macro-footer_M1 = builders.raw.build {
pname = "M1-macro-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_M1
(
if config.aux.platform.endian == "little"
then "--little-endian"
else "--big-endian"
)
"-o"
(builtins.placeholder "out")
];
};
M1-macro_hex2 = builders.raw.build {
pname = "M1-macro_hex2";
version = "1.6.0";
meta = cfg.meta;
executable = M1-0.package;
args = [
args = [
"--architecture"
architecture.m2libc
"-f"
"${sources.m2libc}/sys/types.h"
"-f"
"${sources.m2libc}/stddef.h"
"-f"
"${sources.m2libc}/${architecture.m2libc}/linux/unistd.c"
"-f"
"${sources.m2libc}/${architecture.m2libc}/linux/fcntl.c"
"-f"
"${sources.m2libc}/fcntl.c"
"-f"
"${sources.m2libc}/${architecture.m2libc}/linux/sys/stat.c"
"-f"
"${sources.m2libc}/string.c"
"-f"
"${sources.m2libc}/stdlib.c"
"-f"
"${sources.m2libc}/stdio.h"
"-f"
"${sources.m2libc}/stdio.c"
"-f"
"${sources.m2libc}/bootstrappable.c"
"-f"
"${sources.mescc-tools}/stringify.c"
"-f"
"${sources.mescc-tools}/M1-macro.c"
"--debug"
"-o"
(builtins.placeholder "out")
];
};
M1-macro-footer_M1 = builders.raw.build {
pname = "M1-macro-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_M1
(if config.aux.platform.endian == "little" then "--little-endian" else "--big-endian")
"-o"
(builtins.placeholder "out")
];
};
M1-macro_hex2 = builders.raw.build {
pname = "M1-macro_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"
M1-macro_M1
"-f"
M1-macro-footer_M1
"-o"
(builtins.placeholder "out")
];
};
in
[
"--architecture"
architecture.m2libc
(if config.aux.platform.endian == "little" then "--little-endian" else "--big-endian")
"--base-address"
(
if config.aux.platform.endian == "little"
then "--little-endian"
else "--big-endian"
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}/${architecture.m2libc}_defs.M1"
"${sources.m2libc}/${architecture.m2libc}/ELF-${architecture.m2libc}-debug.hex2"
"-f"
"${sources.m2libc}/${architecture.m2libc}/libc-full.M1"
"-f"
M1-macro_M1
"-f"
M1-macro-footer_M1
M1-macro_hex2
"-o"
(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,
}: let
{ lib, config }:
let
cfg = config.aux.foundation.stages.stage0.hex2;
hex0 = config.aux.foundation.stages.stage0.hex0;
catm = config.aux.foundation.stages.stage0.catm;
@ -16,7 +14,8 @@
builders = config.aux.foundation.builders;
sources = config.aux.foundation.stages.stage0.sources;
architecture = config.aux.foundation.stages.stage0.architecture;
in {
in
{
options.aux.foundation.stages.stage0.hex2 = {
meta = {
description = lib.options.create {
@ -41,7 +40,7 @@ in {
platforms = lib.options.create {
type = lib.types.list.of lib.types.string;
description = "Platforms the package supports.";
default.value = ["i686-linux"];
default.value = [ "i686-linux" ];
};
};
@ -53,135 +52,126 @@ in {
config = {
aux.foundation.stages.stage0.hex2 = {
package = lib.modules.overrides.default (builders.raw.build {
pname = "hex2";
version = "1.6.0";
package = lib.modules.overrides.default (
builders.raw.build {
pname = "hex2";
version = "1.6.0";
meta = cfg.meta;
meta = cfg.meta;
executable = hex2-1.package;
executable = hex2-1.package;
args = let
hex2_linker_M1 = builders.raw.build {
pname = "hex2_linker_M1";
version = "1.6.0";
args =
let
hex2_linker_M1 = builders.raw.build {
pname = "hex2_linker_M1";
version = "1.6.0";
meta = cfg.meta;
meta = cfg.meta;
executable = M2.package;
executable = M2.package;
args = [
"--architecture"
architecture.m2libc
"-f"
"${sources.m2libc}/sys/types.h"
"-f"
"${sources.m2libc}/stddef.h"
"-f"
"${sources.m2libc}/${architecture.m2libc}/linux/unistd.c"
"-f"
"${sources.m2libc}/${architecture.m2libc}/linux/fcntl.c"
"-f"
"${sources.m2libc}/fcntl.c"
"-f"
"${sources.m2libc}/${architecture.m2libc}/linux/sys/stat.c"
"-f"
"${sources.m2libc}/stdlib.c"
"-f"
"${sources.m2libc}/stdio.h"
"-f"
"${sources.m2libc}/stdio.c"
"-f"
"${sources.m2libc}/bootstrappable.c"
"-f"
"${sources.mescc-tools}/hex2.h"
"-f"
"${sources.mescc-tools}/hex2_linker.c"
"-f"
"${sources.mescc-tools}/hex2_word.c"
"-f"
"${sources.mescc-tools}/hex2.c"
"--debug"
"-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.package;
args = [
args = [
"--architecture"
architecture.m2libc
"-f"
"${sources.m2libc}/sys/types.h"
"-f"
"${sources.m2libc}/stddef.h"
"-f"
"${sources.m2libc}/${architecture.m2libc}/linux/unistd.c"
"-f"
"${sources.m2libc}/${architecture.m2libc}/linux/fcntl.c"
"-f"
"${sources.m2libc}/fcntl.c"
"-f"
"${sources.m2libc}/${architecture.m2libc}/linux/sys/stat.c"
"-f"
"${sources.m2libc}/stdlib.c"
"-f"
"${sources.m2libc}/stdio.h"
"-f"
"${sources.m2libc}/stdio.c"
"-f"
"${sources.m2libc}/bootstrappable.c"
"-f"
"${sources.mescc-tools}/hex2.h"
"-f"
"${sources.mescc-tools}/hex2_linker.c"
"-f"
"${sources.mescc-tools}/hex2_word.c"
"-f"
"${sources.mescc-tools}/hex2.c"
"--debug"
"-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.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")
];
};
in
[
"--architecture"
architecture.m2libc
(if config.aux.platform.endian == "little" then "--little-endian" else "--big-endian")
"--base-address"
(
if config.aux.platform.endian == "little"
then "--little-endian"
else "--big-endian"
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}/${architecture.m2libc}_defs.M1"
"${sources.m2libc}/${architecture.m2libc}/ELF-${architecture.m2libc}-debug.hex2"
"-f"
"${sources.m2libc}/${architecture.m2libc}/libc-full.M1"
"-f"
hex2_linker_M1
"-f"
hex2_linker-footer_M1
hex2_linker_hex2
"-o"
(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,
}: let
{ lib, config }:
let
cfg = config.aux.foundation.stages.stage0.kaem-unwrapped;
hex0 = config.aux.foundation.stages.stage0.hex0;
catm = config.aux.foundation.stages.stage0.catm;
@ -16,7 +14,8 @@
builders = config.aux.foundation.builders;
sources = config.aux.foundation.stages.stage0.sources;
architecture = config.aux.foundation.stages.stage0.architecture;
in {
in
{
options.aux.foundation.stages.stage0.kaem-unwrapped = {
meta = {
description = lib.options.create {
@ -41,7 +40,7 @@ in {
platforms = lib.options.create {
type = lib.types.list.of lib.types.string;
description = "Platforms the package supports.";
default.value = ["i686-linux"];
default.value = [ "i686-linux" ];
};
};
@ -53,137 +52,128 @@ in {
config = {
aux.foundation.stages.stage0.kaem-unwrapped = {
package = lib.modules.overrides.default (builders.raw.build {
pname = "kaem-unwrapped";
version = "1.6.0";
package = lib.modules.overrides.default (
builders.raw.build {
pname = "kaem-unwrapped";
version = "1.6.0";
meta = cfg.meta;
meta = cfg.meta;
executable = hex2.package;
executable = hex2.package;
args = let
kaem_M1 = builders.raw.build {
pname = "kaem_M1";
version = "1.6.0";
args =
let
kaem_M1 = builders.raw.build {
pname = "kaem_M1";
version = "1.6.0";
meta = cfg.meta;
meta = cfg.meta;
executable = M2.package;
executable = M2.package;
args = [
"--architecture"
architecture.m2libc
"-f"
"${sources.m2libc}/sys/types.h"
"-f"
"${sources.m2libc}/stddef.h"
"-f"
"${sources.m2libc}/${architecture.m2libc}/linux/unistd.c"
"-f"
"${sources.m2libc}/${architecture.m2libc}/linux/fcntl.c"
"-f"
"${sources.m2libc}/fcntl.c"
"-f"
"${sources.m2libc}/${architecture.m2libc}/linux/sys/stat.c"
"-f"
"${sources.m2libc}/string.c"
"-f"
"${sources.m2libc}/stdlib.c"
"-f"
"${sources.m2libc}/stdio.h"
"-f"
"${sources.m2libc}/stdio.c"
"-f"
"${sources.m2libc}/bootstrappable.c"
"-f"
"${sources.mescc-tools}/Kaem/kaem.h"
"-f"
"${sources.mescc-tools}/Kaem/variable.c"
"-f"
"${sources.mescc-tools}/Kaem/kaem_globals.c"
"-f"
"${sources.mescc-tools}/Kaem/kaem.c"
"--debug"
"-o"
(builtins.placeholder "out")
];
};
kaem-footer_M1 = builders.raw.build {
pname = "kaem-footer_M1";
version = "1.6.0";
meta = cfg.meta;
executable = blood-elf.package;
args =
(lib.lists.when (config.aux.platform.bits == 64) "--64")
++ [
"-f"
kaem_M1
(
if config.aux.platform.endian == "little"
then "--little-endian"
else "--big-endian"
)
"-o"
(builtins.placeholder "out")
];
};
kaem_hex2 = builders.raw.build {
pname = "kaem_hex2";
version = "1.6.0";
meta = cfg.meta;
executable = M1.package;
args = [
args = [
"--architecture"
architecture.m2libc
"-f"
"${sources.m2libc}/sys/types.h"
"-f"
"${sources.m2libc}/stddef.h"
"-f"
"${sources.m2libc}/${architecture.m2libc}/linux/unistd.c"
"-f"
"${sources.m2libc}/${architecture.m2libc}/linux/fcntl.c"
"-f"
"${sources.m2libc}/fcntl.c"
"-f"
"${sources.m2libc}/${architecture.m2libc}/linux/sys/stat.c"
"-f"
"${sources.m2libc}/string.c"
"-f"
"${sources.m2libc}/stdlib.c"
"-f"
"${sources.m2libc}/stdio.h"
"-f"
"${sources.m2libc}/stdio.c"
"-f"
"${sources.m2libc}/bootstrappable.c"
"-f"
"${sources.mescc-tools}/Kaem/kaem.h"
"-f"
"${sources.mescc-tools}/Kaem/variable.c"
"-f"
"${sources.mescc-tools}/Kaem/kaem_globals.c"
"-f"
"${sources.mescc-tools}/Kaem/kaem.c"
"--debug"
"-o"
(builtins.placeholder "out")
];
};
kaem-footer_M1 = builders.raw.build {
pname = "kaem-footer_M1";
version = "1.6.0";
meta = cfg.meta;
executable = blood-elf.package;
args = (lib.lists.when (config.aux.platform.bits == 64) "--64") ++ [
"-f"
kaem_M1
(if config.aux.platform.endian == "little" then "--little-endian" else "--big-endian")
"-o"
(builtins.placeholder "out")
];
};
kaem_hex2 = builders.raw.build {
pname = "kaem_hex2";
version = "1.6.0";
meta = cfg.meta;
executable = M1.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"
kaem_M1
"-f"
kaem-footer_M1
"-o"
(builtins.placeholder "out")
];
};
in
[
"--architecture"
architecture.m2libc
(if config.aux.platform.endian == "little" then "--little-endian" else "--big-endian")
"--base-address"
(
if config.aux.platform.endian == "little"
then "--little-endian"
else "--big-endian"
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}/${architecture.m2libc}_defs.M1"
"${sources.m2libc}/${architecture.m2libc}/ELF-${architecture.m2libc}-debug.hex2"
"-f"
"${sources.m2libc}/${architecture.m2libc}/libc-full.M1"
"-f"
kaem_M1
"-f"
kaem-footer_M1
kaem_hex2
"-o"
(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,
}: let
{ lib, config }:
let
system = config.aux.system;
architecture = config.aux.foundation.stages.stage0.architecture.base;
in {
in
{
options.aux.foundation.stages.stage0.sources = {
base = lib.options.create {
type = lib.types.string;
@ -44,27 +43,25 @@ in {
# fetching that, we are instead fetching each submodule directly. The central repository is located
# here: https://github.com/oriansj/stage0-posix
base =
if architecture == "AMD64"
then
if architecture == "AMD64" then
builtins.fetchTarball {
url = "https://github.com/oriansj/stage0-posix-amd64/archive/93fbe4c08772d8df1412e2554668e24cf604088c.tar.gz";
sha256 = "10d1xnjzqplpfip3pm89bydd501x1bcgkg7lkkadyq5bqpad5flp";
}
else if architecture == "AArch64"
then
else if architecture == "AArch64" then
# FIXME: We may need to patch the aarch64 variant.
# https://github.com/oriansj/M2libc/pull/17
builtins.fetchTarball {
url = "https://github.com/oriansj/stage0-posix-aarch64/archive/39a43f803d572b53f95d42507202152eeda18361.tar.gz";
sha256 = "1x607hr3n5j89394d156r23igpx8hifjd14ygksx7902rlwrrry2";
}
else if architecture == "x86"
then
else if architecture == "x86" then
builtins.fetchTarball {
url = "https://github.com/oriansj/stage0-posix-x86/archive/e86bf7d304bae5ce5ccc88454bb60cf0837e941f.tar.gz";
sha256 = "1c1fk793yzq8zbg60n2zd22fsmirc3zr26fj0iskap456g84nxv8";
}
else builtins.throw "Unsupported architecture for stage0: ${architecture}";
else
builtins.throw "Unsupported architecture for stage0: ${architecture}";
m2libc = builtins.fetchTarball {
url = "https://github.com/oriansj/M2libc/archive/de7c75f144176c3b9be77695d9bf94440445aeae.tar.gz";

View file

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

View file

@ -1,17 +1,14 @@
{
lib,
config,
}: let
{ lib, config }:
let
cfg = config.aux.foundation.stages.stage1.bash;
platform = config.aux.platform;
builders = config.aux.foundation.builders;
stage1 = config.aux.foundation.stages.stage1;
in {
includes = [
./boot.nix
];
in
{
includes = [ ./boot.nix ];
options.aux.foundation.stages.stage1.bash = {
meta = {
@ -37,7 +34,7 @@ in {
platforms = lib.options.create {
type = lib.types.list.of lib.types.string;
description = "Platforms the package supports.";
default.value = ["i686-linux"];
default.value = [ "i686-linux" ];
};
mainProgram = lib.options.create {
@ -72,12 +69,13 @@ in {
sha256 = "132qng0jy600mv1fs95ylnlisx2wavkkgpb19c6kmz7lnmjhjwhk";
};
package = let
patches = [
# flush output for generated code
./patches/mksignames-flush.patch
];
in
package =
let
patches = [
# flush output for generated code
./patches/mksignames-flush.patch
];
in
builders.bash.boot.build {
name = "bash-${cfg.version}";

View file

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

View file

@ -1,14 +1,13 @@
{
lib,
config,
}: let
{ lib, config }:
let
cfg = config.aux.foundation.stages.stage1.bison;
platform = config.aux.platform;
builders = config.aux.foundation.builders;
stage1 = config.aux.foundation.stages.stage1;
in {
in
{
options.aux.foundation.stages.stage1.bison = {
meta = {
description = lib.options.create {
@ -33,7 +32,7 @@ in {
platforms = lib.options.create {
type = lib.types.list.of lib.types.string;
description = "Platforms the package supports.";
default.value = ["i686-linux"];
default.value = [ "i686-linux" ];
};
};

View file

@ -1,14 +1,13 @@
{
lib,
config,
}: let
{ lib, config }:
let
cfg = config.aux.foundation.stages.stage1.bzip2;
platform = config.aux.platform;
builders = config.aux.foundation.builders;
stage1 = config.aux.foundation.stages.stage1;
in {
in
{
options.aux.foundation.stages.stage1.bzip2 = {
meta = {
description = lib.options.create {
@ -34,7 +33,7 @@ in {
type = lib.types.list.of lib.types.string;
description = "Platforms the package supports.";
# TODO: Support more platforms.
default.value = ["i686-linux"];
default.value = [ "i686-linux" ];
};
};

View file

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

View file

@ -1,17 +1,14 @@
{
lib,
config,
}: let
{ lib, config }:
let
cfg = config.aux.foundation.stages.stage1.coreutils;
platform = config.aux.platform;
builders = config.aux.foundation.builders;
stage1 = config.aux.foundation.stages.stage1;
in {
includes = [
./boot.nix
];
in
{
includes = [ ./boot.nix ];
options.aux.foundation.stages.stage1.coreutils = {
meta = {
@ -37,7 +34,7 @@ in {
platforms = lib.options.create {
type = lib.types.list.of lib.types.string;
description = "Platforms the package supports.";
default.value = ["i686-linux"];
default.value = [ "i686-linux" ];
};
};
@ -66,17 +63,18 @@ in {
sha256 = "X2ANkJOXOwr+JTk9m8GMRPIjJlf0yg2V6jHHAutmtzk=";
};
package = let
configureFlags = [
"--prefix=${builtins.placeholder "out"}"
"--build=${platform.build}"
"--host=${platform.host}"
# musl 1.1.x doesn't use 64bit time_t
"--disable-year2038"
# libstdbuf.so fails in static builds
"--enable-no-install-program=stdbuf"
];
in
package =
let
configureFlags = [
"--prefix=${builtins.placeholder "out"}"
"--build=${platform.build}"
"--host=${platform.host}"
# musl 1.1.x doesn't use 64bit time_t
"--disable-year2038"
# libstdbuf.so fails in static builds
"--enable-no-install-program=stdbuf"
];
in
builders.bash.boot.build {
name = "coreutils-${cfg.version}";

View file

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

View file

@ -1,14 +1,13 @@
{
lib,
config,
}: let
{ lib, config }:
let
cfg = config.aux.foundation.stages.stage1.diffutils;
platform = config.aux.platform;
builders = config.aux.foundation.builders;
stage1 = config.aux.foundation.stages.stage1;
in {
in
{
options.aux.foundation.stages.stage1.diffutils = {
meta = {
description = lib.options.create {
@ -33,7 +32,7 @@ in {
platforms = lib.options.create {
type = lib.types.list.of lib.types.string;
description = "Platforms the package supports.";
default.value = ["i686-linux"];
default.value = [ "i686-linux" ];
};
};

View file

@ -1,14 +1,13 @@
{
lib,
config,
}: let
{ lib, config }:
let
cfg = config.aux.foundation.stages.stage1.findutils;
platform = config.aux.platform;
builders = config.aux.foundation.builders;
stage1 = config.aux.foundation.stages.stage1;
in {
in
{
options.aux.foundation.stages.stage1.findutils = {
meta = {
description = lib.options.create {
@ -33,7 +32,7 @@ in {
platforms = lib.options.create {
type = lib.types.list.of lib.types.string;
description = "Platforms the package supports.";
default.value = ["i686-linux"];
default.value = [ "i686-linux" ];
};
};

View file

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

View file

@ -1,17 +1,14 @@
{
lib,
config,
}: let
{ lib, config }:
let
cfg = config.aux.foundation.stages.stage1.gawk;
platform = config.aux.platform;
builders = config.aux.foundation.builders;
stage1 = config.aux.foundation.stages.stage1;
in {
includes = [
./boot.nix
];
in
{
includes = [ ./boot.nix ];
options.aux.foundation.stages.stage1.gawk = {
meta = {
@ -37,7 +34,7 @@ in {
platforms = lib.options.create {
type = lib.types.list.of lib.types.string;
description = "Platforms the package supports.";
default.value = ["i686-linux"];
default.value = [ "i686-linux" ];
};
mainProgram = lib.options.create {

View file

@ -1,14 +1,13 @@
{
lib,
config,
}: let
{ lib, config }:
let
cfg = config.aux.foundation.stages.stage1.gcc;
platform = config.aux.platform;
builders = config.aux.foundation.builders;
stage1 = config.aux.foundation.stages.stage1;
in {
in
{
includes = [
./v4.6.nix
./v4.6.cxx.nix
@ -39,7 +38,7 @@ in {
platforms = lib.options.create {
type = lib.types.list.of lib.types.string;
description = "Platforms the package supports.";
default.value = ["i686-linux"];
default.value = [ "i686-linux" ];
};
};

View file

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

View file

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

View file

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

View file

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

View file

@ -1,14 +1,13 @@
{
lib,
config,
}: let
{ lib, config }:
let
cfg = config.aux.foundation.stages.stage1.gnum4;
platform = config.aux.platform;
builders = config.aux.foundation.builders;
stage1 = config.aux.foundation.stages.stage1;
in {
in
{
options.aux.foundation.stages.stage1.gnum4 = {
meta = {
description = lib.options.create {
@ -33,7 +32,7 @@ in {
platforms = lib.options.create {
type = lib.types.list.of lib.types.string;
description = "Platforms the package supports.";
default.value = ["i686-linux"];
default.value = [ "i686-linux" ];
};
};

View file

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

View file

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

View file

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

View file

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

View file

@ -1,17 +1,14 @@
{
lib,
config,
}: let
{ lib, config }:
let
cfg = config.aux.foundation.stages.stage1.gnused;
platform = config.aux.platform;
builders = config.aux.foundation.builders;
stage1 = config.aux.foundation.stages.stage1;
in {
includes = [
./boot.nix
];
in
{
includes = [ ./boot.nix ];
options.aux.foundation.stages.stage1.gnused = {
meta = {
@ -37,7 +34,7 @@ in {
platforms = lib.options.create {
type = lib.types.list.of lib.types.string;
description = "Platforms the package supports.";
default.value = ["i686-linux"];
default.value = [ "i686-linux" ];
};
mainProgram = lib.options.create {

View file

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

View file

@ -1,14 +1,13 @@
{
lib,
config,
}: let
{ lib, config }:
let
cfg = config.aux.foundation.stages.stage1.gnutar;
platform = config.aux.platform;
builders = config.aux.foundation.builders;
stage1 = config.aux.foundation.stages.stage1;
in {
in
{
includes = [
./boot.nix
./musl.nix
@ -38,7 +37,7 @@ in {
platforms = lib.options.create {
type = lib.types.list.of lib.types.string;
description = "Platforms the package supports.";
default.value = ["i686-linux"];
default.value = [ "i686-linux" ];
};
mainProgram = lib.options.create {

View file

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

View file

@ -1,13 +1,12 @@
{
lib,
config,
}: let
{ lib, config }:
let
cfg = config.aux.foundation.stages.stage1.gzip;
builders = config.aux.foundation.builders;
stage1 = config.aux.foundation.stages.stage1;
in {
in
{
options.aux.foundation.stages.stage1.gzip = {
meta = {
description = lib.options.create {
@ -32,7 +31,7 @@ in {
platforms = lib.options.create {
type = lib.types.list.of lib.types.string;
description = "Platforms the package supports.";
default.value = ["i686-linux"];
default.value = [ "i686-linux" ];
};
};
@ -61,8 +60,9 @@ in {
sha256 = "0ryr5b00qz3xcdcv03qwjdfji8pasp0007ay3ppmk71wl8c1i90w";
};
package = let
in
package =
let
in
builders.bash.boot.build {
name = "gzip-${cfg.version}";
meta = cfg.meta;

View file

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

View file

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

View file

@ -1,14 +1,13 @@
{
lib,
config,
}: let
{ lib, config }:
let
cfg = config.aux.foundation.stages.stage1.linux-headers;
platform = config.aux.platform;
builders = config.aux.foundation.builders;
stage1 = config.aux.foundation.stages.stage1;
in {
in
{
options.aux.foundation.stages.stage1.linux-headers = {
meta = {
description = lib.options.create {
@ -27,7 +26,7 @@ in {
platforms = lib.options.create {
type = lib.types.list.of lib.types.string;
description = "Platforms the package supports.";
default.value = ["i686-linux"];
default.value = [ "i686-linux" ];
};
};

View file

@ -1,14 +1,13 @@
{
lib,
config,
}: let
{ lib, config }:
let
cfg = config.aux.foundation.stages.stage1.ln-boot;
builders = config.aux.foundation.builders;
stage0 = config.aux.foundation.stages.stage0;
stage1 = config.aux.foundation.stages.stage1;
in {
in
{
options.aux.foundation.stages.stage1.ln-boot = {
meta = {
description = lib.options.create {
@ -33,7 +32,7 @@ in {
platforms = lib.options.create {
type = lib.types.list.of lib.types.string;
description = "Platforms the package supports.";
default.value = ["i686-linux"];
default.value = [ "i686-linux" ];
};
};

View file

@ -1,7 +1,5 @@
{
lib,
config,
}: let
{ lib, config }:
let
cfg = config.aux.foundation.stages.stage1.mes.compiler;
system = config.aux.system;
@ -9,7 +7,8 @@
stage0 = config.aux.foundation.stages.stage0;
stage1 = config.aux.foundation.stages.stage1;
in {
in
{
options.aux.foundation.stages.stage1.mes.compiler = {
meta = {
description = lib.options.create {
@ -34,7 +33,7 @@ in {
platforms = lib.options.create {
type = lib.types.list.of lib.types.string;
description = "Platforms the package supports.";
default.value = ["i686-linux"];
default.value = [ "i686-linux" ];
};
};
@ -46,45 +45,46 @@ in {
config = {
aux.foundation.stages.stage1.mes.compiler = {
package = let
compile = path: let
file = builtins.baseNameOf path;
fileWithoutExtension = builtins.replaceStrings [".c"] [""] file;
package =
let
compile =
path:
let
file = builtins.baseNameOf path;
fileWithoutExtension = builtins.replaceStrings [ ".c" ] [ "" ] file;
cc = builtins.concatStringsSep " " [
"${stage1.mes.libs.src.bin}/bin/mes-m2"
"-e"
"main"
"${stage1.mes.libs.src.bin}/bin/mescc.scm"
"--"
"-D"
"HAVE_CONFIG_H=1"
"-I"
"${stage1.mes.libs.prefix}/include"
"-I"
"${stage1.mes.libs.prefix}/include/linux/x86"
];
cc = builtins.concatStringsSep " " [
"${stage1.mes.libs.src.bin}/bin/mes-m2"
"-e"
"main"
"${stage1.mes.libs.src.bin}/bin/mescc.scm"
"--"
"-D"
"HAVE_CONFIG_H=1"
"-I"
"${stage1.mes.libs.prefix}/include"
"-I"
"${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
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 {
name = "mes-${stage1.mes.version}";

View file

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

View file

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

View file

@ -1,7 +1,5 @@
{
lib,
config,
}: let
{ lib, config }:
let
cfg = config.aux.foundation.stages.stage1.mes.libs;
system = config.aux.system;
@ -9,7 +7,8 @@
stage0 = config.aux.foundation.stages.stage0;
stage1 = config.aux.foundation.stages.stage1;
in {
in
{
options.aux.foundation.stages.stage1.mes.libs = {
meta = {
description = lib.options.create {
@ -34,7 +33,7 @@ in {
platforms = lib.options.create {
type = lib.types.list.of lib.types.string;
description = "Platforms the package supports.";
default.value = ["i686-linux"];
default.value = [ "i686-linux" ];
};
};
@ -58,12 +57,13 @@ in {
aux.foundation.stages.stage1.mes.libs = {
prefix = "${cfg.src.out}/mes-${stage1.mes.version}";
src = let
config_h = builtins.toFile "config.h" ''
#undef SYSTEM_LIBC
#define MES_VERSION "${stage1.mes.version}"
'';
in
src =
let
config_h = builtins.toFile "config.h" ''
#undef SYSTEM_LIBC
#define MES_VERSION "${stage1.mes.version}"
'';
in
builders.kaem.build {
name = "mes-src-${stage1.mes.version}";
@ -140,71 +140,82 @@ in {
'';
};
package = let
compile = path: let
file = builtins.baseNameOf path;
fileWithoutExtension = builtins.replaceStrings [".c"] [""] file;
package =
let
compile =
path:
let
file = builtins.baseNameOf path;
fileWithoutExtension = builtins.replaceStrings [ ".c" ] [ "" ] file;
cc = builtins.concatStringsSep " " [
"${cfg.src.bin}/bin/mes-m2"
"-e"
"main"
"${cfg.src.bin}/bin/mescc.scm"
"--"
"-D"
"HAVE_CONFIG_H=1"
"-I"
"${cfg.prefix}/include"
"-I"
"${cfg.prefix}/include/linux/x86"
];
cc = builtins.concatStringsSep " " [
"${cfg.src.bin}/bin/mes-m2"
"-e"
"main"
"${cfg.src.bin}/bin/mescc.scm"
"--"
"-D"
"HAVE_CONFIG_H=1"
"-I"
"${cfg.prefix}/include"
"-I"
"${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
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 {
name = "mes-m2-libs-${stage1.mes.version}";

View file

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

View file

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

View file

@ -1,17 +1,14 @@
{
lib,
config,
}: let
{ lib, config }:
let
cfg = config.aux.foundation.stages.stage1.musl;
platform = config.aux.platform;
builders = config.aux.foundation.builders;
stage1 = config.aux.foundation.stages.stage1;
in {
includes = [
./boot.nix
];
in
{
includes = [ ./boot.nix ];
options.aux.foundation.stages.stage1.musl = {
meta = {
@ -38,7 +35,7 @@ in {
type = lib.types.list.of lib.types.string;
description = "Platforms the package supports.";
# TODO: Support more platforms.
default.value = ["i686-linux"];
default.value = [ "i686-linux" ];
};
};

View file

@ -1,7 +1,5 @@
{
lib,
config,
}: let
{ lib, config }:
let
cfg = config.aux.foundation.stages.stage1.nyacc;
builders = config.aux.foundation.builders;
@ -10,7 +8,8 @@
pname = "nyacc";
version = "1.00.2";
in {
in
{
options.aux.foundation.stages.stage1.nyacc = {
meta = {
description = lib.options.create {
@ -35,7 +34,7 @@ in {
platforms = lib.options.create {
type = lib.types.list.of lib.types.string;
description = "Platforms the package supports.";
default.value = ["i686-linux"];
default.value = [ "i686-linux" ];
};
};

View file

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

View file

@ -1,7 +1,5 @@
args @ {
lib,
config,
}: let
args@{ lib, config }:
let
cfg = config.aux.foundation.stages.stage1.tinycc.boot;
builders = config.aux.foundation.builders;
@ -11,7 +9,8 @@ args @ {
pname = "tinycc-boot";
helpers = lib.fp.withDynamicArgs (import ./helpers.nix) args;
in {
in
{
options.aux.foundation.stages.stage1.tinycc.boot = {
meta = {
description = lib.options.create {
@ -36,7 +35,10 @@ in {
platforms = lib.options.create {
type = lib.types.list.of lib.types.string;
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 = {
aux.foundation.stages.stage1.tinycc.boot = let
tinycc-boot = let
tinycc-mes-bootstrappable = helpers.createBoot {
pname = "tinycc-mes-bootstrappable";
version = stage1.tinycc.version;
src = cfg.src;
};
aux.foundation.stages.stage1.tinycc.boot =
let
tinycc-boot =
let
tinycc-mes-bootstrappable = helpers.createBoot {
pname = "tinycc-mes-bootstrappable";
version = stage1.tinycc.version;
src = cfg.src;
};
tinycc-boot0 = helpers.createTinyccMes {
pname = "tinycc-boot0";
version = stage1.tinycc.version;
src = cfg.src;
args = [
"-D HAVE_LONG_LONG_STUB=1"
"-D HAVE_SETJMP=1"
];
lib.args = [
"-D HAVE_LONG_LONG_STUB=1"
];
boot = tinycc-mes-bootstrappable;
meta = cfg.meta;
};
tinycc-boot0 = helpers.createTinyccMes {
pname = "tinycc-boot0";
version = stage1.tinycc.version;
src = cfg.src;
args = [
"-D HAVE_LONG_LONG_STUB=1"
"-D HAVE_SETJMP=1"
];
lib.args = [ "-D HAVE_LONG_LONG_STUB=1" ];
boot = tinycc-mes-bootstrappable;
meta = cfg.meta;
};
tinycc-boot1 = helpers.createTinyccMes {
pname = "tinycc-boot1";
version = stage1.tinycc.version;
src = cfg.src;
args = [
"-D HAVE_BITFIELD=1"
"-D HAVE_LONG_LONG=1"
"-D HAVE_SETJMP=1"
];
lib.args = [
"-D HAVE_LONG_LONG=1"
];
boot = tinycc-boot0;
meta = cfg.meta;
};
tinycc-boot1 = helpers.createTinyccMes {
pname = "tinycc-boot1";
version = stage1.tinycc.version;
src = cfg.src;
args = [
"-D HAVE_BITFIELD=1"
"-D HAVE_LONG_LONG=1"
"-D HAVE_SETJMP=1"
];
lib.args = [ "-D HAVE_LONG_LONG=1" ];
boot = tinycc-boot0;
meta = cfg.meta;
};
tinycc-boot2 = helpers.createTinyccMes {
pname = "tinycc-boot2";
version = stage1.tinycc.version;
src = cfg.src;
args = [
"-D HAVE_BITFIELD=1"
"-D HAVE_FLOAT_STUB=1"
"-D HAVE_LONG_LONG=1"
"-D HAVE_SETJMP=1"
];
lib.args = [
"-D HAVE_FLOAT_STUB=1"
"-D HAVE_LONG_LONG=1"
];
boot = tinycc-boot1;
meta = cfg.meta;
};
tinycc-boot2 = helpers.createTinyccMes {
pname = "tinycc-boot2";
version = stage1.tinycc.version;
src = cfg.src;
args = [
"-D HAVE_BITFIELD=1"
"-D HAVE_FLOAT_STUB=1"
"-D HAVE_LONG_LONG=1"
"-D HAVE_SETJMP=1"
];
lib.args = [
"-D HAVE_FLOAT_STUB=1"
"-D HAVE_LONG_LONG=1"
];
boot = tinycc-boot1;
meta = cfg.meta;
};
tinycc-boot3 = helpers.createTinyccMes {
pname = "tinycc-boot3";
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-boot2;
meta = cfg.meta;
};
tinycc-boot3 = helpers.createTinyccMes {
pname = "tinycc-boot3";
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-boot2;
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
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 {
revision = "80114c4da6b17fbaabb399cc29f427e368309bc8";
{
revision = "80114c4da6b17fbaabb399cc29f427e368309bc8";
libs.package = tinycc-boot.libs;
compiler.package = tinycc-boot.compiler;
libs.package = tinycc-boot.libs;
compiler.package = tinycc-boot.compiler;
src = let
tarball = builtins.fetchurl {
url = "https://gitlab.com/janneke/tinycc/-/archive/${cfg.revision}/tinycc-${cfg.revision}.tar.gz";
sha256 = "1a0cw9a62qc76qqn5sjmp3xrbbvsz2dxrw21lrnx9q0s74mwaxbq";
};
src =
let
tarball = builtins.fetchurl {
url = "https://gitlab.com/janneke/tinycc/-/archive/${cfg.revision}/tinycc-${cfg.revision}.tar.gz";
sha256 = "1a0cw9a62qc76qqn5sjmp3xrbbvsz2dxrw21lrnx9q0s74mwaxbq";
};
patched = builders.kaem.build {
name = "${pname}-src";
patched = builders.kaem.build {
name = "${pname}-src";
meta = stage1.tinycc.meta;
meta = stage1.tinycc.meta;
script = ''
ungz --file ${tarball} --output tinycc.tar
mkdir -p ''${out}
cd ''${out}
untar --file ''${NIX_BUILD_TOP}/tinycc.tar
script = ''
ungz --file ${tarball} --output tinycc.tar
mkdir -p ''${out}
cd ''${out}
untar --file ''${NIX_BUILD_TOP}/tinycc.tar
# Patch
cd tinycc-${cfg.revision}
# Patch
cd tinycc-${cfg.revision}
# 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;"
'';
};
in "${patched}/tinycc-${cfg.revision}";
};
# 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;"
'';
};
in
"${patched}/tinycc-${cfg.revision}";
};
};
}

View file

@ -1,13 +1,12 @@
{
lib,
config,
}: let
{ lib, config }:
let
cfg = config.aux.foundation.stages.stage1.tinycc;
builders = config.aux.foundation.builders;
stage1 = config.aux.foundation.stages.stage1;
in {
in
{
includes = [
./boot.nix
./mes.nix
@ -38,7 +37,7 @@ in {
platforms = lib.options.create {
type = lib.types.list.of lib.types.string;
description = "Platforms the package supports.";
default.value = ["i686-linux"];
default.value = [ "i686-linux" ];
};
};

View file

@ -1,7 +1,5 @@
{
lib,
config,
}: let
{ lib, config }:
let
cfg = config.aux.foundation.stages.stage1.tinycc.boot;
builders = config.aux.foundation.builders;
@ -9,151 +7,163 @@
stage1 = config.aux.foundation.stages.stage1;
cflags = stage1.mes.libc.package.extras.CFLAGS;
createBoot = {
pname,
version,
src,
}: let
compiler = builders.kaem.build {
name = "${pname}-${version}";
script = ''
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";
createBoot =
{
pname,
version,
src,
}:
let
compiler = builders.kaem.build {
name = "${pname}-${version}";
script = ''
${tinycc}/bin/tcc ${args} -c -o ${name}.o ${source}
${tinycc}/bin/tcc -ar cr ''${out} ${name}.o
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
'';
};
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
'';
libs = createLibc {
inherit pname version;
src = stage1.mes.libc.package;
args = cflags;
tinycc = compiler;
};
in
{
inherit compiler libs;
};
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
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 = ''
${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 {
name = "${pname}-libs-${version}";
@ -167,10 +177,7 @@
cp ${libgetopt} ''${out}/lib/libgetopt.a
'';
};
in {
inherit
createBoot
createTinyccMes
createLibc
;
in
{
inherit createBoot createTinyccMes createLibc;
}

View file

@ -1,7 +1,5 @@
args @ {
lib,
config,
}: let
args@{ lib, config }:
let
cfg = config.aux.foundation.stages.stage1.tinycc.mes;
builders = config.aux.foundation.builders;
@ -11,7 +9,8 @@ args @ {
pname = "tinycc-mes";
helpers = lib.fp.withDynamicArgs (import ./helpers.nix) args;
in {
in
{
options.aux.foundation.stages.stage1.tinycc.mes = {
compiler = {
package = lib.options.create {
@ -39,104 +38,109 @@ in {
};
config = {
aux.foundation.stages.stage1.tinycc.mes = let
tinycc-mes = let
tccdefs = builders.kaem.build {
name = "tccdefs-${stage1.tinycc.version}";
aux.foundation.stages.stage1.tinycc.mes =
let
tinycc-mes =
let
tccdefs = builders.kaem.build {
name = "tccdefs-${stage1.tinycc.version}";
script = ''
mkdir ''${out}
${stage1.tinycc.boot.compiler.package}/bin/tcc \
-B ${stage1.tinycc.boot.libs.package}/lib \
-DC2STR \
-o c2str \
${cfg.src}/conftest.c
./c2str ${cfg.src}/include/tccdefs.h ''${out}/tccdefs_.h
'';
};
script = ''
mkdir ''${out}
${stage1.tinycc.boot.compiler.package}/bin/tcc \
-B ${stage1.tinycc.boot.libs.package}/lib \
-DC2STR \
-o c2str \
${cfg.src}/conftest.c
./c2str ${cfg.src}/include/tccdefs.h ''${out}/tccdefs_.h
'';
};
tinycc-mes-boot = helpers.createTinyccMes {
pname = "${pname}-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"
"-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 = {
libs = stage1.tinycc.boot.libs.package;
compiler = stage1.tinycc.boot.compiler.package;
tinycc-mes-boot = helpers.createTinyccMes {
pname = "${pname}-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"
"-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 = {
libs = stage1.tinycc.boot.libs.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
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;
};
in {
revision = "86f3d8e33105435946383aee52487b5ddf918140";
{
revision = "86f3d8e33105435946383aee52487b5ddf918140";
libs.package = tinycc-mes.libs;
compiler.package = tinycc-mes.compiler;
libs.package = tinycc-mes.libs;
compiler.package = tinycc-mes.compiler;
src = let
tarball = builtins.fetchurl {
url = "https://repo.or.cz/tinycc.git/snapshot/${cfg.revision}.tar.gz";
sha256 = "11idrvbwfgj1d03crv994mpbbbyg63j1k64lw1gjy7mkiifw2xap";
};
src =
let
tarball = builtins.fetchurl {
url = "https://repo.or.cz/tinycc.git/snapshot/${cfg.revision}.tar.gz";
sha256 = "11idrvbwfgj1d03crv994mpbbbyg63j1k64lw1gjy7mkiifw2xap";
};
patched = builders.kaem.build {
name = "${pname}-src";
patched = builders.kaem.build {
name = "${pname}-src";
meta = stage1.tinycc.meta;
meta = stage1.tinycc.meta;
script = ''
ungz --file ${tarball} --output tinycc.tar
mkdir -p ''${out}
cd ''${out}
untar --file ''${NIX_BUILD_TOP}/tinycc.tar
script = ''
ungz --file ${tarball} --output tinycc.tar
mkdir -p ''${out}
cd ''${out}
untar --file ''${NIX_BUILD_TOP}/tinycc.tar
# Patch
cd tinycc-${builtins.substring 0 7 cfg.revision}
# Patch
cd tinycc-${builtins.substring 0 7 cfg.revision}
# 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;"
'';
};
in "${patched}/tinycc-${builtins.substring 0 7 cfg.revision}";
};
# 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;"
'';
};
in
"${patched}/tinycc-${builtins.substring 0 7 cfg.revision}";
};
};
}

View file

@ -1,7 +1,5 @@
args @ {
lib,
config,
}: let
args@{ lib, config }:
let
cfg = config.aux.foundation.stages.stage1.tinycc.musl;
builders = config.aux.foundation.builders;
@ -11,7 +9,8 @@ args @ {
pname = "tinycc-musl";
helpers = lib.fp.withDynamicArgs (import ./helpers.nix) args;
in {
in
{
options.aux.foundation.stages.stage1.tinycc.musl = {
compiler = {
package = lib.options.create {
@ -39,139 +38,141 @@ in {
};
config = {
aux.foundation.stages.stage1.tinycc.musl = let
patches = [
./patches/ignore-duplicate-symbols.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
aux.foundation.stages.stage1.tinycc.musl =
let
patches = [
./patches/ignore-duplicate-symbols.patch
./patches/ignore-static-inside-array.patch
./patches/static-link.patch
];
script = ''
# Unpack
tar xzf ${cfg.src}
cd tinycc-${builtins.substring 0 7 cfg.revision}
tinycc-musl = builders.bash.boot.build {
name = "${pname}-${stage1.tinycc.version}";
# Patch
${lib.strings.concatMapSep "\n" (file: "patch -Np0 -i ${file}") patches}
meta = stage1.tinycc.meta;
# Configure
touch config.h
deps.build.host = [
stage1.tinycc.boot.compiler.package
stage1.gnupatch.package
stage1.gnutar.boot.package
stage1.gzip.package
];
# Build
# We first have to recompile using tcc-0.9.26 as tcc-0.9.27 is not self-hosting,
# but when linked with musl it is.
ln -s ${stage1.musl.boot.package}/lib/libtcc1.a ./libtcc1.a
script = ''
# Unpack
tar xzf ${cfg.src}
cd tinycc-${builtins.substring 0 7 cfg.revision}
tcc \
-B ${stage1.tinycc.boot.libs.package}/lib \
-DC2STR \
-o c2str \
conftest.c
./c2str include/tccdefs.h tccdefs_.h
# Patch
${lib.strings.concatMapSep "\n" (file: "patch -Np0 -i ${file}") patches}
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
# Configure
touch config.h
# 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
# Build
# We first have to recompile using tcc-0.9.26 as tcc-0.9.27 is not self-hosting,
# but when linked with musl it is.
ln -s ${stage1.musl.boot.package}/lib/libtcc1.a ./libtcc1.a
# Install
install -D tcc-musl $out/bin/tcc
install -Dm444 libtcc1.a $out/lib/libtcc1.a
'';
tcc \
-B ${stage1.tinycc.boot.libs.package}/lib \
-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,
}: let
{ lib, config }:
let
cfg = config.aux.foundation.stages.stage1.xz;
platform = config.aux.platform;
builders = config.aux.foundation.builders;
stage1 = config.aux.foundation.stages.stage1;
in {
in
{
options.aux.foundation.stages.stage1.xz = {
meta = {
description = lib.options.create {
@ -36,7 +35,7 @@ in {
platforms = lib.options.create {
type = lib.types.list.of lib.types.string;
description = "Platforms the package supports.";
default.value = ["i686-linux"];
default.value = [ "i686-linux" ];
};
};

View file

@ -1,14 +1,13 @@
{
lib,
config,
}: let
{ lib, config }:
let
cfg = config.aux.foundation.stages.stage1.zlib;
platform = config.aux.platform;
builders = config.aux.foundation.builders;
stage1 = config.aux.foundation.stages.stage1;
in {
in
{
options.aux.foundation.stages.stage1.zlib = {
meta = {
description = lib.options.create {
@ -33,7 +32,7 @@ in {
platforms = lib.options.create {
type = lib.types.list.of lib.types.string;
description = "Platforms the package supports.";
default.value = ["i686-linux"];
default.value = [ "i686-linux" ];
};
};

View file

@ -1,14 +1,13 @@
{
lib,
config,
}: let
{ lib, config }:
let
cfg = config.aux.foundation.stages.stage2.bash;
platform = config.aux.platform;
builders = config.aux.foundation.builders;
stage1 = config.aux.foundation.stages.stage1;
in {
in
{
options.aux.foundation.stages.stage2.bash = {
meta = {
description = lib.options.create {
@ -33,7 +32,7 @@ in {
platforms = lib.options.create {
type = lib.types.list.of lib.types.string;
description = "Platforms the package supports.";
default.value = ["i686-linux"];
default.value = [ "i686-linux" ];
};
mainProgram = lib.options.create {

View file

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

View file

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

View file

@ -1,14 +1,13 @@
{
lib,
config,
}: let
{ lib, config }:
let
cfg = config.aux.foundation.stages.stage2.bzip2;
platform = config.aux.platform;
builders = config.aux.foundation.builders;
stage1 = config.aux.foundation.stages.stage1;
in {
in
{
options.aux.foundation.stages.stage2.bzip2 = {
meta = {
description = lib.options.create {
@ -34,7 +33,7 @@ in {
type = lib.types.list.of lib.types.string;
description = "Platforms the package supports.";
# TODO: Support more platforms.
default.value = ["i686-linux"];
default.value = [ "i686-linux" ];
};
};

View file

@ -1,14 +1,13 @@
{
lib,
config,
}: let
{ lib, config }:
let
cfg = config.aux.foundation.stages.stage2.coreutils;
platform = config.aux.platform;
builders = config.aux.foundation.builders;
stage1 = config.aux.foundation.stages.stage1;
in {
in
{
options.aux.foundation.stages.stage2.coreutils = {
meta = {
description = lib.options.create {
@ -33,7 +32,7 @@ in {
platforms = lib.options.create {
type = lib.types.list.of lib.types.string;
description = "Platforms the package supports.";
default.value = ["i686-linux"];
default.value = [ "i686-linux" ];
};
};
@ -62,18 +61,19 @@ in {
sha256 = "X2ANkJOXOwr+JTk9m8GMRPIjJlf0yg2V6jHHAutmtzk=";
};
package = let
configureFlags = [
"--prefix=${builtins.placeholder "out"}"
"--build=${platform.build}"
"--host=${platform.host}"
# libstdbuf.so fails in static builds
"--enable-no-install-program=stdbuf"
"--enable-single-binary=symlinks"
"CC=musl-gcc"
"CFLAGS=-static"
];
in
package =
let
configureFlags = [
"--prefix=${builtins.placeholder "out"}"
"--build=${platform.build}"
"--host=${platform.host}"
# libstdbuf.so fails in static builds
"--enable-no-install-program=stdbuf"
"--enable-single-binary=symlinks"
"CC=musl-gcc"
"CFLAGS=-static"
];
in
builders.bash.build {
name = "coreutils-${cfg.version}";

View file

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

View file

@ -1,14 +1,13 @@
{
lib,
config,
}: let
{ lib, config }:
let
cfg = config.aux.foundation.stages.stage2.diffutils;
platform = config.aux.platform;
builders = config.aux.foundation.builders;
stage1 = config.aux.foundation.stages.stage1;
in {
in
{
options.aux.foundation.stages.stage2.diffutils = {
meta = {
description = lib.options.create {
@ -33,7 +32,7 @@ in {
platforms = lib.options.create {
type = lib.types.list.of lib.types.string;
description = "Platforms the package supports.";
default.value = ["i686-linux"];
default.value = [ "i686-linux" ];
};
};

View file

@ -1,14 +1,13 @@
{
lib,
config,
}: let
{ lib, config }:
let
cfg = config.aux.foundation.stages.stage2.findutils;
platform = config.aux.platform;
builders = config.aux.foundation.builders;
stage1 = config.aux.foundation.stages.stage1;
in {
in
{
options.aux.foundation.stages.stage2.findutils = {
meta = {
description = lib.options.create {
@ -33,7 +32,7 @@ in {
platforms = lib.options.create {
type = lib.types.list.of lib.types.string;
description = "Platforms the package supports.";
default.value = ["i686-linux"];
default.value = [ "i686-linux" ];
};
};

View file

@ -1,14 +1,13 @@
{
lib,
config,
}: let
{ lib, config }:
let
cfg = config.aux.foundation.stages.stage2.gawk;
platform = config.aux.platform;
builders = config.aux.foundation.builders;
stage1 = config.aux.foundation.stages.stage1;
in {
in
{
options.aux.foundation.stages.stage2.gawk = {
meta = {
description = lib.options.create {
@ -33,7 +32,7 @@ in {
platforms = lib.options.create {
type = lib.types.list.of lib.types.string;
description = "Platforms the package supports.";
default.value = ["i686-linux"];
default.value = [ "i686-linux" ];
};
mainProgram = lib.options.create {

View file

@ -1,14 +1,13 @@
{
lib,
config,
}: let
{ lib, config }:
let
cfg = config.aux.foundation.stages.stage2.gcc;
platform = config.aux.platform;
builders = config.aux.foundation.builders;
stage1 = config.aux.foundation.stages.stage1;
in {
in
{
options.aux.foundation.stages.stage2.gcc = {
meta = {
description = lib.options.create {
@ -33,7 +32,7 @@ in {
platforms = lib.options.create {
type = lib.types.list.of lib.types.string;
description = "Platforms the package supports.";
default.value = ["i686-linux"];
default.value = [ "i686-linux" ];
};
};

View file

@ -1,7 +1,5 @@
{
lib,
config,
}: let
{ lib, config }:
let
cfg = config.aux.foundation.stages.stage2.glibc;
platform = config.aux.platform;
@ -9,7 +7,8 @@
stage1 = config.aux.foundation.stages.stage1;
stage2 = config.aux.foundation.stages.stage2;
in {
in
{
options.aux.foundation.stages.stage2.glibc = {
meta = {
description = lib.options.create {
@ -34,7 +33,7 @@ in {
platforms = lib.options.create {
type = lib.types.list.of lib.types.string;
description = "Platforms the package supports.";
default.value = ["i686-linux"];
default.value = [ "i686-linux" ];
};
};

View file

@ -1,14 +1,13 @@
{
lib,
config,
}: let
{ lib, config }:
let
cfg = config.aux.foundation.stages.stage2.gnugrep;
platform = config.aux.platform;
builders = config.aux.foundation.builders;
stage1 = config.aux.foundation.stages.stage1;
in {
in
{
options.aux.foundation.stages.stage2.gnugrep = {
meta = {
description = lib.options.create {
@ -33,7 +32,7 @@ in {
platforms = lib.options.create {
type = lib.types.list.of lib.types.string;
description = "Platforms the package supports.";
default.value = ["i686-linux"];
default.value = [ "i686-linux" ];
};
mainProgram = lib.options.create {

View file

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

View file

@ -1,14 +1,13 @@
{
lib,
config,
}: let
{ lib, config }:
let
cfg = config.aux.foundation.stages.stage2.gnupatch;
platform = config.aux.platform;
builders = config.aux.foundation.builders;
stage1 = config.aux.foundation.stages.stage1;
in {
in
{
options.aux.foundation.stages.stage2.gnupatch = {
meta = {
description = lib.options.create {
@ -33,7 +32,7 @@ in {
platforms = lib.options.create {
type = lib.types.list.of lib.types.string;
description = "Platforms the package supports.";
default.value = ["i686-linux"];
default.value = [ "i686-linux" ];
};
};

View file

@ -1,14 +1,13 @@
{
lib,
config,
}: let
{ lib, config }:
let
cfg = config.aux.foundation.stages.stage2.gnused;
platform = config.aux.platform;
builders = config.aux.foundation.builders;
stage1 = config.aux.foundation.stages.stage1;
in {
in
{
options.aux.foundation.stages.stage2.gnused = {
meta = {
description = lib.options.create {
@ -33,7 +32,7 @@ in {
platforms = lib.options.create {
type = lib.types.list.of lib.types.string;
description = "Platforms the package supports.";
default.value = ["i686-linux"];
default.value = [ "i686-linux" ];
};
mainProgram = lib.options.create {

View file

@ -1,14 +1,13 @@
{
lib,
config,
}: let
{ lib, config }:
let
cfg = config.aux.foundation.stages.stage2.gnutar;
platform = config.aux.platform;
builders = config.aux.foundation.builders;
stage1 = config.aux.foundation.stages.stage1;
in {
in
{
options.aux.foundation.stages.stage2.gnutar = {
meta = {
description = lib.options.create {
@ -33,7 +32,7 @@ in {
platforms = lib.options.create {
type = lib.types.list.of lib.types.string;
description = "Platforms the package supports.";
default.value = ["i686-linux"];
default.value = [ "i686-linux" ];
};
mainProgram = lib.options.create {

View file

@ -1,14 +1,13 @@
{
lib,
config,
}: let
{ lib, config }:
let
cfg = config.aux.foundation.stages.stage2.gzip;
platform = config.aux.platform;
builders = config.aux.foundation.builders;
stage1 = config.aux.foundation.stages.stage1;
in {
in
{
options.aux.foundation.stages.stage2.gzip = {
meta = {
description = lib.options.create {
@ -33,7 +32,7 @@ in {
platforms = lib.options.create {
type = lib.types.list.of lib.types.string;
description = "Platforms the package supports.";
default.value = ["i686-linux"];
default.value = [ "i686-linux" ];
};
};

View file

@ -1,7 +1,5 @@
{
lib,
config,
}: let
{ lib, config }:
let
cfg = config.aux.foundation.stages.stage2.patchelf;
platform = config.aux.platform;
@ -9,7 +7,8 @@
stage1 = config.aux.foundation.stages.stage1;
stage2 = config.aux.foundation.stages.stage2;
in {
in
{
options.aux.foundation.stages.stage2.patchelf = {
meta = {
description = lib.options.create {
@ -34,7 +33,7 @@ in {
platforms = lib.options.create {
type = lib.types.list.of lib.types.string;
description = "Platforms the package supports.";
default.value = ["i686-linux"];
default.value = [ "i686-linux" ];
};
};

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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