Compare commits
2 commits
786738b368
...
7adf088998
Author | SHA1 | Date | |
---|---|---|---|
isabel roses | 7adf088998 | ||
isabel roses | 120d4b3257 |
|
@ -1,6 +0,0 @@
|
||||||
#!/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
|
|
||||||
|
|
||||||
files=$(find . -name "*.nix" -type f)
|
|
||||||
|
|
||||||
nixfmt ${1:-"--verify"} ${files}
|
|
|
@ -1,13 +1,10 @@
|
||||||
{
|
{system ? builtins.currentSystem}: let
|
||||||
system ? builtins.currentSystem,
|
|
||||||
}:
|
|
||||||
let
|
|
||||||
lib = import ./../lib;
|
lib = import ./../lib;
|
||||||
|
|
||||||
modules = import ./src;
|
modules = import ./src;
|
||||||
|
|
||||||
result = lib.modules.run {
|
result = lib.modules.run {
|
||||||
modules = (builtins.attrValues modules) ++ [ { config.aux.system = system; } ];
|
modules = (builtins.attrValues modules) ++ [{config.aux.system = system;}];
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
result.config.exports.resolved.packages
|
result.config.exports.resolved.packages
|
||||||
|
|
|
@ -7,30 +7,28 @@
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
outputs =
|
outputs = inputs: let
|
||||||
inputs:
|
inherit (inputs.lib) lib;
|
||||||
let
|
|
||||||
inherit (inputs.lib) lib;
|
|
||||||
|
|
||||||
modules = import ./src;
|
modules = import ./src;
|
||||||
|
|
||||||
forEachSystem = lib.attrs.generate [ "i686-linux" ];
|
forEachSystem = lib.attrs.generate [
|
||||||
|
"i686-linux"
|
||||||
|
"x86_64-linux"
|
||||||
|
];
|
||||||
|
in {
|
||||||
|
extras = let
|
||||||
|
result = lib.modules.run {modules = builtins.attrValues modules;};
|
||||||
in
|
in
|
||||||
{
|
result.config.exports.resolved.extras;
|
||||||
extras =
|
|
||||||
let
|
|
||||||
result = lib.modules.run { modules = builtins.attrValues modules; };
|
|
||||||
in
|
|
||||||
result.config.exports.resolved.extras;
|
|
||||||
|
|
||||||
packages = forEachSystem (
|
packages = forEachSystem (
|
||||||
system:
|
system: let
|
||||||
let
|
result = lib.modules.run {
|
||||||
result = lib.modules.run {
|
modules = (builtins.attrValues modules) ++ [{config.aux.system = system;}];
|
||||||
modules = (builtins.attrValues modules) ++ [ { config.aux.system = system; } ];
|
};
|
||||||
};
|
in
|
||||||
in
|
|
||||||
result.config.exports.resolved.packages
|
result.config.exports.resolved.packages
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
{ lib, config }:
|
{
|
||||||
let
|
lib,
|
||||||
|
config,
|
||||||
|
}: let
|
||||||
system = config.aux.system;
|
system = config.aux.system;
|
||||||
builders = config.aux.foundation.builders;
|
builders = config.aux.foundation.builders;
|
||||||
|
|
||||||
stage0 = config.aux.foundation.stages.stage0;
|
stage0 = config.aux.foundation.stages.stage0;
|
||||||
stage1 = config.aux.foundation.stages.stage1;
|
stage1 = config.aux.foundation.stages.stage1;
|
||||||
in
|
in {
|
||||||
{
|
|
||||||
options.aux.foundation.builders.bash.boot = {
|
options.aux.foundation.builders.bash.boot = {
|
||||||
build = lib.options.create {
|
build = lib.options.create {
|
||||||
type = lib.types.function lib.types.derivation;
|
type = lib.types.function lib.types.derivation;
|
||||||
|
@ -16,67 +17,61 @@ in
|
||||||
|
|
||||||
config = {
|
config = {
|
||||||
aux.foundation.builders.bash.boot = {
|
aux.foundation.builders.bash.boot = {
|
||||||
build =
|
build = settings @ {
|
||||||
settings@{
|
name,
|
||||||
name,
|
script,
|
||||||
script,
|
meta ? {},
|
||||||
meta ? { },
|
extras ? {},
|
||||||
extras ? { },
|
env ? {},
|
||||||
env ? { },
|
deps ? {},
|
||||||
deps ? { },
|
...
|
||||||
...
|
}: let
|
||||||
}:
|
package = builtins.derivation (
|
||||||
let
|
(builtins.removeAttrs settings ["meta" "extras" "executable" "env" "deps" "script"])
|
||||||
package = builtins.derivation (
|
// env
|
||||||
(builtins.removeAttrs settings [
|
// {
|
||||||
"meta"
|
inherit name system script;
|
||||||
"extras"
|
|
||||||
"executable"
|
|
||||||
"env"
|
|
||||||
"deps"
|
|
||||||
"script"
|
|
||||||
])
|
|
||||||
// env
|
|
||||||
// {
|
|
||||||
inherit name system script;
|
|
||||||
|
|
||||||
passAsFile = [ "script" ];
|
passAsFile = ["script"];
|
||||||
|
|
||||||
builder = "${stage1.bash.boot.package}/bin/bash";
|
builder = "${stage1.bash.boot.package}/bin/bash";
|
||||||
|
|
||||||
args = [
|
args = [
|
||||||
"-e"
|
"-e"
|
||||||
(builtins.toFile "bash-builder.sh" ''
|
(builtins.toFile "bash-builder.sh" ''
|
||||||
export CONFIG_SHELL=$SHELL
|
export CONFIG_SHELL=$SHELL
|
||||||
|
|
||||||
# Normalize the NIX_BUILD_CORES variable. The value might be 0, which
|
# Normalize the NIX_BUILD_CORES variable. The value might be 0, which
|
||||||
# means that we're supposed to try and auto-detect the number of
|
# means that we're supposed to try and auto-detect the number of
|
||||||
# available CPU cores at run-time. We don't have nproc to detect the
|
# available CPU cores at run-time. We don't have nproc to detect the
|
||||||
# number of available CPU cores so default to 1 if not set.
|
# number of available CPU cores so default to 1 if not set.
|
||||||
NIX_BUILD_CORES="''${NIX_BUILD_CORES:-1}"
|
NIX_BUILD_CORES="''${NIX_BUILD_CORES:-1}"
|
||||||
if [ $NIX_BUILD_CORES -le 0 ]; then
|
if [ $NIX_BUILD_CORES -le 0 ]; then
|
||||||
NIX_BUILD_CORES=1
|
NIX_BUILD_CORES=1
|
||||||
fi
|
fi
|
||||||
export NIX_BUILD_CORES
|
export NIX_BUILD_CORES
|
||||||
|
|
||||||
bash -eux $scriptPath
|
bash -eux $scriptPath
|
||||||
'')
|
'')
|
||||||
];
|
];
|
||||||
|
|
||||||
SHELL = "${stage1.bash.boot.package}/bin/bash";
|
SHELL = "${stage1.bash.boot.package}/bin/bash";
|
||||||
|
|
||||||
PATH = lib.paths.bin (
|
PATH = lib.paths.bin (
|
||||||
(deps.build.host or [ ])
|
(deps.build.host or [])
|
||||||
++ [
|
++ [
|
||||||
stage1.bash.boot.package
|
stage1.bash.boot.package
|
||||||
stage1.coreutils.boot.package
|
stage1.coreutils.boot.package
|
||||||
stage0.mescc-tools-extra.package
|
stage0.mescc-tools-extra.package
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
in
|
in
|
||||||
package // { inherit meta extras; };
|
package
|
||||||
|
// {
|
||||||
|
inherit meta extras;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,15 @@
|
||||||
{ lib, config }:
|
{
|
||||||
let
|
lib,
|
||||||
|
config,
|
||||||
|
}: let
|
||||||
system = config.aux.system;
|
system = config.aux.system;
|
||||||
builders = config.aux.foundation.builders;
|
builders = config.aux.foundation.builders;
|
||||||
|
|
||||||
stage1 = config.aux.foundation.stages.stage1;
|
stage1 = config.aux.foundation.stages.stage1;
|
||||||
in
|
in {
|
||||||
{
|
includes = [
|
||||||
includes = [ ./boot.nix ];
|
./boot.nix
|
||||||
|
];
|
||||||
|
|
||||||
options.aux.foundation.builders.bash = {
|
options.aux.foundation.builders.bash = {
|
||||||
build = lib.options.create {
|
build = lib.options.create {
|
||||||
|
@ -17,66 +20,60 @@ in
|
||||||
|
|
||||||
config = {
|
config = {
|
||||||
aux.foundation.builders.bash = {
|
aux.foundation.builders.bash = {
|
||||||
build =
|
build = settings @ {
|
||||||
settings@{
|
name,
|
||||||
name,
|
script,
|
||||||
script,
|
meta ? {},
|
||||||
meta ? { },
|
extras ? {},
|
||||||
extras ? { },
|
env ? {},
|
||||||
env ? { },
|
deps ? {},
|
||||||
deps ? { },
|
...
|
||||||
...
|
}: let
|
||||||
}:
|
package = builtins.derivation (
|
||||||
let
|
(builtins.removeAttrs settings ["meta" "extras" "executable" "env" "deps" "script"])
|
||||||
package = builtins.derivation (
|
// env
|
||||||
(builtins.removeAttrs settings [
|
// {
|
||||||
"meta"
|
inherit name system script;
|
||||||
"extras"
|
|
||||||
"executable"
|
|
||||||
"env"
|
|
||||||
"deps"
|
|
||||||
"script"
|
|
||||||
])
|
|
||||||
// env
|
|
||||||
// {
|
|
||||||
inherit name system script;
|
|
||||||
|
|
||||||
passAsFile = [ "script" ];
|
passAsFile = ["script"];
|
||||||
|
|
||||||
builder = "${stage1.bash.package}/bin/bash";
|
builder = "${stage1.bash.package}/bin/bash";
|
||||||
|
|
||||||
args = [
|
args = [
|
||||||
"-e"
|
"-e"
|
||||||
(builtins.toFile "bash-builder.sh" ''
|
(builtins.toFile "bash-builder.sh" ''
|
||||||
export CONFIG_SHELL=$SHELL
|
export CONFIG_SHELL=$SHELL
|
||||||
|
|
||||||
# Normalize the NIX_BUILD_CORES variable. The value might be 0, which
|
# Normalize the NIX_BUILD_CORES variable. The value might be 0, which
|
||||||
# means that we're supposed to try and auto-detect the number of
|
# means that we're supposed to try and auto-detect the number of
|
||||||
# available CPU cores at run-time.
|
# available CPU cores at run-time.
|
||||||
NIX_BUILD_CORES="''${NIX_BUILD_CORES:-1}"
|
NIX_BUILD_CORES="''${NIX_BUILD_CORES:-1}"
|
||||||
if ((NIX_BUILD_CORES <= 0)); then
|
if ((NIX_BUILD_CORES <= 0)); then
|
||||||
guess=$(nproc 2>/dev/null || true)
|
guess=$(nproc 2>/dev/null || true)
|
||||||
((NIX_BUILD_CORES = guess <= 0 ? 1 : guess))
|
((NIX_BUILD_CORES = guess <= 0 ? 1 : guess))
|
||||||
fi
|
fi
|
||||||
export NIX_BUILD_CORES
|
export NIX_BUILD_CORES
|
||||||
|
|
||||||
bash -eux $scriptPath
|
bash -eux $scriptPath
|
||||||
'')
|
'')
|
||||||
];
|
];
|
||||||
|
|
||||||
SHELL = "${stage1.bash.package}/bin/bash";
|
SHELL = "${stage1.bash.package}/bin/bash";
|
||||||
|
|
||||||
PATH = lib.paths.bin (
|
PATH = lib.paths.bin (
|
||||||
(deps.build.host or [ ])
|
(deps.build.host or [])
|
||||||
++ [
|
++ [
|
||||||
stage1.bash.package
|
stage1.bash.package
|
||||||
stage1.coreutils.package
|
stage1.coreutils.package
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
in
|
in
|
||||||
package // { inherit meta extras; };
|
package
|
||||||
|
// {
|
||||||
|
inherit meta extras;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
{ lib, config }:
|
{
|
||||||
let
|
lib,
|
||||||
|
config,
|
||||||
|
}: let
|
||||||
system = config.aux.system;
|
system = config.aux.system;
|
||||||
|
|
||||||
stage0 = config.aux.foundation.stages.stage0;
|
stage0 = config.aux.foundation.stages.stage0;
|
||||||
in
|
in {
|
||||||
{
|
|
||||||
options.aux.foundation.builders.file.text = {
|
options.aux.foundation.builders.file.text = {
|
||||||
build = lib.options.create {
|
build = lib.options.create {
|
||||||
type = lib.types.function lib.types.derivation;
|
type = lib.types.function lib.types.derivation;
|
||||||
|
@ -14,62 +15,55 @@ in
|
||||||
|
|
||||||
config = {
|
config = {
|
||||||
aux.foundation.builders.file.text = {
|
aux.foundation.builders.file.text = {
|
||||||
build =
|
build = settings @ {
|
||||||
settings@{
|
name,
|
||||||
name,
|
contents,
|
||||||
contents,
|
isExecutable ? false,
|
||||||
isExecutable ? false,
|
destination ? "",
|
||||||
destination ? "",
|
meta ? {},
|
||||||
meta ? { },
|
extras ? {},
|
||||||
extras ? { },
|
...
|
||||||
...
|
}: let
|
||||||
}:
|
script =
|
||||||
let
|
''
|
||||||
script =
|
target=''${out}''${destination}
|
||||||
''
|
''
|
||||||
target=''${out}''${destination}
|
+ lib.strings.when (builtins.dirOf destination == ".") ''
|
||||||
''
|
mkdir -p ''${out}''${destinationDir}
|
||||||
+ lib.strings.when (builtins.dirOf destination == ".") ''
|
''
|
||||||
mkdir -p ''${out}''${destinationDir}
|
+ ''
|
||||||
''
|
cp ''${contentsPath} ''${target}
|
||||||
+ ''
|
''
|
||||||
cp ''${contentsPath} ''${target}
|
+ lib.strings.when isExecutable ''
|
||||||
''
|
chmod 555 ''${target}
|
||||||
+ lib.strings.when isExecutable ''
|
'';
|
||||||
chmod 555 ''${target}
|
package = builtins.derivation (
|
||||||
'';
|
(builtins.removeAttrs settings ["meta" "extras" "executable" "isExecutable"])
|
||||||
package = builtins.derivation (
|
// {
|
||||||
(builtins.removeAttrs settings [
|
inherit name system destination contents;
|
||||||
"meta"
|
destinationDir = builtins.dirOf destination;
|
||||||
"extras"
|
|
||||||
"executable"
|
|
||||||
"isExecutable"
|
|
||||||
])
|
|
||||||
// {
|
|
||||||
inherit
|
|
||||||
name
|
|
||||||
system
|
|
||||||
destination
|
|
||||||
contents
|
|
||||||
;
|
|
||||||
destinationDir = builtins.dirOf destination;
|
|
||||||
|
|
||||||
passAsFile = [ "contents" ];
|
passAsFile = ["contents"];
|
||||||
|
|
||||||
builder = "${stage0.kaem.package}/bin/kaem";
|
builder = "${stage0.kaem.package}/bin/kaem";
|
||||||
|
|
||||||
args = [
|
args = [
|
||||||
"--verbose"
|
"--verbose"
|
||||||
"--strict"
|
"--strict"
|
||||||
"--file"
|
"--file"
|
||||||
(builtins.toFile "write-text-to-file.kaem" script)
|
(builtins.toFile "write-text-to-file.kaem" script)
|
||||||
];
|
];
|
||||||
|
|
||||||
PATH = lib.paths.bin [ stage0.mescc-tools-extra.package ];
|
PATH = lib.paths.bin [
|
||||||
}
|
stage0.mescc-tools-extra.package
|
||||||
);
|
];
|
||||||
in
|
}
|
||||||
package // { inherit meta extras; };
|
);
|
||||||
|
in
|
||||||
|
package
|
||||||
|
// {
|
||||||
|
inherit meta extras;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
{ lib, config }:
|
{
|
||||||
let
|
lib,
|
||||||
|
config,
|
||||||
|
}: let
|
||||||
system = config.aux.system;
|
system = config.aux.system;
|
||||||
builders = config.aux.foundation.builders;
|
builders = config.aux.foundation.builders;
|
||||||
|
|
||||||
stage0 = config.aux.foundation.stages.stage0;
|
stage0 = config.aux.foundation.stages.stage0;
|
||||||
in
|
in {
|
||||||
{
|
|
||||||
options.aux.foundation.builders.kaem = {
|
options.aux.foundation.builders.kaem = {
|
||||||
build = lib.options.create {
|
build = lib.options.create {
|
||||||
type = lib.types.function lib.types.derivation;
|
type = lib.types.function lib.types.derivation;
|
||||||
|
@ -15,54 +16,50 @@ in
|
||||||
|
|
||||||
config = {
|
config = {
|
||||||
aux.foundation.builders.kaem = {
|
aux.foundation.builders.kaem = {
|
||||||
build =
|
build = settings @ {
|
||||||
settings@{
|
name,
|
||||||
name,
|
script,
|
||||||
script,
|
meta ? {},
|
||||||
meta ? { },
|
extras ? {},
|
||||||
extras ? { },
|
env ? {},
|
||||||
env ? { },
|
deps ? {},
|
||||||
deps ? { },
|
...
|
||||||
...
|
}: let
|
||||||
}:
|
package = builtins.derivation (
|
||||||
let
|
(builtins.removeAttrs settings ["meta" "extras" "executable" "env" "deps" "script"])
|
||||||
package = builtins.derivation (
|
// env
|
||||||
(builtins.removeAttrs settings [
|
// {
|
||||||
"meta"
|
inherit name system;
|
||||||
"extras"
|
|
||||||
"executable"
|
|
||||||
"env"
|
|
||||||
"deps"
|
|
||||||
"script"
|
|
||||||
])
|
|
||||||
// env
|
|
||||||
// {
|
|
||||||
inherit name system;
|
|
||||||
|
|
||||||
builder = "${stage0.kaem.package}/bin/kaem";
|
builder = "${stage0.kaem.package}/bin/kaem";
|
||||||
|
|
||||||
args = [
|
args = [
|
||||||
"--verbose"
|
"--verbose"
|
||||||
"--strict"
|
"--strict"
|
||||||
"--file"
|
"--file"
|
||||||
(builders.file.text.build {
|
(
|
||||||
|
builders.file.text.build {
|
||||||
name = "${name}-builder";
|
name = "${name}-builder";
|
||||||
contents = script;
|
contents = script;
|
||||||
})
|
}
|
||||||
];
|
)
|
||||||
|
];
|
||||||
|
|
||||||
PATH = lib.paths.bin (
|
PATH = lib.paths.bin (
|
||||||
(deps.build.host or [ ])
|
(deps.build.host or [])
|
||||||
++ [
|
++ [
|
||||||
stage0.kaem.package
|
stage0.kaem.package
|
||||||
stage0.mescc-tools.package
|
stage0.mescc-tools.package
|
||||||
stage0.mescc-tools-extra.package
|
stage0.mescc-tools-extra.package
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
in
|
in
|
||||||
package // { inherit meta extras; };
|
package
|
||||||
|
// {
|
||||||
|
inherit meta extras;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
{ lib, config }:
|
|
||||||
let
|
|
||||||
system = config.aux.system;
|
|
||||||
in
|
|
||||||
{
|
{
|
||||||
|
lib,
|
||||||
|
config,
|
||||||
|
}: let
|
||||||
|
system = config.aux.system;
|
||||||
|
in {
|
||||||
options.aux.foundation.builders.raw = {
|
options.aux.foundation.builders.raw = {
|
||||||
build = lib.options.create {
|
build = lib.options.create {
|
||||||
type = lib.types.function lib.types.derivation;
|
type = lib.types.function lib.types.derivation;
|
||||||
|
@ -12,38 +13,30 @@ in
|
||||||
|
|
||||||
config = {
|
config = {
|
||||||
aux.foundation.builders.raw = {
|
aux.foundation.builders.raw = {
|
||||||
build =
|
build = settings @ {
|
||||||
settings@{
|
pname,
|
||||||
pname,
|
version,
|
||||||
version,
|
executable,
|
||||||
executable,
|
args ? [],
|
||||||
args ? [ ],
|
meta ? {},
|
||||||
meta ? { },
|
extras ? {},
|
||||||
extras ? { },
|
...
|
||||||
...
|
}: let
|
||||||
}:
|
package = builtins.derivation (
|
||||||
let
|
(builtins.removeAttrs settings ["meta" "extras" "executable"])
|
||||||
package = builtins.derivation (
|
// {
|
||||||
(builtins.removeAttrs settings [
|
inherit version pname system args;
|
||||||
"meta"
|
|
||||||
"extras"
|
|
||||||
"executable"
|
|
||||||
])
|
|
||||||
// {
|
|
||||||
inherit
|
|
||||||
version
|
|
||||||
pname
|
|
||||||
system
|
|
||||||
args
|
|
||||||
;
|
|
||||||
|
|
||||||
name = "${pname}-${version}";
|
name = "${pname}-${version}";
|
||||||
|
|
||||||
builder = executable;
|
builder = executable;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
in
|
in
|
||||||
package // { inherit meta extras; };
|
package
|
||||||
|
// {
|
||||||
|
inherit meta extras;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,4 +13,4 @@ let
|
||||||
system = ./system;
|
system = ./system;
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
modules
|
modules
|
||||||
|
|
|
@ -1,19 +1,20 @@
|
||||||
{ lib, config }:
|
{
|
||||||
let
|
lib,
|
||||||
|
config,
|
||||||
|
}: let
|
||||||
options = {
|
options = {
|
||||||
packages = lib.options.create {
|
packages = lib.options.create {
|
||||||
default.value = { };
|
default.value = {};
|
||||||
|
|
||||||
type = lib.types.attrs.of lib.types.derivation;
|
type = lib.types.attrs.of lib.types.derivation;
|
||||||
};
|
};
|
||||||
|
|
||||||
extras = lib.options.create {
|
extras = lib.options.create {
|
||||||
default.value = { };
|
default.value = {};
|
||||||
type = lib.types.attrs.any;
|
type = lib.types.attrs.any;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
in
|
in {
|
||||||
{
|
|
||||||
options = {
|
options = {
|
||||||
exports = {
|
exports = {
|
||||||
inherit (options) packages extras;
|
inherit (options) packages extras;
|
||||||
|
@ -26,16 +27,19 @@ in
|
||||||
|
|
||||||
config = {
|
config = {
|
||||||
exports.resolved = {
|
exports.resolved = {
|
||||||
packages = builtins.mapAttrs (
|
packages =
|
||||||
name: value:
|
builtins.mapAttrs (
|
||||||
lib.attrs.filter (
|
|
||||||
name: value:
|
name: value:
|
||||||
if value ? meta && value.meta ? platforms then
|
lib.attrs.filter
|
||||||
builtins.elem config.aux.system value.meta.platforms
|
(
|
||||||
else
|
name: value:
|
||||||
true
|
if value ? meta && value.meta ? platforms
|
||||||
) value
|
then builtins.elem config.aux.system value.meta.platforms
|
||||||
) config.exports.packages;
|
else true
|
||||||
|
)
|
||||||
|
value
|
||||||
|
)
|
||||||
|
config.exports.packages;
|
||||||
|
|
||||||
extras = config.exports.extras;
|
extras = config.exports.extras;
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
{ lib }:
|
{lib}: {
|
||||||
{
|
|
||||||
options.aux.mirrors = {
|
options.aux.mirrors = {
|
||||||
gnu = lib.options.create {
|
gnu = lib.options.create {
|
||||||
type = lib.types.string;
|
type = lib.types.string;
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
{ lib, config }:
|
{
|
||||||
let
|
lib,
|
||||||
|
config,
|
||||||
|
}: let
|
||||||
system = config.aux.system;
|
system = config.aux.system;
|
||||||
|
|
||||||
parts = lib.strings.split "-" system;
|
parts = lib.strings.split "-" system;
|
||||||
|
@ -283,8 +285,7 @@ let
|
||||||
family = "javascript";
|
family = "javascript";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
in
|
in {
|
||||||
{
|
|
||||||
options.aux.platform = {
|
options.aux.platform = {
|
||||||
name = lib.options.create {
|
name = lib.options.create {
|
||||||
type = lib.types.string;
|
type = lib.types.string;
|
||||||
|
@ -302,10 +303,7 @@ in
|
||||||
};
|
};
|
||||||
|
|
||||||
endian = lib.options.create {
|
endian = lib.options.create {
|
||||||
type = lib.types.enum [
|
type = lib.types.enum ["little" "big"];
|
||||||
"little"
|
|
||||||
"big"
|
|
||||||
];
|
|
||||||
default.value = "big";
|
default.value = "big";
|
||||||
description = "Endianess of the platform";
|
description = "Endianess of the platform";
|
||||||
};
|
};
|
||||||
|
@ -334,13 +332,18 @@ in
|
||||||
};
|
};
|
||||||
|
|
||||||
config = {
|
config = {
|
||||||
aux.platform = (platforms.${platform} or (builtins.throw "Unsupported platform: ${system}")) // {
|
aux.platform =
|
||||||
name = platform;
|
(
|
||||||
|
platforms.${platform}
|
||||||
|
or (builtins.throw "Unsupported platform: ${system}")
|
||||||
|
)
|
||||||
|
// {
|
||||||
|
name = platform;
|
||||||
|
|
||||||
# These will only ever have `linux` as the target since we
|
# These will only ever have `linux` as the target since we
|
||||||
# do not support darwin bootstrapping.
|
# do not support darwin bootstrapping.
|
||||||
build = "${platform}-unknown-${target}-gnu";
|
build = "${platform}-unknown-${target}-gnu";
|
||||||
host = "${platform}-unknown-${target}-gnu";
|
host = "${platform}-unknown-${target}-gnu";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,18 +1,18 @@
|
||||||
{ lib, config }:
|
{
|
||||||
let
|
lib,
|
||||||
system = config.aux.system;
|
config,
|
||||||
|
}: let
|
||||||
|
inherit (config.aux) system;
|
||||||
|
|
||||||
architecture =
|
architecture =
|
||||||
if system == "x86_64-linux" then
|
if system == "x86_64-linux"
|
||||||
"AMD64"
|
then "AMD64"
|
||||||
else if system == "aarch64-linux" then
|
else if system == "aarch64-linux"
|
||||||
"AArch64"
|
then "AArch64"
|
||||||
else if system == "i686-linux" then
|
else if system == "i686-linux"
|
||||||
"x86"
|
then "x86"
|
||||||
else
|
else builtins.throw "Unsupported system for stage0: ${system}";
|
||||||
builtins.throw "Unsupported system for stage0: ${system}";
|
in {
|
||||||
in
|
|
||||||
{
|
|
||||||
options.aux.foundation.stages.stage0.architecture = {
|
options.aux.foundation.stages.stage0.architecture = {
|
||||||
base = lib.options.create {
|
base = lib.options.create {
|
||||||
type = lib.types.string;
|
type = lib.types.string;
|
||||||
|
|
|
@ -1,21 +1,21 @@
|
||||||
{ lib, config }:
|
{
|
||||||
let
|
lib,
|
||||||
|
config,
|
||||||
|
}: let
|
||||||
cfg = config.aux.foundation.stages.stage0;
|
cfg = config.aux.foundation.stages.stage0;
|
||||||
|
|
||||||
system = config.aux.system;
|
system = config.aux.system;
|
||||||
builders = config.aux.foundation.builders;
|
builders = config.aux.foundation.builders;
|
||||||
|
|
||||||
architecture =
|
architecture =
|
||||||
if system == "x86_64-linux" then
|
if system == "x86_64-linux"
|
||||||
"AMD64"
|
then "AMD64"
|
||||||
else if system == "aarch64-linux" then
|
else if system == "aarch64-linux"
|
||||||
"AArch64"
|
then "AArch64"
|
||||||
else if system == "i686-linux" then
|
else if system == "i686-linux"
|
||||||
"x86"
|
then "x86"
|
||||||
else
|
else builtins.throw "Unsupported system for stage0: ${system}";
|
||||||
builtins.throw "Unsupported system for stage0: ${system}";
|
in {
|
||||||
in
|
|
||||||
{
|
|
||||||
includes = [
|
includes = [
|
||||||
./sources
|
./sources
|
||||||
./architecture
|
./architecture
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
{ lib, config }:
|
{
|
||||||
let
|
lib,
|
||||||
|
config,
|
||||||
|
}: let
|
||||||
cfg = config.aux.foundation.stages.stage0.kaem;
|
cfg = config.aux.foundation.stages.stage0.kaem;
|
||||||
|
|
||||||
system = config.aux.system;
|
system = config.aux.system;
|
||||||
|
@ -8,8 +10,7 @@ let
|
||||||
kaem-unwrapped = config.aux.foundation.stages.stage0.kaem-unwrapped;
|
kaem-unwrapped = config.aux.foundation.stages.stage0.kaem-unwrapped;
|
||||||
mescc-tools = config.aux.foundation.stages.stage0.mescc-tools;
|
mescc-tools = config.aux.foundation.stages.stage0.mescc-tools;
|
||||||
mescc-tools-extra = config.aux.foundation.stages.stage0.mescc-tools-extra;
|
mescc-tools-extra = config.aux.foundation.stages.stage0.mescc-tools-extra;
|
||||||
in
|
in {
|
||||||
{
|
|
||||||
options.aux.foundation.stages.stage0.kaem = {
|
options.aux.foundation.stages.stage0.kaem = {
|
||||||
meta = {
|
meta = {
|
||||||
description = lib.options.create {
|
description = lib.options.create {
|
||||||
|
@ -34,7 +35,10 @@ in
|
||||||
platforms = lib.options.create {
|
platforms = lib.options.create {
|
||||||
type = lib.types.list.of lib.types.string;
|
type = lib.types.list.of lib.types.string;
|
||||||
description = "Platforms the package supports.";
|
description = "Platforms the package supports.";
|
||||||
default.value = [ "i686-linux" ];
|
default.value = [
|
||||||
|
"x86_64-linux"
|
||||||
|
"i686-linux"
|
||||||
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -63,7 +67,7 @@ in
|
||||||
];
|
];
|
||||||
|
|
||||||
kaemUnwrapped = kaem-unwrapped.package;
|
kaemUnwrapped = kaem-unwrapped.package;
|
||||||
PATH = lib.paths.bin [ mescc-tools-extra.package ];
|
PATH = lib.paths.bin [mescc-tools-extra.package];
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
{ lib, config }:
|
{
|
||||||
let
|
lib,
|
||||||
|
config,
|
||||||
|
}: let
|
||||||
cfg = config.aux.foundation.stages.stage0.mescc-tools-extra;
|
cfg = config.aux.foundation.stages.stage0.mescc-tools-extra;
|
||||||
hex0 = config.aux.foundation.stages.stage0.hex0;
|
hex0 = config.aux.foundation.stages.stage0.hex0;
|
||||||
catm = config.aux.foundation.stages.stage0.catm;
|
catm = config.aux.foundation.stages.stage0.catm;
|
||||||
|
@ -16,8 +18,7 @@ let
|
||||||
builders = config.aux.foundation.builders;
|
builders = config.aux.foundation.builders;
|
||||||
sources = config.aux.foundation.stages.stage0.sources;
|
sources = config.aux.foundation.stages.stage0.sources;
|
||||||
architecture = config.aux.foundation.stages.stage0.architecture;
|
architecture = config.aux.foundation.stages.stage0.architecture;
|
||||||
in
|
in {
|
||||||
{
|
|
||||||
options.aux.foundation.stages.stage0.mescc-tools-extra = {
|
options.aux.foundation.stages.stage0.mescc-tools-extra = {
|
||||||
meta = {
|
meta = {
|
||||||
description = lib.options.create {
|
description = lib.options.create {
|
||||||
|
@ -42,7 +43,10 @@ in
|
||||||
platforms = lib.options.create {
|
platforms = lib.options.create {
|
||||||
type = lib.types.list.of lib.types.string;
|
type = lib.types.list.of lib.types.string;
|
||||||
description = "Platforms the package supports.";
|
description = "Platforms the package supports.";
|
||||||
default.value = [ "i686-linux" ];
|
default.value = [
|
||||||
|
"x86_64-linux"
|
||||||
|
"i686-linux"
|
||||||
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
{ lib, config }:
|
{
|
||||||
let
|
lib,
|
||||||
|
config,
|
||||||
|
}: let
|
||||||
cfg = config.aux.foundation.stages.stage0.mescc-tools;
|
cfg = config.aux.foundation.stages.stage0.mescc-tools;
|
||||||
hex0 = config.aux.foundation.stages.stage0.hex0;
|
hex0 = config.aux.foundation.stages.stage0.hex0;
|
||||||
catm = config.aux.foundation.stages.stage0.catm;
|
catm = config.aux.foundation.stages.stage0.catm;
|
||||||
|
@ -16,57 +18,60 @@ let
|
||||||
sources = config.aux.foundation.stages.stage0.sources;
|
sources = config.aux.foundation.stages.stage0.sources;
|
||||||
architecture = config.aux.foundation.stages.stage0.architecture;
|
architecture = config.aux.foundation.stages.stage0.architecture;
|
||||||
|
|
||||||
bloodFlag = if config.aux.platform.bits == 64 then "--64" else " ";
|
bloodFlag =
|
||||||
endianFlag = if config.aux.platform.endian == "little" then "--little-endian" else "--big-endian";
|
if config.aux.platform.bits == 64
|
||||||
|
then "--64"
|
||||||
|
else " ";
|
||||||
|
endianFlag =
|
||||||
|
if config.aux.platform.endian == "little"
|
||||||
|
then "--little-endian"
|
||||||
|
else "--big-endian";
|
||||||
baseAddress =
|
baseAddress =
|
||||||
if config.aux.system == "x86_64-linux" then
|
if config.aux.system == "x86_64-linux"
|
||||||
"0x00600000"
|
then "0x00600000"
|
||||||
else if config.aux.system == "aarch64-linux" then
|
else if config.aux.system == "aarch64-linux"
|
||||||
"0x00600000"
|
then "0x00600000"
|
||||||
else if config.aux.system == "i686-linux" then
|
else if config.aux.system == "i686-linux"
|
||||||
"0x08048000"
|
then "0x08048000"
|
||||||
else
|
else builtins.throw "Unsupported system: ${config.aux.system}";
|
||||||
builtins.throw "Unsupported system: ${config.aux.system}";
|
|
||||||
|
|
||||||
getExtraUtil =
|
getExtraUtil = name: let
|
||||||
name:
|
script = builtins.toFile "build-${name}.kaem" ''
|
||||||
let
|
''${M2} --architecture ${architecture.m2libc} \
|
||||||
script = builtins.toFile "build-${name}.kaem" ''
|
-f ''${m2libc}/sys/types.h \
|
||||||
''${M2} --architecture ${architecture.m2libc} \
|
-f ''${m2libc}/stddef.h \
|
||||||
-f ''${m2libc}/sys/types.h \
|
-f ''${m2libc}/${architecture.m2libc}/linux/fcntl.c \
|
||||||
-f ''${m2libc}/stddef.h \
|
-f ''${m2libc}/fcntl.c \
|
||||||
-f ''${m2libc}/${architecture.m2libc}/linux/fcntl.c \
|
-f ''${m2libc}/${architecture.m2libc}/linux/unistd.c \
|
||||||
-f ''${m2libc}/fcntl.c \
|
-f ''${m2libc}/${architecture.m2libc}/linux/sys/stat.c \
|
||||||
-f ''${m2libc}/${architecture.m2libc}/linux/unistd.c \
|
-f ''${m2libc}/stdlib.c \
|
||||||
-f ''${m2libc}/${architecture.m2libc}/linux/sys/stat.c \
|
-f ''${m2libc}/stdio.h \
|
||||||
-f ''${m2libc}/stdlib.c \
|
-f ''${m2libc}/stdio.c \
|
||||||
-f ''${m2libc}/stdio.h \
|
-f ''${m2libc}/string.c \
|
||||||
-f ''${m2libc}/stdio.c \
|
-f ''${m2libc}/bootstrappable.c \
|
||||||
-f ''${m2libc}/string.c \
|
-f ''${mesccToolsExtra}/${name}.c \
|
||||||
-f ''${m2libc}/bootstrappable.c \
|
--debug \
|
||||||
-f ''${mesccToolsExtra}/${name}.c \
|
-o ${name}.M1
|
||||||
--debug \
|
|
||||||
-o ${name}.M1
|
|
||||||
|
|
||||||
''${blood-elf-0} ${endianFlag} ${bloodFlag} -f ${name}.M1 -o ${name}-footer.M1
|
''${blood-elf-0} ${endianFlag} ${bloodFlag} -f ${name}.M1 -o ${name}-footer.M1
|
||||||
|
|
||||||
''${M1} --architecture ${architecture.m2libc} \
|
''${M1} --architecture ${architecture.m2libc} \
|
||||||
${endianFlag} \
|
${endianFlag} \
|
||||||
-f ''${m2libc}/${architecture.m2libc}/${architecture.m2libc}_defs.M1 \
|
-f ''${m2libc}/${architecture.m2libc}/${architecture.m2libc}_defs.M1 \
|
||||||
-f ''${m2libc}/${architecture.m2libc}/libc-full.M1 \
|
-f ''${m2libc}/${architecture.m2libc}/libc-full.M1 \
|
||||||
-f ${name}.M1 \
|
-f ${name}.M1 \
|
||||||
-f ${name}-footer.M1 \
|
-f ${name}-footer.M1 \
|
||||||
-o ${name}.hex2
|
-o ${name}.hex2
|
||||||
|
|
||||||
''${hex2} --architecture ${architecture.m2libc} \
|
''${hex2} --architecture ${architecture.m2libc} \
|
||||||
${endianFlag} \
|
${endianFlag} \
|
||||||
-f ''${m2libc}/${architecture.m2libc}/ELF-${architecture.m2libc}-debug.hex2 \
|
-f ''${m2libc}/${architecture.m2libc}/ELF-${architecture.m2libc}-debug.hex2 \
|
||||||
-f ${name}.hex2 \
|
-f ${name}.hex2 \
|
||||||
--base-address ${baseAddress} \
|
--base-address ${baseAddress} \
|
||||||
-o ''${out}
|
-o ''${out}
|
||||||
|
|
||||||
'';
|
'';
|
||||||
in
|
in
|
||||||
builders.raw.build {
|
builders.raw.build {
|
||||||
pname = "mescc-tools-extra-${name}";
|
pname = "mescc-tools-extra-${name}";
|
||||||
version = "1.6.0";
|
version = "1.6.0";
|
||||||
|
@ -99,8 +104,7 @@ let
|
||||||
endianFlag = endianFlag;
|
endianFlag = endianFlag;
|
||||||
baseAddress = baseAddress;
|
baseAddress = baseAddress;
|
||||||
};
|
};
|
||||||
in
|
in {
|
||||||
{
|
|
||||||
options.aux.foundation.stages.stage0.mescc-tools = {
|
options.aux.foundation.stages.stage0.mescc-tools = {
|
||||||
meta = {
|
meta = {
|
||||||
description = lib.options.create {
|
description = lib.options.create {
|
||||||
|
@ -125,7 +129,10 @@ in
|
||||||
platforms = lib.options.create {
|
platforms = lib.options.create {
|
||||||
type = lib.types.list.of lib.types.string;
|
type = lib.types.list.of lib.types.string;
|
||||||
description = "Platforms the package supports.";
|
description = "Platforms the package supports.";
|
||||||
default.value = [ "i686-linux" ];
|
default.value = [
|
||||||
|
"x86_64-linux"
|
||||||
|
"i686-linux"
|
||||||
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
{ lib, config }:
|
{
|
||||||
let
|
lib,
|
||||||
|
config,
|
||||||
|
}: let
|
||||||
cfg = config.aux.foundation.stages.stage0.hex0;
|
cfg = config.aux.foundation.stages.stage0.hex0;
|
||||||
|
|
||||||
system = config.aux.system;
|
system = config.aux.system;
|
||||||
|
@ -7,16 +9,14 @@ let
|
||||||
sources = config.aux.foundation.stages.stage0.sources;
|
sources = config.aux.foundation.stages.stage0.sources;
|
||||||
|
|
||||||
architecture =
|
architecture =
|
||||||
if system == "x86_64-linux" then
|
if system == "x86_64-linux"
|
||||||
"AMD64"
|
then "AMD64"
|
||||||
else if system == "aarch64-linux" then
|
else if system == "aarch64-linux"
|
||||||
"AArch64"
|
then "AArch64"
|
||||||
else if system == "i686-linux" then
|
else if system == "i686-linux"
|
||||||
"x86"
|
then "x86"
|
||||||
else
|
else builtins.throw "Unsupported system for stage0: ${system}";
|
||||||
builtins.throw "Unsupported system for stage0: ${system}";
|
in {
|
||||||
in
|
|
||||||
{
|
|
||||||
options.aux.foundation.stages.stage0.hex0 = {
|
options.aux.foundation.stages.stage0.hex0 = {
|
||||||
meta = {
|
meta = {
|
||||||
description = lib.options.create {
|
description = lib.options.create {
|
||||||
|
@ -41,7 +41,10 @@ in
|
||||||
platforms = lib.options.create {
|
platforms = lib.options.create {
|
||||||
type = lib.types.list.of lib.types.string;
|
type = lib.types.list.of lib.types.string;
|
||||||
description = "Platforms the package supports.";
|
description = "Platforms the package supports.";
|
||||||
default.value = [ "i686-linux" ];
|
default.value = [
|
||||||
|
"x86_64-linux"
|
||||||
|
"i686-linux"
|
||||||
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -87,14 +90,13 @@ in
|
||||||
);
|
);
|
||||||
|
|
||||||
hash = lib.modules.overrides.default (
|
hash = lib.modules.overrides.default (
|
||||||
if system == "x86_64-linux" then
|
if system == "x86_64-linux"
|
||||||
"sha256-RCgK9oZRDQUiWLVkcIBSR2HeoB+Bh0czthrpjFEkCaY="
|
then "sha256-RCgK9oZRDQUiWLVkcIBSR2HeoB+Bh0czthrpjFEkCaY="
|
||||||
else if system == "aarch64-linux" then
|
else if system == "aarch64-linux"
|
||||||
"sha256-XTPsoKeI6wTZAF0UwEJPzuHelWOJe//wXg4HYO0dEJo="
|
then "sha256-XTPsoKeI6wTZAF0UwEJPzuHelWOJe//wXg4HYO0dEJo="
|
||||||
else if system == "i686-linux" then
|
else if system == "i686-linux"
|
||||||
"sha256-QU3RPGy51W7M2xnfFY1IqruKzusrSLU+L190ztN6JW8="
|
then "sha256-QU3RPGy51W7M2xnfFY1IqruKzusrSLU+L190ztN6JW8="
|
||||||
else
|
else null
|
||||||
null
|
|
||||||
);
|
);
|
||||||
|
|
||||||
executable = lib.modules.overrides.default (
|
executable = lib.modules.overrides.default (
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
{ lib, config }:
|
{
|
||||||
let
|
lib,
|
||||||
|
config,
|
||||||
|
}: let
|
||||||
cfg = config.aux.foundation.stages.stage0.hex1;
|
cfg = config.aux.foundation.stages.stage0.hex1;
|
||||||
hex0 = config.aux.foundation.stages.stage0.hex0;
|
hex0 = config.aux.foundation.stages.stage0.hex0;
|
||||||
|
|
||||||
|
@ -7,8 +9,7 @@ let
|
||||||
builders = config.aux.foundation.builders;
|
builders = config.aux.foundation.builders;
|
||||||
sources = config.aux.foundation.stages.stage0.sources;
|
sources = config.aux.foundation.stages.stage0.sources;
|
||||||
architecture = config.aux.foundation.stages.stage0.architecture;
|
architecture = config.aux.foundation.stages.stage0.architecture;
|
||||||
in
|
in {
|
||||||
{
|
|
||||||
options.aux.foundation.stages.stage0.hex1 = {
|
options.aux.foundation.stages.stage0.hex1 = {
|
||||||
meta = {
|
meta = {
|
||||||
description = lib.options.create {
|
description = lib.options.create {
|
||||||
|
@ -33,7 +34,10 @@ in
|
||||||
platforms = lib.options.create {
|
platforms = lib.options.create {
|
||||||
type = lib.types.list.of lib.types.string;
|
type = lib.types.list.of lib.types.string;
|
||||||
description = "Platforms the package supports.";
|
description = "Platforms the package supports.";
|
||||||
default.value = [ "i686-linux" ];
|
default.value = [
|
||||||
|
"x86_64-linux"
|
||||||
|
"i686-linux"
|
||||||
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
{ lib, config }:
|
{
|
||||||
let
|
lib,
|
||||||
|
config,
|
||||||
|
}: let
|
||||||
cfg = config.aux.foundation.stages.stage0.hex2-0;
|
cfg = config.aux.foundation.stages.stage0.hex2-0;
|
||||||
hex0 = config.aux.foundation.stages.stage0.hex0;
|
hex0 = config.aux.foundation.stages.stage0.hex0;
|
||||||
hex1 = config.aux.foundation.stages.stage0.hex1;
|
hex1 = config.aux.foundation.stages.stage0.hex1;
|
||||||
|
@ -8,8 +10,7 @@ let
|
||||||
builders = config.aux.foundation.builders;
|
builders = config.aux.foundation.builders;
|
||||||
sources = config.aux.foundation.stages.stage0.sources;
|
sources = config.aux.foundation.stages.stage0.sources;
|
||||||
architecture = config.aux.foundation.stages.stage0.architecture;
|
architecture = config.aux.foundation.stages.stage0.architecture;
|
||||||
in
|
in {
|
||||||
{
|
|
||||||
options.aux.foundation.stages.stage0.hex2-0 = {
|
options.aux.foundation.stages.stage0.hex2-0 = {
|
||||||
meta = {
|
meta = {
|
||||||
description = lib.options.create {
|
description = lib.options.create {
|
||||||
|
@ -34,7 +35,10 @@ in
|
||||||
platforms = lib.options.create {
|
platforms = lib.options.create {
|
||||||
type = lib.types.list.of lib.types.string;
|
type = lib.types.list.of lib.types.string;
|
||||||
description = "Platforms the package supports.";
|
description = "Platforms the package supports.";
|
||||||
default.value = [ "i686-linux" ];
|
default.value = [
|
||||||
|
"x86_64-linux"
|
||||||
|
"i686-linux"
|
||||||
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
{ lib, config }:
|
{
|
||||||
let
|
lib,
|
||||||
|
config,
|
||||||
|
}: let
|
||||||
cfg = config.aux.foundation.stages.stage0.catm;
|
cfg = config.aux.foundation.stages.stage0.catm;
|
||||||
hex0 = config.aux.foundation.stages.stage0.hex0;
|
hex0 = config.aux.foundation.stages.stage0.hex0;
|
||||||
hex1 = config.aux.foundation.stages.stage0.hex1;
|
hex1 = config.aux.foundation.stages.stage0.hex1;
|
||||||
|
@ -9,8 +11,7 @@ let
|
||||||
builders = config.aux.foundation.builders;
|
builders = config.aux.foundation.builders;
|
||||||
sources = config.aux.foundation.stages.stage0.sources;
|
sources = config.aux.foundation.stages.stage0.sources;
|
||||||
architecture = config.aux.foundation.stages.stage0.architecture;
|
architecture = config.aux.foundation.stages.stage0.architecture;
|
||||||
in
|
in {
|
||||||
{
|
|
||||||
options.aux.foundation.stages.stage0.catm = {
|
options.aux.foundation.stages.stage0.catm = {
|
||||||
meta = {
|
meta = {
|
||||||
description = lib.options.create {
|
description = lib.options.create {
|
||||||
|
@ -35,7 +36,10 @@ in
|
||||||
platforms = lib.options.create {
|
platforms = lib.options.create {
|
||||||
type = lib.types.list.of lib.types.string;
|
type = lib.types.list.of lib.types.string;
|
||||||
description = "Platforms the package supports.";
|
description = "Platforms the package supports.";
|
||||||
default.value = [ "i686-linux" ];
|
default.value = [
|
||||||
|
"x86_64-linux"
|
||||||
|
"i686-linux"
|
||||||
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -54,19 +58,21 @@ in
|
||||||
|
|
||||||
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 =
|
args =
|
||||||
if architecture.base == "AArch64" then
|
if architecture.base == "AArch64"
|
||||||
[
|
then [
|
||||||
"${sources.base}/catm_${architecture.base}.hex1"
|
"${sources.base}/catm_${architecture.base}.hex1"
|
||||||
(builtins.placeholder "out")
|
(builtins.placeholder "out")
|
||||||
]
|
]
|
||||||
else
|
else [
|
||||||
[
|
"${sources.base}/catm_${architecture.base}.hex2"
|
||||||
"${sources.base}/catm_${architecture.base}.hex2"
|
(builtins.placeholder "out")
|
||||||
(builtins.placeholder "out")
|
];
|
||||||
];
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
{ lib, config }:
|
{
|
||||||
let
|
lib,
|
||||||
|
config,
|
||||||
|
}: let
|
||||||
cfg = config.aux.foundation.stages.stage0.M0;
|
cfg = config.aux.foundation.stages.stage0.M0;
|
||||||
hex0 = config.aux.foundation.stages.stage0.hex0;
|
hex0 = config.aux.foundation.stages.stage0.hex0;
|
||||||
hex2-0 = config.aux.foundation.stages.stage0.hex2-0;
|
hex2-0 = config.aux.foundation.stages.stage0.hex2-0;
|
||||||
|
@ -9,8 +11,7 @@ let
|
||||||
builders = config.aux.foundation.builders;
|
builders = config.aux.foundation.builders;
|
||||||
sources = config.aux.foundation.stages.stage0.sources;
|
sources = config.aux.foundation.stages.stage0.sources;
|
||||||
architecture = config.aux.foundation.stages.stage0.architecture;
|
architecture = config.aux.foundation.stages.stage0.architecture;
|
||||||
in
|
in {
|
||||||
{
|
|
||||||
options.aux.foundation.stages.stage0.M0 = {
|
options.aux.foundation.stages.stage0.M0 = {
|
||||||
meta = {
|
meta = {
|
||||||
description = lib.options.create {
|
description = lib.options.create {
|
||||||
|
@ -35,7 +36,10 @@ in
|
||||||
platforms = lib.options.create {
|
platforms = lib.options.create {
|
||||||
type = lib.types.list.of lib.types.string;
|
type = lib.types.list.of lib.types.string;
|
||||||
description = "Platforms the package supports.";
|
description = "Platforms the package supports.";
|
||||||
default.value = [ "i686-linux" ];
|
default.value = [
|
||||||
|
"x86_64-linux"
|
||||||
|
"i686-linux"
|
||||||
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -56,27 +60,25 @@ in
|
||||||
|
|
||||||
executable = hex2-0.package;
|
executable = hex2-0.package;
|
||||||
|
|
||||||
args =
|
args = let
|
||||||
let
|
M0_hex2-0 = builders.raw.build {
|
||||||
M0_hex2-0 = builders.raw.build {
|
pname = "M0_hex2-0";
|
||||||
pname = "M0_hex2-0";
|
version = "1.6.0";
|
||||||
version = "1.6.0";
|
|
||||||
|
|
||||||
meta = cfg.meta;
|
meta = cfg.meta;
|
||||||
|
|
||||||
executable = catm.package;
|
executable = catm.package;
|
||||||
|
|
||||||
args = [
|
args = [
|
||||||
(builtins.placeholder "out")
|
(builtins.placeholder "out")
|
||||||
"${sources.m2libc}/${architecture.m2libc}/ELF-${architecture.m2libc}.hex2"
|
"${sources.m2libc}/${architecture.m2libc}/ELF-${architecture.m2libc}.hex2"
|
||||||
"${sources.base}/M0_${architecture.base}.hex2"
|
"${sources.base}/M0_${architecture.base}.hex2"
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
in
|
in [
|
||||||
[
|
M0_hex2-0
|
||||||
M0_hex2-0
|
(builtins.placeholder "out")
|
||||||
(builtins.placeholder "out")
|
];
|
||||||
];
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
{ lib, config }:
|
{
|
||||||
let
|
lib,
|
||||||
|
config,
|
||||||
|
}: let
|
||||||
cfg = config.aux.foundation.stages.stage0.cc_arch;
|
cfg = config.aux.foundation.stages.stage0.cc_arch;
|
||||||
hex0 = config.aux.foundation.stages.stage0.hex0;
|
hex0 = config.aux.foundation.stages.stage0.hex0;
|
||||||
hex2-0 = config.aux.foundation.stages.stage0.hex2-0;
|
hex2-0 = config.aux.foundation.stages.stage0.hex2-0;
|
||||||
|
@ -10,8 +12,7 @@ let
|
||||||
builders = config.aux.foundation.builders;
|
builders = config.aux.foundation.builders;
|
||||||
sources = config.aux.foundation.stages.stage0.sources;
|
sources = config.aux.foundation.stages.stage0.sources;
|
||||||
architecture = config.aux.foundation.stages.stage0.architecture;
|
architecture = config.aux.foundation.stages.stage0.architecture;
|
||||||
in
|
in {
|
||||||
{
|
|
||||||
options.aux.foundation.stages.stage0.cc_arch = {
|
options.aux.foundation.stages.stage0.cc_arch = {
|
||||||
meta = {
|
meta = {
|
||||||
description = lib.options.create {
|
description = lib.options.create {
|
||||||
|
@ -36,7 +37,10 @@ in
|
||||||
platforms = lib.options.create {
|
platforms = lib.options.create {
|
||||||
type = lib.types.list.of lib.types.string;
|
type = lib.types.list.of lib.types.string;
|
||||||
description = "Platforms the package supports.";
|
description = "Platforms the package supports.";
|
||||||
default.value = [ "i686-linux" ];
|
default.value = [
|
||||||
|
"x86_64-linux"
|
||||||
|
"i686-linux"
|
||||||
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -57,40 +61,38 @@ in
|
||||||
|
|
||||||
executable = hex2-0.package;
|
executable = hex2-0.package;
|
||||||
|
|
||||||
args =
|
args = let
|
||||||
let
|
cc_arch0_hex2-0 = builders.raw.build {
|
||||||
cc_arch0_hex2-0 = builders.raw.build {
|
pname = "cc_arch0_hex2-0";
|
||||||
pname = "cc_arch0_hex2-0";
|
version = "1.6.0";
|
||||||
version = "1.6.0";
|
|
||||||
|
|
||||||
meta = cfg.meta;
|
meta = cfg.meta;
|
||||||
|
|
||||||
executable = M0.package;
|
executable = M0.package;
|
||||||
|
|
||||||
args = [
|
args = [
|
||||||
"${sources.base}/cc_${architecture.m2libc}.M1"
|
"${sources.base}/cc_${architecture.m2libc}.M1"
|
||||||
(builtins.placeholder "out")
|
(builtins.placeholder "out")
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
cc_arch1_hex2-0 = builders.raw.build {
|
cc_arch1_hex2-0 = builders.raw.build {
|
||||||
pname = "cc_arch1_hex2-0";
|
pname = "cc_arch1_hex2-0";
|
||||||
version = "1.6.0";
|
version = "1.6.0";
|
||||||
|
|
||||||
meta = cfg.meta;
|
meta = cfg.meta;
|
||||||
|
|
||||||
executable = catm.package;
|
executable = catm.package;
|
||||||
|
|
||||||
args = [
|
args = [
|
||||||
(builtins.placeholder "out")
|
(builtins.placeholder "out")
|
||||||
"${sources.m2libc}/${architecture.m2libc}/ELF-${architecture.m2libc}.hex2"
|
"${sources.m2libc}/${architecture.m2libc}/ELF-${architecture.m2libc}.hex2"
|
||||||
cc_arch0_hex2-0
|
cc_arch0_hex2-0
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
in
|
in [
|
||||||
[
|
cc_arch1_hex2-0
|
||||||
cc_arch1_hex2-0
|
(builtins.placeholder "out")
|
||||||
(builtins.placeholder "out")
|
];
|
||||||
];
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
{ lib, config }:
|
{
|
||||||
let
|
lib,
|
||||||
|
config,
|
||||||
|
}: let
|
||||||
cfg = config.aux.foundation.stages.stage0.M2;
|
cfg = config.aux.foundation.stages.stage0.M2;
|
||||||
hex0 = config.aux.foundation.stages.stage0.hex0;
|
hex0 = config.aux.foundation.stages.stage0.hex0;
|
||||||
hex2-0 = config.aux.foundation.stages.stage0.hex2-0;
|
hex2-0 = config.aux.foundation.stages.stage0.hex2-0;
|
||||||
|
@ -11,8 +13,7 @@ let
|
||||||
builders = config.aux.foundation.builders;
|
builders = config.aux.foundation.builders;
|
||||||
sources = config.aux.foundation.stages.stage0.sources;
|
sources = config.aux.foundation.stages.stage0.sources;
|
||||||
architecture = config.aux.foundation.stages.stage0.architecture;
|
architecture = config.aux.foundation.stages.stage0.architecture;
|
||||||
in
|
in {
|
||||||
{
|
|
||||||
options.aux.foundation.stages.stage0.M2 = {
|
options.aux.foundation.stages.stage0.M2 = {
|
||||||
meta = {
|
meta = {
|
||||||
description = lib.options.create {
|
description = lib.options.create {
|
||||||
|
@ -37,7 +38,10 @@ in
|
||||||
platforms = lib.options.create {
|
platforms = lib.options.create {
|
||||||
type = lib.types.list.of lib.types.string;
|
type = lib.types.list.of lib.types.string;
|
||||||
description = "Platforms the package supports.";
|
description = "Platforms the package supports.";
|
||||||
default.value = [ "i686-linux" ];
|
default.value = [
|
||||||
|
"x86_64-linux"
|
||||||
|
"i686-linux"
|
||||||
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -58,90 +62,88 @@ in
|
||||||
|
|
||||||
executable = hex2-0.package;
|
executable = hex2-0.package;
|
||||||
|
|
||||||
args =
|
args = let
|
||||||
let
|
M2_c = builders.raw.build {
|
||||||
M2_c = builders.raw.build {
|
pname = "M2_c";
|
||||||
pname = "M2_c";
|
version = "1.6.0";
|
||||||
version = "1.6.0";
|
|
||||||
|
|
||||||
meta = cfg.meta;
|
meta = cfg.meta;
|
||||||
|
|
||||||
executable = catm.package;
|
executable = catm.package;
|
||||||
|
|
||||||
args = [
|
args = [
|
||||||
(builtins.placeholder "out")
|
(builtins.placeholder "out")
|
||||||
"${sources.m2libc}/${architecture.m2libc}/linux/bootstrap.c"
|
"${sources.m2libc}/${architecture.m2libc}/linux/bootstrap.c"
|
||||||
"${sources.m2planet}/cc.h"
|
"${sources.m2planet}/cc.h"
|
||||||
"${sources.m2libc}/bootstrappable.c"
|
"${sources.m2libc}/bootstrappable.c"
|
||||||
"${sources.m2planet}/cc_globals.c"
|
"${sources.m2planet}/cc_globals.c"
|
||||||
"${sources.m2planet}/cc_reader.c"
|
"${sources.m2planet}/cc_reader.c"
|
||||||
"${sources.m2planet}/cc_strings.c"
|
"${sources.m2planet}/cc_strings.c"
|
||||||
"${sources.m2planet}/cc_types.c"
|
"${sources.m2planet}/cc_types.c"
|
||||||
"${sources.m2planet}/cc_core.c"
|
"${sources.m2planet}/cc_core.c"
|
||||||
"${sources.m2planet}/cc_macro.c"
|
"${sources.m2planet}/cc_macro.c"
|
||||||
"${sources.m2planet}/cc.c"
|
"${sources.m2planet}/cc.c"
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
M2_M1 = builders.raw.build {
|
M2_M1 = builders.raw.build {
|
||||||
pname = "M2_M1";
|
pname = "M2_M1";
|
||||||
version = "1.6.0";
|
version = "1.6.0";
|
||||||
|
|
||||||
meta = cfg.meta;
|
meta = cfg.meta;
|
||||||
|
|
||||||
executable = cc_arch.package;
|
executable = cc_arch.package;
|
||||||
|
|
||||||
args = [
|
args = [
|
||||||
M2_c
|
M2_c
|
||||||
(builtins.placeholder "out")
|
(builtins.placeholder "out")
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
M2_M1' = builders.raw.build {
|
M2_M1' = builders.raw.build {
|
||||||
pname = "M2_M1";
|
pname = "M2_M1";
|
||||||
version = "1.6.0";
|
version = "1.6.0";
|
||||||
|
|
||||||
meta = cfg.meta;
|
meta = cfg.meta;
|
||||||
|
|
||||||
executable = catm.package;
|
executable = catm.package;
|
||||||
|
|
||||||
args = [
|
args = [
|
||||||
(builtins.placeholder "out")
|
(builtins.placeholder "out")
|
||||||
"${sources.m2libc}/${architecture.m2libc}/${architecture.m2libc}_defs.M1"
|
"${sources.m2libc}/${architecture.m2libc}/${architecture.m2libc}_defs.M1"
|
||||||
"${sources.m2libc}/${architecture.m2libc}/libc-core.M1"
|
"${sources.m2libc}/${architecture.m2libc}/libc-core.M1"
|
||||||
M2_M1
|
M2_M1
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
M2_hex2-0 = builders.raw.build {
|
M2_hex2-0 = builders.raw.build {
|
||||||
pname = "M2_hex2-0";
|
pname = "M2_hex2-0";
|
||||||
version = "1.6.0";
|
version = "1.6.0";
|
||||||
|
|
||||||
meta = cfg.meta;
|
meta = cfg.meta;
|
||||||
|
|
||||||
executable = M0.package;
|
executable = M0.package;
|
||||||
|
|
||||||
args = [
|
args = [
|
||||||
M2_M1'
|
M2_M1'
|
||||||
(builtins.placeholder "out")
|
(builtins.placeholder "out")
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
M2_hex2-0' = builders.raw.build {
|
M2_hex2-0' = builders.raw.build {
|
||||||
pname = "M2_hex2-0";
|
pname = "M2_hex2-0";
|
||||||
version = "1.6.0";
|
version = "1.6.0";
|
||||||
|
|
||||||
meta = cfg.meta;
|
meta = cfg.meta;
|
||||||
|
|
||||||
executable = catm.package;
|
executable = catm.package;
|
||||||
|
|
||||||
args = [
|
args = [
|
||||||
(builtins.placeholder "out")
|
(builtins.placeholder "out")
|
||||||
"${sources.m2libc}/${architecture.m2libc}/ELF-${architecture.m2libc}.hex2"
|
"${sources.m2libc}/${architecture.m2libc}/ELF-${architecture.m2libc}.hex2"
|
||||||
M2_hex2-0
|
M2_hex2-0
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
in
|
in [
|
||||||
[
|
M2_hex2-0'
|
||||||
M2_hex2-0'
|
(builtins.placeholder "out")
|
||||||
(builtins.placeholder "out")
|
];
|
||||||
];
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
{ lib, config }:
|
{
|
||||||
let
|
lib,
|
||||||
|
config,
|
||||||
|
}: let
|
||||||
cfg = config.aux.foundation.stages.stage0.blood-elf;
|
cfg = config.aux.foundation.stages.stage0.blood-elf;
|
||||||
hex0 = config.aux.foundation.stages.stage0.hex0;
|
hex0 = config.aux.foundation.stages.stage0.hex0;
|
||||||
hex2-0 = config.aux.foundation.stages.stage0.hex2-0;
|
hex2-0 = config.aux.foundation.stages.stage0.hex2-0;
|
||||||
|
@ -12,8 +14,7 @@ let
|
||||||
builders = config.aux.foundation.builders;
|
builders = config.aux.foundation.builders;
|
||||||
sources = config.aux.foundation.stages.stage0.sources;
|
sources = config.aux.foundation.stages.stage0.sources;
|
||||||
architecture = config.aux.foundation.stages.stage0.architecture;
|
architecture = config.aux.foundation.stages.stage0.architecture;
|
||||||
in
|
in {
|
||||||
{
|
|
||||||
options.aux.foundation.stages.stage0.blood-elf = {
|
options.aux.foundation.stages.stage0.blood-elf = {
|
||||||
meta = {
|
meta = {
|
||||||
description = lib.options.create {
|
description = lib.options.create {
|
||||||
|
@ -38,7 +39,10 @@ in
|
||||||
platforms = lib.options.create {
|
platforms = lib.options.create {
|
||||||
type = lib.types.list.of lib.types.string;
|
type = lib.types.list.of lib.types.string;
|
||||||
description = "Platforms the package supports.";
|
description = "Platforms the package supports.";
|
||||||
default.value = [ "i686-linux" ];
|
default.value = [
|
||||||
|
"x86_64-linux"
|
||||||
|
"i686-linux"
|
||||||
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -59,79 +63,77 @@ in
|
||||||
|
|
||||||
executable = hex2-0.package;
|
executable = hex2-0.package;
|
||||||
|
|
||||||
args =
|
args = let
|
||||||
let
|
blood-elf_M1 = builders.raw.build {
|
||||||
blood-elf_M1 = builders.raw.build {
|
pname = "blood-elf_M1";
|
||||||
pname = "blood-elf_M1";
|
version = "1.6.0";
|
||||||
version = "1.6.0";
|
|
||||||
|
|
||||||
meta = cfg.meta;
|
meta = cfg.meta;
|
||||||
|
|
||||||
executable = M2.package;
|
executable = M2.package;
|
||||||
|
|
||||||
args = [
|
args = [
|
||||||
"--architecture"
|
"--architecture"
|
||||||
architecture.m2libc
|
architecture.m2libc
|
||||||
"-f"
|
"-f"
|
||||||
"${sources.m2libc}/${architecture.m2libc}/linux/bootstrap.c"
|
"${sources.m2libc}/${architecture.m2libc}/linux/bootstrap.c"
|
||||||
"-f"
|
"-f"
|
||||||
"${sources.m2libc}/bootstrappable.c"
|
"${sources.m2libc}/bootstrappable.c"
|
||||||
"-f"
|
"-f"
|
||||||
"${sources.mescc-tools}/stringify.c"
|
"${sources.mescc-tools}/stringify.c"
|
||||||
"-f"
|
"-f"
|
||||||
"${sources.mescc-tools}/blood-elf.c"
|
"${sources.mescc-tools}/blood-elf.c"
|
||||||
"--bootstrap-mode"
|
"--bootstrap-mode"
|
||||||
"-o"
|
"-o"
|
||||||
(builtins.placeholder "out")
|
(builtins.placeholder "out")
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
blood-elf_M1' = builders.raw.build {
|
blood-elf_M1' = builders.raw.build {
|
||||||
pname = "blood-elf_M1-1";
|
pname = "blood-elf_M1-1";
|
||||||
version = "1.6.0";
|
version = "1.6.0";
|
||||||
|
|
||||||
meta = cfg.meta;
|
meta = cfg.meta;
|
||||||
|
|
||||||
executable = catm.package;
|
executable = catm.package;
|
||||||
|
|
||||||
args = [
|
args = [
|
||||||
(builtins.placeholder "out")
|
(builtins.placeholder "out")
|
||||||
"${sources.m2libc}/${architecture.m2libc}/${architecture.m2libc}_defs.M1"
|
"${sources.m2libc}/${architecture.m2libc}/${architecture.m2libc}_defs.M1"
|
||||||
"${sources.m2libc}/${architecture.m2libc}/libc-core.M1"
|
"${sources.m2libc}/${architecture.m2libc}/libc-core.M1"
|
||||||
blood-elf_M1
|
blood-elf_M1
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
blood-elf_hex2-0 = builders.raw.build {
|
blood-elf_hex2-0 = builders.raw.build {
|
||||||
pname = "blood-elf_hex2-0";
|
pname = "blood-elf_hex2-0";
|
||||||
version = "1.6.0";
|
version = "1.6.0";
|
||||||
|
|
||||||
meta = cfg.meta;
|
meta = cfg.meta;
|
||||||
|
|
||||||
executable = M0.package;
|
executable = M0.package;
|
||||||
|
|
||||||
args = [
|
args = [
|
||||||
blood-elf_M1'
|
blood-elf_M1'
|
||||||
(builtins.placeholder "out")
|
(builtins.placeholder "out")
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
blood-elf_hex2-0' = builders.raw.build {
|
blood-elf_hex2-0' = builders.raw.build {
|
||||||
pname = "blood-elf_hex2-0-1";
|
pname = "blood-elf_hex2-0-1";
|
||||||
version = "1.6.0";
|
version = "1.6.0";
|
||||||
|
|
||||||
meta = cfg.meta;
|
meta = cfg.meta;
|
||||||
|
|
||||||
executable = catm.package;
|
executable = catm.package;
|
||||||
|
|
||||||
args = [
|
args = [
|
||||||
(builtins.placeholder "out")
|
(builtins.placeholder "out")
|
||||||
"${sources.m2libc}/${architecture.m2libc}/ELF-${architecture.m2libc}.hex2"
|
"${sources.m2libc}/${architecture.m2libc}/ELF-${architecture.m2libc}.hex2"
|
||||||
blood-elf_hex2-0
|
blood-elf_hex2-0
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
in
|
in [
|
||||||
[
|
blood-elf_hex2-0'
|
||||||
blood-elf_hex2-0'
|
(builtins.placeholder "out")
|
||||||
(builtins.placeholder "out")
|
];
|
||||||
];
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
{ lib, config }:
|
{
|
||||||
let
|
lib,
|
||||||
|
config,
|
||||||
|
}: let
|
||||||
cfg = config.aux.foundation.stages.stage0.M1-0;
|
cfg = config.aux.foundation.stages.stage0.M1-0;
|
||||||
hex0 = config.aux.foundation.stages.stage0.hex0;
|
hex0 = config.aux.foundation.stages.stage0.hex0;
|
||||||
hex2-0 = config.aux.foundation.stages.stage0.hex2-0;
|
hex2-0 = config.aux.foundation.stages.stage0.hex2-0;
|
||||||
|
@ -13,8 +15,7 @@ let
|
||||||
builders = config.aux.foundation.builders;
|
builders = config.aux.foundation.builders;
|
||||||
sources = config.aux.foundation.stages.stage0.sources;
|
sources = config.aux.foundation.stages.stage0.sources;
|
||||||
architecture = config.aux.foundation.stages.stage0.architecture;
|
architecture = config.aux.foundation.stages.stage0.architecture;
|
||||||
in
|
in {
|
||||||
{
|
|
||||||
options.aux.foundation.stages.stage0.M1-0 = {
|
options.aux.foundation.stages.stage0.M1-0 = {
|
||||||
meta = {
|
meta = {
|
||||||
description = lib.options.create {
|
description = lib.options.create {
|
||||||
|
@ -39,7 +40,10 @@ in
|
||||||
platforms = lib.options.create {
|
platforms = lib.options.create {
|
||||||
type = lib.types.list.of lib.types.string;
|
type = lib.types.list.of lib.types.string;
|
||||||
description = "Platforms the package supports.";
|
description = "Platforms the package supports.";
|
||||||
default.value = [ "i686-linux" ];
|
default.value = [
|
||||||
|
"x86_64-linux"
|
||||||
|
"i686-linux"
|
||||||
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -60,97 +64,101 @@ in
|
||||||
|
|
||||||
executable = hex2-0.package;
|
executable = hex2-0.package;
|
||||||
|
|
||||||
args =
|
args = let
|
||||||
let
|
M1-macro-0_M1 = builders.raw.build {
|
||||||
M1-macro-0_M1 = builders.raw.build {
|
pname = "M1-macro-0_M1";
|
||||||
pname = "M1-macro-0_M1";
|
version = "1.6.0";
|
||||||
version = "1.6.0";
|
|
||||||
|
|
||||||
meta = cfg.meta;
|
meta = cfg.meta;
|
||||||
|
|
||||||
executable = M2.package;
|
executable = M2.package;
|
||||||
|
|
||||||
args = [
|
args = [
|
||||||
"--architecture"
|
"--architecture"
|
||||||
architecture.m2libc
|
architecture.m2libc
|
||||||
|
"-f"
|
||||||
|
"${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"
|
"-f"
|
||||||
"${sources.m2libc}/${architecture.m2libc}/linux/bootstrap.c"
|
M1-macro-0_M1
|
||||||
"-f"
|
(
|
||||||
"${sources.m2libc}/bootstrappable.c"
|
if config.aux.platform.endian == "little"
|
||||||
"-f"
|
then "--little-endian"
|
||||||
"${sources.mescc-tools}/stringify.c"
|
else "--big-endian"
|
||||||
"-f"
|
)
|
||||||
"${sources.mescc-tools}/M1-macro.c"
|
|
||||||
"--bootstrap-mode"
|
|
||||||
"--debug"
|
|
||||||
"-o"
|
"-o"
|
||||||
(builtins.placeholder "out")
|
(builtins.placeholder "out")
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
M1-macro-0-footer_M1 = builders.raw.build {
|
M1-macro-0_M1' = builders.raw.build {
|
||||||
pname = "M1-macro-0-footer_M1";
|
pname = "M1-macro-0_M1-1";
|
||||||
version = "1.6.0";
|
version = "1.6.0";
|
||||||
|
|
||||||
meta = cfg.meta;
|
meta = cfg.meta;
|
||||||
|
|
||||||
executable = blood-elf.package;
|
executable = catm.package;
|
||||||
|
|
||||||
args = (lib.lists.when (config.aux.platform.bits == 64) "--64") ++ [
|
args = [
|
||||||
"-f"
|
(builtins.placeholder "out")
|
||||||
M1-macro-0_M1
|
"${sources.m2libc}/${architecture.m2libc}/${architecture.m2libc}_defs.M1"
|
||||||
(if config.aux.platform.endian == "little" then "--little-endian" else "--big-endian")
|
"${sources.m2libc}/${architecture.m2libc}/libc-core.M1"
|
||||||
"-o"
|
M1-macro-0_M1
|
||||||
(builtins.placeholder "out")
|
M1-macro-0-footer_M1
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
M1-macro-0_M1' = builders.raw.build {
|
M1-macro-0_hex2-0 = builders.raw.build {
|
||||||
pname = "M1-macro-0_M1-1";
|
pname = "M1-macro-0_hex2-0";
|
||||||
version = "1.6.0";
|
version = "1.6.0";
|
||||||
|
|
||||||
meta = cfg.meta;
|
meta = cfg.meta;
|
||||||
|
|
||||||
executable = catm.package;
|
executable = M0.package;
|
||||||
|
|
||||||
args = [
|
args = [
|
||||||
(builtins.placeholder "out")
|
M1-macro-0_M1'
|
||||||
"${sources.m2libc}/${architecture.m2libc}/${architecture.m2libc}_defs.M1"
|
(builtins.placeholder "out")
|
||||||
"${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-1";
|
||||||
};
|
version = "1.6.0";
|
||||||
M1-macro-0_hex2-0 = builders.raw.build {
|
|
||||||
pname = "M1-macro-0_hex2-0";
|
|
||||||
version = "1.6.0";
|
|
||||||
|
|
||||||
meta = cfg.meta;
|
meta = cfg.meta;
|
||||||
|
|
||||||
executable = M0.package;
|
executable = catm.package;
|
||||||
|
|
||||||
args = [
|
args = [
|
||||||
M1-macro-0_M1'
|
(builtins.placeholder "out")
|
||||||
(builtins.placeholder "out")
|
"${sources.m2libc}/${architecture.m2libc}/ELF-${architecture.m2libc}-debug.hex2"
|
||||||
];
|
M1-macro-0_hex2-0
|
||||||
};
|
];
|
||||||
M1-macro-0_hex2-0' = builders.raw.build {
|
};
|
||||||
pname = "M1-macro-0_hex2-0-1";
|
in [
|
||||||
version = "1.6.0";
|
M1-macro-0_hex2-0'
|
||||||
|
(builtins.placeholder "out")
|
||||||
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")
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
{ lib, config }:
|
{
|
||||||
let
|
lib,
|
||||||
|
config,
|
||||||
|
}: let
|
||||||
cfg = config.aux.foundation.stages.stage0.hex2-1;
|
cfg = config.aux.foundation.stages.stage0.hex2-1;
|
||||||
hex0 = config.aux.foundation.stages.stage0.hex0;
|
hex0 = config.aux.foundation.stages.stage0.hex0;
|
||||||
hex2-0 = config.aux.foundation.stages.stage0.hex2-0;
|
hex2-0 = config.aux.foundation.stages.stage0.hex2-0;
|
||||||
|
@ -14,8 +16,7 @@ let
|
||||||
builders = config.aux.foundation.builders;
|
builders = config.aux.foundation.builders;
|
||||||
sources = config.aux.foundation.stages.stage0.sources;
|
sources = config.aux.foundation.stages.stage0.sources;
|
||||||
architecture = config.aux.foundation.stages.stage0.architecture;
|
architecture = config.aux.foundation.stages.stage0.architecture;
|
||||||
in
|
in {
|
||||||
{
|
|
||||||
options.aux.foundation.stages.stage0.hex2-1 = {
|
options.aux.foundation.stages.stage0.hex2-1 = {
|
||||||
meta = {
|
meta = {
|
||||||
description = lib.options.create {
|
description = lib.options.create {
|
||||||
|
@ -40,7 +41,10 @@ in
|
||||||
platforms = lib.options.create {
|
platforms = lib.options.create {
|
||||||
type = lib.types.list.of lib.types.string;
|
type = lib.types.list.of lib.types.string;
|
||||||
description = "Platforms the package supports.";
|
description = "Platforms the package supports.";
|
||||||
default.value = [ "i686-linux" ];
|
default.value = [
|
||||||
|
"x86_64-linux"
|
||||||
|
"i686-linux"
|
||||||
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -61,111 +65,119 @@ in
|
||||||
|
|
||||||
executable = hex2-0.package;
|
executable = hex2-0.package;
|
||||||
|
|
||||||
args =
|
args = let
|
||||||
let
|
hex2_linker_M1 = builders.raw.build {
|
||||||
hex2_linker_M1 = builders.raw.build {
|
pname = "hex2_linker_M1";
|
||||||
pname = "hex2_linker_M1";
|
version = "1.6.0";
|
||||||
version = "1.6.0";
|
|
||||||
|
|
||||||
meta = cfg.meta;
|
meta = cfg.meta;
|
||||||
|
|
||||||
executable = M2.package;
|
executable = M2.package;
|
||||||
|
|
||||||
args = [
|
args = [
|
||||||
"--architecture"
|
"--architecture"
|
||||||
architecture.m2libc
|
architecture.m2libc
|
||||||
"-f"
|
"-f"
|
||||||
"${sources.m2libc}/sys/types.h"
|
"${sources.m2libc}/sys/types.h"
|
||||||
"-f"
|
"-f"
|
||||||
"${sources.m2libc}/stddef.h"
|
"${sources.m2libc}/stddef.h"
|
||||||
"-f"
|
"-f"
|
||||||
"${sources.m2libc}/${architecture.m2libc}/linux/unistd.c"
|
"${sources.m2libc}/${architecture.m2libc}/linux/unistd.c"
|
||||||
"-f"
|
"-f"
|
||||||
"${sources.m2libc}/${architecture.m2libc}/linux/fcntl.c"
|
"${sources.m2libc}/${architecture.m2libc}/linux/fcntl.c"
|
||||||
"-f"
|
"-f"
|
||||||
"${sources.m2libc}/fcntl.c"
|
"${sources.m2libc}/fcntl.c"
|
||||||
"-f"
|
"-f"
|
||||||
"${sources.m2libc}/${architecture.m2libc}/linux/sys/stat.c"
|
"${sources.m2libc}/${architecture.m2libc}/linux/sys/stat.c"
|
||||||
"-f"
|
"-f"
|
||||||
"${sources.m2libc}/stdlib.c"
|
"${sources.m2libc}/stdlib.c"
|
||||||
"-f"
|
"-f"
|
||||||
"${sources.m2libc}/stdio.h"
|
"${sources.m2libc}/stdio.h"
|
||||||
"-f"
|
"-f"
|
||||||
"${sources.m2libc}/stdio.c"
|
"${sources.m2libc}/stdio.c"
|
||||||
"-f"
|
"-f"
|
||||||
"${sources.m2libc}/bootstrappable.c"
|
"${sources.m2libc}/bootstrappable.c"
|
||||||
"-f"
|
"-f"
|
||||||
"${sources.mescc-tools}/hex2.h"
|
"${sources.mescc-tools}/hex2.h"
|
||||||
"-f"
|
"-f"
|
||||||
"${sources.mescc-tools}/hex2_linker.c"
|
"${sources.mescc-tools}/hex2_linker.c"
|
||||||
"-f"
|
"-f"
|
||||||
"${sources.mescc-tools}/hex2_word.c"
|
"${sources.mescc-tools}/hex2_word.c"
|
||||||
"-f"
|
"-f"
|
||||||
"${sources.mescc-tools}/hex2.c"
|
"${sources.mescc-tools}/hex2.c"
|
||||||
"--debug"
|
"--debug"
|
||||||
"-o"
|
"-o"
|
||||||
(builtins.placeholder "out")
|
(builtins.placeholder "out")
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
hex2_linker-footer_M1 = builders.raw.build {
|
hex2_linker-footer_M1 = builders.raw.build {
|
||||||
pname = "hex2_linker-footer_M1";
|
pname = "hex2_linker-footer_M1";
|
||||||
version = "1.6.0";
|
version = "1.6.0";
|
||||||
|
|
||||||
meta = cfg.meta;
|
meta = cfg.meta;
|
||||||
|
|
||||||
executable = blood-elf.package;
|
executable = blood-elf.package;
|
||||||
|
|
||||||
args = (lib.lists.when (config.aux.platform.bits == 64) "--64") ++ [
|
args =
|
||||||
|
(lib.lists.when (config.aux.platform.bits == 64) "--64")
|
||||||
|
++ [
|
||||||
"-f"
|
"-f"
|
||||||
hex2_linker_M1
|
hex2_linker_M1
|
||||||
(if config.aux.platform.endian == "little" then "--little-endian" else "--big-endian")
|
(
|
||||||
|
if config.aux.platform.endian == "little"
|
||||||
|
then "--little-endian"
|
||||||
|
else "--big-endian"
|
||||||
|
)
|
||||||
"-o"
|
"-o"
|
||||||
(builtins.placeholder "out")
|
(builtins.placeholder "out")
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
hex2_linker_hex2 = builders.raw.build {
|
hex2_linker_hex2 = builders.raw.build {
|
||||||
pname = "hex2_linker_hex2";
|
pname = "hex2_linker_hex2";
|
||||||
version = "1.6.0";
|
version = "1.6.0";
|
||||||
|
|
||||||
meta = cfg.meta;
|
meta = cfg.meta;
|
||||||
|
|
||||||
executable = M1-0.package;
|
executable = M1-0.package;
|
||||||
|
|
||||||
args = [
|
args = [
|
||||||
"--architecture"
|
"--architecture"
|
||||||
architecture.m2libc
|
architecture.m2libc
|
||||||
(if config.aux.platform.endian == "little" then "--little-endian" else "--big-endian")
|
(
|
||||||
"-f"
|
if config.aux.platform.endian == "little"
|
||||||
"${sources.m2libc}/${architecture.m2libc}/${architecture.m2libc}_defs.M1"
|
then "--little-endian"
|
||||||
"-f"
|
else "--big-endian"
|
||||||
"${sources.m2libc}/${architecture.m2libc}/libc-full.M1"
|
)
|
||||||
"-f"
|
"-f"
|
||||||
hex2_linker_M1
|
"${sources.m2libc}/${architecture.m2libc}/${architecture.m2libc}_defs.M1"
|
||||||
"-f"
|
"-f"
|
||||||
hex2_linker-footer_M1
|
"${sources.m2libc}/${architecture.m2libc}/libc-full.M1"
|
||||||
"-o"
|
"-f"
|
||||||
(builtins.placeholder "out")
|
hex2_linker_M1
|
||||||
];
|
"-f"
|
||||||
};
|
hex2_linker-footer_M1
|
||||||
hex2_linker_hex2' = builders.raw.build {
|
"-o"
|
||||||
pname = "hex2_linker_hex2-1";
|
(builtins.placeholder "out")
|
||||||
version = "1.6.0";
|
];
|
||||||
|
};
|
||||||
|
hex2_linker_hex2' = builders.raw.build {
|
||||||
|
pname = "hex2_linker_hex2-1";
|
||||||
|
version = "1.6.0";
|
||||||
|
|
||||||
meta = cfg.meta;
|
meta = cfg.meta;
|
||||||
|
|
||||||
executable = catm.package;
|
executable = catm.package;
|
||||||
|
|
||||||
args = [
|
args = [
|
||||||
(builtins.placeholder "out")
|
(builtins.placeholder "out")
|
||||||
"${sources.m2libc}/${architecture.m2libc}/ELF-${architecture.m2libc}-debug.hex2"
|
"${sources.m2libc}/${architecture.m2libc}/ELF-${architecture.m2libc}-debug.hex2"
|
||||||
hex2_linker_hex2
|
hex2_linker_hex2
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
in
|
in [
|
||||||
[
|
hex2_linker_hex2'
|
||||||
hex2_linker_hex2'
|
(builtins.placeholder "out")
|
||||||
(builtins.placeholder "out")
|
];
|
||||||
];
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
{ lib, config }:
|
{
|
||||||
let
|
lib,
|
||||||
|
config,
|
||||||
|
}: let
|
||||||
cfg = config.aux.foundation.stages.stage0.M1;
|
cfg = config.aux.foundation.stages.stage0.M1;
|
||||||
hex0 = config.aux.foundation.stages.stage0.hex0;
|
hex0 = config.aux.foundation.stages.stage0.hex0;
|
||||||
hex2-0 = config.aux.foundation.stages.stage0.hex2-0;
|
hex2-0 = config.aux.foundation.stages.stage0.hex2-0;
|
||||||
|
@ -15,8 +17,7 @@ let
|
||||||
builders = config.aux.foundation.builders;
|
builders = config.aux.foundation.builders;
|
||||||
sources = config.aux.foundation.stages.stage0.sources;
|
sources = config.aux.foundation.stages.stage0.sources;
|
||||||
architecture = config.aux.foundation.stages.stage0.architecture;
|
architecture = config.aux.foundation.stages.stage0.architecture;
|
||||||
in
|
in {
|
||||||
{
|
|
||||||
options.aux.foundation.stages.stage0.M1 = {
|
options.aux.foundation.stages.stage0.M1 = {
|
||||||
meta = {
|
meta = {
|
||||||
description = lib.options.create {
|
description = lib.options.create {
|
||||||
|
@ -41,7 +42,10 @@ in
|
||||||
platforms = lib.options.create {
|
platforms = lib.options.create {
|
||||||
type = lib.types.list.of lib.types.string;
|
type = lib.types.list.of lib.types.string;
|
||||||
description = "Platforms the package supports.";
|
description = "Platforms the package supports.";
|
||||||
default.value = [ "i686-linux" ];
|
default.value = [
|
||||||
|
"x86_64-linux"
|
||||||
|
"i686-linux"
|
||||||
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -62,113 +66,124 @@ in
|
||||||
|
|
||||||
executable = hex2-1.package;
|
executable = hex2-1.package;
|
||||||
|
|
||||||
args =
|
args = let
|
||||||
let
|
M1-macro_M1 = builders.raw.build {
|
||||||
M1-macro_M1 = builders.raw.build {
|
pname = "M1-macro_M1";
|
||||||
pname = "M1-macro_M1";
|
version = "1.6.0";
|
||||||
version = "1.6.0";
|
|
||||||
|
|
||||||
meta = cfg.meta;
|
meta = cfg.meta;
|
||||||
|
|
||||||
executable = M2.package;
|
executable = M2.package;
|
||||||
|
|
||||||
args = [
|
args = [
|
||||||
"--architecture"
|
"--architecture"
|
||||||
architecture.m2libc
|
architecture.m2libc
|
||||||
"-f"
|
"-f"
|
||||||
"${sources.m2libc}/sys/types.h"
|
"${sources.m2libc}/sys/types.h"
|
||||||
"-f"
|
"-f"
|
||||||
"${sources.m2libc}/stddef.h"
|
"${sources.m2libc}/stddef.h"
|
||||||
"-f"
|
"-f"
|
||||||
"${sources.m2libc}/${architecture.m2libc}/linux/unistd.c"
|
"${sources.m2libc}/${architecture.m2libc}/linux/unistd.c"
|
||||||
"-f"
|
"-f"
|
||||||
"${sources.m2libc}/${architecture.m2libc}/linux/fcntl.c"
|
"${sources.m2libc}/${architecture.m2libc}/linux/fcntl.c"
|
||||||
"-f"
|
"-f"
|
||||||
"${sources.m2libc}/fcntl.c"
|
"${sources.m2libc}/fcntl.c"
|
||||||
"-f"
|
"-f"
|
||||||
"${sources.m2libc}/${architecture.m2libc}/linux/sys/stat.c"
|
"${sources.m2libc}/${architecture.m2libc}/linux/sys/stat.c"
|
||||||
"-f"
|
"-f"
|
||||||
"${sources.m2libc}/string.c"
|
"${sources.m2libc}/string.c"
|
||||||
"-f"
|
"-f"
|
||||||
"${sources.m2libc}/stdlib.c"
|
"${sources.m2libc}/stdlib.c"
|
||||||
"-f"
|
"-f"
|
||||||
"${sources.m2libc}/stdio.h"
|
"${sources.m2libc}/stdio.h"
|
||||||
"-f"
|
"-f"
|
||||||
"${sources.m2libc}/stdio.c"
|
"${sources.m2libc}/stdio.c"
|
||||||
"-f"
|
"-f"
|
||||||
"${sources.m2libc}/bootstrappable.c"
|
"${sources.m2libc}/bootstrappable.c"
|
||||||
"-f"
|
"-f"
|
||||||
"${sources.mescc-tools}/stringify.c"
|
"${sources.mescc-tools}/stringify.c"
|
||||||
"-f"
|
"-f"
|
||||||
"${sources.mescc-tools}/M1-macro.c"
|
"${sources.mescc-tools}/M1-macro.c"
|
||||||
"--debug"
|
"--debug"
|
||||||
"-o"
|
"-o"
|
||||||
(builtins.placeholder "out")
|
(builtins.placeholder "out")
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
M1-macro-footer_M1 = builders.raw.build {
|
M1-macro-footer_M1 = builders.raw.build {
|
||||||
pname = "M1-macro-footer_M1";
|
pname = "M1-macro-footer_M1";
|
||||||
version = "1.6.0";
|
version = "1.6.0";
|
||||||
|
|
||||||
meta = cfg.meta;
|
meta = cfg.meta;
|
||||||
|
|
||||||
executable = blood-elf.package;
|
executable = blood-elf.package;
|
||||||
|
|
||||||
args = (lib.lists.when (config.aux.platform.bits == 64) "--64") ++ [
|
args =
|
||||||
|
(lib.lists.when (config.aux.platform.bits == 64) "--64")
|
||||||
|
++ [
|
||||||
"-f"
|
"-f"
|
||||||
M1-macro_M1
|
M1-macro_M1
|
||||||
(if config.aux.platform.endian == "little" then "--little-endian" else "--big-endian")
|
(
|
||||||
|
if config.aux.platform.endian == "little"
|
||||||
|
then "--little-endian"
|
||||||
|
else "--big-endian"
|
||||||
|
)
|
||||||
"-o"
|
"-o"
|
||||||
(builtins.placeholder "out")
|
(builtins.placeholder "out")
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
M1-macro_hex2 = builders.raw.build {
|
M1-macro_hex2 = builders.raw.build {
|
||||||
pname = "M1-macro_hex2";
|
pname = "M1-macro_hex2";
|
||||||
version = "1.6.0";
|
version = "1.6.0";
|
||||||
|
|
||||||
meta = cfg.meta;
|
meta = cfg.meta;
|
||||||
|
|
||||||
executable = M1-0.package;
|
executable = M1-0.package;
|
||||||
|
|
||||||
args = [
|
args = [
|
||||||
"--architecture"
|
"--architecture"
|
||||||
architecture.m2libc
|
architecture.m2libc
|
||||||
(if config.aux.platform.endian == "little" then "--little-endian" else "--big-endian")
|
(
|
||||||
"-f"
|
if config.aux.platform.endian == "little"
|
||||||
"${sources.m2libc}/${architecture.m2libc}/${architecture.m2libc}_defs.M1"
|
then "--little-endian"
|
||||||
"-f"
|
else "--big-endian"
|
||||||
"${sources.m2libc}/${architecture.m2libc}/libc-full.M1"
|
)
|
||||||
"-f"
|
"-f"
|
||||||
M1-macro_M1
|
"${sources.m2libc}/${architecture.m2libc}/${architecture.m2libc}_defs.M1"
|
||||||
"-f"
|
"-f"
|
||||||
M1-macro-footer_M1
|
"${sources.m2libc}/${architecture.m2libc}/libc-full.M1"
|
||||||
"-o"
|
"-f"
|
||||||
(builtins.placeholder "out")
|
M1-macro_M1
|
||||||
];
|
"-f"
|
||||||
};
|
M1-macro-footer_M1
|
||||||
in
|
"-o"
|
||||||
[
|
(builtins.placeholder "out")
|
||||||
"--architecture"
|
];
|
||||||
architecture.m2libc
|
};
|
||||||
(if config.aux.platform.endian == "little" then "--little-endian" else "--big-endian")
|
in [
|
||||||
"--base-address"
|
"--architecture"
|
||||||
(
|
architecture.m2libc
|
||||||
if config.aux.system == "x86_64-linux" then
|
(
|
||||||
"0x00600000"
|
if config.aux.platform.endian == "little"
|
||||||
else if config.aux.system == "aarch64-linux" then
|
then "--little-endian"
|
||||||
"0x00600000"
|
else "--big-endian"
|
||||||
else if config.aux.system == "i686-linux" then
|
)
|
||||||
"0x08048000"
|
"--base-address"
|
||||||
else
|
(
|
||||||
builtins.throw "Unsupported system: ${config.aux.system}"
|
if config.aux.system == "x86_64-linux"
|
||||||
)
|
then "0x00600000"
|
||||||
"-f"
|
else if config.aux.system == "aarch64-linux"
|
||||||
"${sources.m2libc}/${architecture.m2libc}/ELF-${architecture.m2libc}-debug.hex2"
|
then "0x00600000"
|
||||||
"-f"
|
else if config.aux.system == "i686-linux"
|
||||||
M1-macro_hex2
|
then "0x08048000"
|
||||||
"-o"
|
else builtins.throw "Unsupported system: ${config.aux.system}"
|
||||||
(builtins.placeholder "out")
|
)
|
||||||
];
|
"-f"
|
||||||
|
"${sources.m2libc}/${architecture.m2libc}/ELF-${architecture.m2libc}-debug.hex2"
|
||||||
|
"-f"
|
||||||
|
M1-macro_hex2
|
||||||
|
"-o"
|
||||||
|
(builtins.placeholder "out")
|
||||||
|
];
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
{ lib, config }:
|
{
|
||||||
let
|
lib,
|
||||||
|
config,
|
||||||
|
}: let
|
||||||
cfg = config.aux.foundation.stages.stage0.hex2;
|
cfg = config.aux.foundation.stages.stage0.hex2;
|
||||||
hex0 = config.aux.foundation.stages.stage0.hex0;
|
hex0 = config.aux.foundation.stages.stage0.hex0;
|
||||||
catm = config.aux.foundation.stages.stage0.catm;
|
catm = config.aux.foundation.stages.stage0.catm;
|
||||||
|
@ -14,8 +16,7 @@ let
|
||||||
builders = config.aux.foundation.builders;
|
builders = config.aux.foundation.builders;
|
||||||
sources = config.aux.foundation.stages.stage0.sources;
|
sources = config.aux.foundation.stages.stage0.sources;
|
||||||
architecture = config.aux.foundation.stages.stage0.architecture;
|
architecture = config.aux.foundation.stages.stage0.architecture;
|
||||||
in
|
in {
|
||||||
{
|
|
||||||
options.aux.foundation.stages.stage0.hex2 = {
|
options.aux.foundation.stages.stage0.hex2 = {
|
||||||
meta = {
|
meta = {
|
||||||
description = lib.options.create {
|
description = lib.options.create {
|
||||||
|
@ -40,7 +41,10 @@ in
|
||||||
platforms = lib.options.create {
|
platforms = lib.options.create {
|
||||||
type = lib.types.list.of lib.types.string;
|
type = lib.types.list.of lib.types.string;
|
||||||
description = "Platforms the package supports.";
|
description = "Platforms the package supports.";
|
||||||
default.value = [ "i686-linux" ];
|
default.value = [
|
||||||
|
"x86_64-linux"
|
||||||
|
"i686-linux"
|
||||||
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -61,115 +65,126 @@ in
|
||||||
|
|
||||||
executable = hex2-1.package;
|
executable = hex2-1.package;
|
||||||
|
|
||||||
args =
|
args = let
|
||||||
let
|
hex2_linker_M1 = builders.raw.build {
|
||||||
hex2_linker_M1 = builders.raw.build {
|
pname = "hex2_linker_M1";
|
||||||
pname = "hex2_linker_M1";
|
version = "1.6.0";
|
||||||
version = "1.6.0";
|
|
||||||
|
|
||||||
meta = cfg.meta;
|
meta = cfg.meta;
|
||||||
|
|
||||||
executable = M2.package;
|
executable = M2.package;
|
||||||
|
|
||||||
args = [
|
args = [
|
||||||
"--architecture"
|
"--architecture"
|
||||||
architecture.m2libc
|
architecture.m2libc
|
||||||
"-f"
|
"-f"
|
||||||
"${sources.m2libc}/sys/types.h"
|
"${sources.m2libc}/sys/types.h"
|
||||||
"-f"
|
"-f"
|
||||||
"${sources.m2libc}/stddef.h"
|
"${sources.m2libc}/stddef.h"
|
||||||
"-f"
|
"-f"
|
||||||
"${sources.m2libc}/${architecture.m2libc}/linux/unistd.c"
|
"${sources.m2libc}/${architecture.m2libc}/linux/unistd.c"
|
||||||
"-f"
|
"-f"
|
||||||
"${sources.m2libc}/${architecture.m2libc}/linux/fcntl.c"
|
"${sources.m2libc}/${architecture.m2libc}/linux/fcntl.c"
|
||||||
"-f"
|
"-f"
|
||||||
"${sources.m2libc}/fcntl.c"
|
"${sources.m2libc}/fcntl.c"
|
||||||
"-f"
|
"-f"
|
||||||
"${sources.m2libc}/${architecture.m2libc}/linux/sys/stat.c"
|
"${sources.m2libc}/${architecture.m2libc}/linux/sys/stat.c"
|
||||||
"-f"
|
"-f"
|
||||||
"${sources.m2libc}/stdlib.c"
|
"${sources.m2libc}/stdlib.c"
|
||||||
"-f"
|
"-f"
|
||||||
"${sources.m2libc}/stdio.h"
|
"${sources.m2libc}/stdio.h"
|
||||||
"-f"
|
"-f"
|
||||||
"${sources.m2libc}/stdio.c"
|
"${sources.m2libc}/stdio.c"
|
||||||
"-f"
|
"-f"
|
||||||
"${sources.m2libc}/bootstrappable.c"
|
"${sources.m2libc}/bootstrappable.c"
|
||||||
"-f"
|
"-f"
|
||||||
"${sources.mescc-tools}/hex2.h"
|
"${sources.mescc-tools}/hex2.h"
|
||||||
"-f"
|
"-f"
|
||||||
"${sources.mescc-tools}/hex2_linker.c"
|
"${sources.mescc-tools}/hex2_linker.c"
|
||||||
"-f"
|
"-f"
|
||||||
"${sources.mescc-tools}/hex2_word.c"
|
"${sources.mescc-tools}/hex2_word.c"
|
||||||
"-f"
|
"-f"
|
||||||
"${sources.mescc-tools}/hex2.c"
|
"${sources.mescc-tools}/hex2.c"
|
||||||
"--debug"
|
"--debug"
|
||||||
"-o"
|
"-o"
|
||||||
(builtins.placeholder "out")
|
(builtins.placeholder "out")
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
hex2_linker-footer_M1 = builders.raw.build {
|
hex2_linker-footer_M1 = builders.raw.build {
|
||||||
pname = "hex2_linker-footer_M1";
|
pname = "hex2_linker-footer_M1";
|
||||||
version = "1.6.0";
|
version = "1.6.0";
|
||||||
|
|
||||||
meta = cfg.meta;
|
meta = cfg.meta;
|
||||||
|
|
||||||
executable = blood-elf.package;
|
executable = blood-elf.package;
|
||||||
|
|
||||||
args = (lib.lists.when (config.aux.platform.bits == 64) "--64") ++ [
|
args =
|
||||||
|
(lib.lists.when (config.aux.platform.bits == 64) "--64")
|
||||||
|
++ [
|
||||||
"-f"
|
"-f"
|
||||||
hex2_linker_M1
|
hex2_linker_M1
|
||||||
(if config.aux.platform.endian == "little" then "--little-endian" else "--big-endian")
|
(
|
||||||
|
if config.aux.platform.endian == "little"
|
||||||
|
then "--little-endian"
|
||||||
|
else "--big-endian"
|
||||||
|
)
|
||||||
"-o"
|
"-o"
|
||||||
(builtins.placeholder "out")
|
(builtins.placeholder "out")
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
hex2_linker_hex2 = builders.raw.build {
|
hex2_linker_hex2 = builders.raw.build {
|
||||||
pname = "hex2_linker_hex2";
|
pname = "hex2_linker_hex2";
|
||||||
version = "1.6.0";
|
version = "1.6.0";
|
||||||
|
|
||||||
meta = cfg.meta;
|
meta = cfg.meta;
|
||||||
|
|
||||||
executable = M1.package;
|
executable = M1.package;
|
||||||
|
|
||||||
args = [
|
args = [
|
||||||
"--architecture"
|
"--architecture"
|
||||||
architecture.m2libc
|
architecture.m2libc
|
||||||
(if config.aux.platform.endian == "little" then "--little-endian" else "--big-endian")
|
(
|
||||||
"-f"
|
if config.aux.platform.endian == "little"
|
||||||
"${sources.m2libc}/${architecture.m2libc}/${architecture.m2libc}_defs.M1"
|
then "--little-endian"
|
||||||
"-f"
|
else "--big-endian"
|
||||||
"${sources.m2libc}/${architecture.m2libc}/libc-full.M1"
|
)
|
||||||
"-f"
|
"-f"
|
||||||
hex2_linker_M1
|
"${sources.m2libc}/${architecture.m2libc}/${architecture.m2libc}_defs.M1"
|
||||||
"-f"
|
"-f"
|
||||||
hex2_linker-footer_M1
|
"${sources.m2libc}/${architecture.m2libc}/libc-full.M1"
|
||||||
"-o"
|
"-f"
|
||||||
(builtins.placeholder "out")
|
hex2_linker_M1
|
||||||
];
|
"-f"
|
||||||
};
|
hex2_linker-footer_M1
|
||||||
in
|
"-o"
|
||||||
[
|
(builtins.placeholder "out")
|
||||||
"--architecture"
|
];
|
||||||
architecture.m2libc
|
};
|
||||||
(if config.aux.platform.endian == "little" then "--little-endian" else "--big-endian")
|
in [
|
||||||
"--base-address"
|
"--architecture"
|
||||||
(
|
architecture.m2libc
|
||||||
if config.aux.system == "x86_64-linux" then
|
(
|
||||||
"0x00600000"
|
if config.aux.platform.endian == "little"
|
||||||
else if config.aux.system == "aarch64-linux" then
|
then "--little-endian"
|
||||||
"0x00600000"
|
else "--big-endian"
|
||||||
else if config.aux.system == "i686-linux" then
|
)
|
||||||
"0x08048000"
|
"--base-address"
|
||||||
else
|
(
|
||||||
builtins.throw "Unsupported system: ${config.aux.system}"
|
if config.aux.system == "x86_64-linux"
|
||||||
)
|
then "0x00600000"
|
||||||
"-f"
|
else if config.aux.system == "aarch64-linux"
|
||||||
"${sources.m2libc}/${architecture.m2libc}/ELF-${architecture.m2libc}-debug.hex2"
|
then "0x00600000"
|
||||||
"-f"
|
else if config.aux.system == "i686-linux"
|
||||||
hex2_linker_hex2
|
then "0x08048000"
|
||||||
"-o"
|
else builtins.throw "Unsupported system: ${config.aux.system}"
|
||||||
(builtins.placeholder "out")
|
)
|
||||||
];
|
"-f"
|
||||||
|
"${sources.m2libc}/${architecture.m2libc}/ELF-${architecture.m2libc}-debug.hex2"
|
||||||
|
"-f"
|
||||||
|
hex2_linker_hex2
|
||||||
|
"-o"
|
||||||
|
(builtins.placeholder "out")
|
||||||
|
];
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
{ lib, config }:
|
{
|
||||||
let
|
lib,
|
||||||
|
config,
|
||||||
|
}: let
|
||||||
cfg = config.aux.foundation.stages.stage0.kaem-unwrapped;
|
cfg = config.aux.foundation.stages.stage0.kaem-unwrapped;
|
||||||
hex0 = config.aux.foundation.stages.stage0.hex0;
|
hex0 = config.aux.foundation.stages.stage0.hex0;
|
||||||
catm = config.aux.foundation.stages.stage0.catm;
|
catm = config.aux.foundation.stages.stage0.catm;
|
||||||
|
@ -14,8 +16,7 @@ let
|
||||||
builders = config.aux.foundation.builders;
|
builders = config.aux.foundation.builders;
|
||||||
sources = config.aux.foundation.stages.stage0.sources;
|
sources = config.aux.foundation.stages.stage0.sources;
|
||||||
architecture = config.aux.foundation.stages.stage0.architecture;
|
architecture = config.aux.foundation.stages.stage0.architecture;
|
||||||
in
|
in {
|
||||||
{
|
|
||||||
options.aux.foundation.stages.stage0.kaem-unwrapped = {
|
options.aux.foundation.stages.stage0.kaem-unwrapped = {
|
||||||
meta = {
|
meta = {
|
||||||
description = lib.options.create {
|
description = lib.options.create {
|
||||||
|
@ -40,7 +41,10 @@ in
|
||||||
platforms = lib.options.create {
|
platforms = lib.options.create {
|
||||||
type = lib.types.list.of lib.types.string;
|
type = lib.types.list.of lib.types.string;
|
||||||
description = "Platforms the package supports.";
|
description = "Platforms the package supports.";
|
||||||
default.value = [ "i686-linux" ];
|
default.value = [
|
||||||
|
"x86_64-linux"
|
||||||
|
"i686-linux"
|
||||||
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -61,117 +65,128 @@ in
|
||||||
|
|
||||||
executable = hex2.package;
|
executable = hex2.package;
|
||||||
|
|
||||||
args =
|
args = let
|
||||||
let
|
kaem_M1 = builders.raw.build {
|
||||||
kaem_M1 = builders.raw.build {
|
pname = "kaem_M1";
|
||||||
pname = "kaem_M1";
|
version = "1.6.0";
|
||||||
version = "1.6.0";
|
|
||||||
|
|
||||||
meta = cfg.meta;
|
meta = cfg.meta;
|
||||||
|
|
||||||
executable = M2.package;
|
executable = M2.package;
|
||||||
|
|
||||||
args = [
|
args = [
|
||||||
"--architecture"
|
"--architecture"
|
||||||
architecture.m2libc
|
architecture.m2libc
|
||||||
"-f"
|
"-f"
|
||||||
"${sources.m2libc}/sys/types.h"
|
"${sources.m2libc}/sys/types.h"
|
||||||
"-f"
|
"-f"
|
||||||
"${sources.m2libc}/stddef.h"
|
"${sources.m2libc}/stddef.h"
|
||||||
"-f"
|
"-f"
|
||||||
"${sources.m2libc}/${architecture.m2libc}/linux/unistd.c"
|
"${sources.m2libc}/${architecture.m2libc}/linux/unistd.c"
|
||||||
"-f"
|
"-f"
|
||||||
"${sources.m2libc}/${architecture.m2libc}/linux/fcntl.c"
|
"${sources.m2libc}/${architecture.m2libc}/linux/fcntl.c"
|
||||||
"-f"
|
"-f"
|
||||||
"${sources.m2libc}/fcntl.c"
|
"${sources.m2libc}/fcntl.c"
|
||||||
"-f"
|
"-f"
|
||||||
"${sources.m2libc}/${architecture.m2libc}/linux/sys/stat.c"
|
"${sources.m2libc}/${architecture.m2libc}/linux/sys/stat.c"
|
||||||
"-f"
|
"-f"
|
||||||
"${sources.m2libc}/string.c"
|
"${sources.m2libc}/string.c"
|
||||||
"-f"
|
"-f"
|
||||||
"${sources.m2libc}/stdlib.c"
|
"${sources.m2libc}/stdlib.c"
|
||||||
"-f"
|
"-f"
|
||||||
"${sources.m2libc}/stdio.h"
|
"${sources.m2libc}/stdio.h"
|
||||||
"-f"
|
"-f"
|
||||||
"${sources.m2libc}/stdio.c"
|
"${sources.m2libc}/stdio.c"
|
||||||
"-f"
|
"-f"
|
||||||
"${sources.m2libc}/bootstrappable.c"
|
"${sources.m2libc}/bootstrappable.c"
|
||||||
"-f"
|
"-f"
|
||||||
"${sources.mescc-tools}/Kaem/kaem.h"
|
"${sources.mescc-tools}/Kaem/kaem.h"
|
||||||
"-f"
|
"-f"
|
||||||
"${sources.mescc-tools}/Kaem/variable.c"
|
"${sources.mescc-tools}/Kaem/variable.c"
|
||||||
"-f"
|
"-f"
|
||||||
"${sources.mescc-tools}/Kaem/kaem_globals.c"
|
"${sources.mescc-tools}/Kaem/kaem_globals.c"
|
||||||
"-f"
|
"-f"
|
||||||
"${sources.mescc-tools}/Kaem/kaem.c"
|
"${sources.mescc-tools}/Kaem/kaem.c"
|
||||||
"--debug"
|
"--debug"
|
||||||
"-o"
|
"-o"
|
||||||
(builtins.placeholder "out")
|
(builtins.placeholder "out")
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
kaem-footer_M1 = builders.raw.build {
|
kaem-footer_M1 = builders.raw.build {
|
||||||
pname = "kaem-footer_M1";
|
pname = "kaem-footer_M1";
|
||||||
version = "1.6.0";
|
version = "1.6.0";
|
||||||
|
|
||||||
meta = cfg.meta;
|
meta = cfg.meta;
|
||||||
|
|
||||||
executable = blood-elf.package;
|
executable = blood-elf.package;
|
||||||
|
|
||||||
args = (lib.lists.when (config.aux.platform.bits == 64) "--64") ++ [
|
args =
|
||||||
|
(lib.lists.when (config.aux.platform.bits == 64) "--64")
|
||||||
|
++ [
|
||||||
"-f"
|
"-f"
|
||||||
kaem_M1
|
kaem_M1
|
||||||
(if config.aux.platform.endian == "little" then "--little-endian" else "--big-endian")
|
(
|
||||||
|
if config.aux.platform.endian == "little"
|
||||||
|
then "--little-endian"
|
||||||
|
else "--big-endian"
|
||||||
|
)
|
||||||
"-o"
|
"-o"
|
||||||
(builtins.placeholder "out")
|
(builtins.placeholder "out")
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
kaem_hex2 = builders.raw.build {
|
kaem_hex2 = builders.raw.build {
|
||||||
pname = "kaem_hex2";
|
pname = "kaem_hex2";
|
||||||
version = "1.6.0";
|
version = "1.6.0";
|
||||||
|
|
||||||
meta = cfg.meta;
|
meta = cfg.meta;
|
||||||
|
|
||||||
executable = M1.package;
|
executable = M1.package;
|
||||||
|
|
||||||
args = [
|
args = [
|
||||||
"--architecture"
|
"--architecture"
|
||||||
architecture.m2libc
|
architecture.m2libc
|
||||||
(if config.aux.platform.endian == "little" then "--little-endian" else "--big-endian")
|
(
|
||||||
"-f"
|
if config.aux.platform.endian == "little"
|
||||||
"${sources.m2libc}/${architecture.m2libc}/${architecture.m2libc}_defs.M1"
|
then "--little-endian"
|
||||||
"-f"
|
else "--big-endian"
|
||||||
"${sources.m2libc}/${architecture.m2libc}/libc-full.M1"
|
)
|
||||||
"-f"
|
"-f"
|
||||||
kaem_M1
|
"${sources.m2libc}/${architecture.m2libc}/${architecture.m2libc}_defs.M1"
|
||||||
"-f"
|
"-f"
|
||||||
kaem-footer_M1
|
"${sources.m2libc}/${architecture.m2libc}/libc-full.M1"
|
||||||
"-o"
|
"-f"
|
||||||
(builtins.placeholder "out")
|
kaem_M1
|
||||||
];
|
"-f"
|
||||||
};
|
kaem-footer_M1
|
||||||
in
|
"-o"
|
||||||
[
|
(builtins.placeholder "out")
|
||||||
"--architecture"
|
];
|
||||||
architecture.m2libc
|
};
|
||||||
(if config.aux.platform.endian == "little" then "--little-endian" else "--big-endian")
|
in [
|
||||||
"--base-address"
|
"--architecture"
|
||||||
(
|
architecture.m2libc
|
||||||
if config.aux.system == "x86_64-linux" then
|
(
|
||||||
"0x00600000"
|
if config.aux.platform.endian == "little"
|
||||||
else if config.aux.system == "aarch64-linux" then
|
then "--little-endian"
|
||||||
"0x00600000"
|
else "--big-endian"
|
||||||
else if config.aux.system == "i686-linux" then
|
)
|
||||||
"0x08048000"
|
"--base-address"
|
||||||
else
|
(
|
||||||
builtins.throw "Unsupported system: ${config.aux.system}"
|
if config.aux.system == "x86_64-linux"
|
||||||
)
|
then "0x00600000"
|
||||||
"-f"
|
else if config.aux.system == "aarch64-linux"
|
||||||
"${sources.m2libc}/${architecture.m2libc}/ELF-${architecture.m2libc}-debug.hex2"
|
then "0x00600000"
|
||||||
"-f"
|
else if config.aux.system == "i686-linux"
|
||||||
kaem_hex2
|
then "0x08048000"
|
||||||
"-o"
|
else builtins.throw "Unsupported system: ${config.aux.system}"
|
||||||
(builtins.placeholder "out")
|
)
|
||||||
];
|
"-f"
|
||||||
|
"${sources.m2libc}/${architecture.m2libc}/ELF-${architecture.m2libc}-debug.hex2"
|
||||||
|
"-f"
|
||||||
|
kaem_hex2
|
||||||
|
"-o"
|
||||||
|
(builtins.placeholder "out")
|
||||||
|
];
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
{ lib, config }:
|
{
|
||||||
let
|
lib,
|
||||||
|
config,
|
||||||
|
}: let
|
||||||
system = config.aux.system;
|
system = config.aux.system;
|
||||||
|
|
||||||
architecture = config.aux.foundation.stages.stage0.architecture.base;
|
architecture = config.aux.foundation.stages.stage0.architecture.base;
|
||||||
in
|
in {
|
||||||
{
|
|
||||||
options.aux.foundation.stages.stage0.sources = {
|
options.aux.foundation.stages.stage0.sources = {
|
||||||
base = lib.options.create {
|
base = lib.options.create {
|
||||||
type = lib.types.string;
|
type = lib.types.string;
|
||||||
|
@ -43,25 +44,27 @@ in
|
||||||
# fetching that, we are instead fetching each submodule directly. The central repository is located
|
# fetching that, we are instead fetching each submodule directly. The central repository is located
|
||||||
# here: https://github.com/oriansj/stage0-posix
|
# here: https://github.com/oriansj/stage0-posix
|
||||||
base =
|
base =
|
||||||
if architecture == "AMD64" then
|
if architecture == "AMD64"
|
||||||
|
then
|
||||||
builtins.fetchTarball {
|
builtins.fetchTarball {
|
||||||
url = "https://github.com/oriansj/stage0-posix-amd64/archive/93fbe4c08772d8df1412e2554668e24cf604088c.tar.gz";
|
url = "https://github.com/oriansj/stage0-posix-amd64/archive/93fbe4c08772d8df1412e2554668e24cf604088c.tar.gz";
|
||||||
sha256 = "10d1xnjzqplpfip3pm89bydd501x1bcgkg7lkkadyq5bqpad5flp";
|
sha256 = "10d1xnjzqplpfip3pm89bydd501x1bcgkg7lkkadyq5bqpad5flp";
|
||||||
}
|
}
|
||||||
else if architecture == "AArch64" then
|
else if architecture == "AArch64"
|
||||||
|
then
|
||||||
# FIXME: We may need to patch the aarch64 variant.
|
# FIXME: We may need to patch the aarch64 variant.
|
||||||
# https://github.com/oriansj/M2libc/pull/17
|
# https://github.com/oriansj/M2libc/pull/17
|
||||||
builtins.fetchTarball {
|
builtins.fetchTarball {
|
||||||
url = "https://github.com/oriansj/stage0-posix-aarch64/archive/39a43f803d572b53f95d42507202152eeda18361.tar.gz";
|
url = "https://github.com/oriansj/stage0-posix-aarch64/archive/39a43f803d572b53f95d42507202152eeda18361.tar.gz";
|
||||||
sha256 = "1x607hr3n5j89394d156r23igpx8hifjd14ygksx7902rlwrrry2";
|
sha256 = "1x607hr3n5j89394d156r23igpx8hifjd14ygksx7902rlwrrry2";
|
||||||
}
|
}
|
||||||
else if architecture == "x86" then
|
else if architecture == "x86"
|
||||||
|
then
|
||||||
builtins.fetchTarball {
|
builtins.fetchTarball {
|
||||||
url = "https://github.com/oriansj/stage0-posix-x86/archive/e86bf7d304bae5ce5ccc88454bb60cf0837e941f.tar.gz";
|
url = "https://github.com/oriansj/stage0-posix-x86/archive/e86bf7d304bae5ce5ccc88454bb60cf0837e941f.tar.gz";
|
||||||
sha256 = "1c1fk793yzq8zbg60n2zd22fsmirc3zr26fj0iskap456g84nxv8";
|
sha256 = "1c1fk793yzq8zbg60n2zd22fsmirc3zr26fj0iskap456g84nxv8";
|
||||||
}
|
}
|
||||||
else
|
else builtins.throw "Unsupported architecture for stage0: ${architecture}";
|
||||||
builtins.throw "Unsupported architecture for stage0: ${architecture}";
|
|
||||||
|
|
||||||
m2libc = builtins.fetchTarball {
|
m2libc = builtins.fetchTarball {
|
||||||
url = "https://github.com/oriansj/M2libc/archive/de7c75f144176c3b9be77695d9bf94440445aeae.tar.gz";
|
url = "https://github.com/oriansj/M2libc/archive/de7c75f144176c3b9be77695d9bf94440445aeae.tar.gz";
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
{ lib, config }:
|
{
|
||||||
let
|
lib,
|
||||||
|
config,
|
||||||
|
}: let
|
||||||
cfg = config.aux.foundation.stages.stage1.bash.boot;
|
cfg = config.aux.foundation.stages.stage1.bash.boot;
|
||||||
|
|
||||||
builders = config.aux.foundation.builders;
|
builders = config.aux.foundation.builders;
|
||||||
|
|
||||||
stage1 = config.aux.foundation.stages.stage1;
|
stage1 = config.aux.foundation.stages.stage1;
|
||||||
in
|
in {
|
||||||
{
|
|
||||||
options.aux.foundation.stages.stage1.bash.boot = {
|
options.aux.foundation.stages.stage1.bash.boot = {
|
||||||
meta = {
|
meta = {
|
||||||
description = lib.options.create {
|
description = lib.options.create {
|
||||||
|
@ -31,7 +32,10 @@ in
|
||||||
platforms = lib.options.create {
|
platforms = lib.options.create {
|
||||||
type = lib.types.list.of lib.types.string;
|
type = lib.types.list.of lib.types.string;
|
||||||
description = "Platforms the package supports.";
|
description = "Platforms the package supports.";
|
||||||
default.value = [ "i686-linux" ];
|
default.value = [
|
||||||
|
"i686-linux"
|
||||||
|
"x86_64-linux"
|
||||||
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -60,56 +64,55 @@ in
|
||||||
sha256 = "1r1z2qdw3rz668nxrzwa14vk2zcn00hw7mpjn384picck49d80xs";
|
sha256 = "1r1z2qdw3rz668nxrzwa14vk2zcn00hw7mpjn384picck49d80xs";
|
||||||
};
|
};
|
||||||
|
|
||||||
package =
|
package = let
|
||||||
let
|
# Thanks to the live-bootstrap project!
|
||||||
# Thanks to the live-bootstrap project!
|
# See https://github.com/fosslinux/live-bootstrap/blob/1bc4296091c51f53a5598050c8956d16e945b0f5/sysa/bash-2.05b/bash-2.05b.kaem
|
||||||
# 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";
|
||||||
liveBootstrap = "https://github.com/fosslinux/live-bootstrap/raw/1bc4296091c51f53a5598050c8956d16e945b0f5/sysa/bash-2.05b";
|
|
||||||
|
|
||||||
main_mk = builtins.fetchurl {
|
main_mk = builtins.fetchurl {
|
||||||
url = "${liveBootstrap}/mk/main.mk";
|
url = "${liveBootstrap}/mk/main.mk";
|
||||||
sha256 = "0hj29q3pq3370p18sxkpvv9flb7yvx2fs96xxlxqlwa8lkimd0j4";
|
sha256 = "0hj29q3pq3370p18sxkpvv9flb7yvx2fs96xxlxqlwa8lkimd0j4";
|
||||||
};
|
};
|
||||||
|
|
||||||
common_mk = builtins.fetchurl {
|
common_mk = builtins.fetchurl {
|
||||||
url = "${liveBootstrap}/mk/common.mk";
|
url = "${liveBootstrap}/mk/common.mk";
|
||||||
sha256 = "09rigxxf85p2ybnq248sai1gdx95yykc8jmwi4yjx389zh09mcr8";
|
sha256 = "09rigxxf85p2ybnq248sai1gdx95yykc8jmwi4yjx389zh09mcr8";
|
||||||
};
|
};
|
||||||
|
|
||||||
builtins_mk = builtins.fetchurl {
|
builtins_mk = builtins.fetchurl {
|
||||||
url = "${liveBootstrap}/mk/builtins.mk";
|
url = "${liveBootstrap}/mk/builtins.mk";
|
||||||
sha256 = "0939dy5by1xhfmsjj6w63nlgk509fjrhpb2crics3dpcv7prl8lj";
|
sha256 = "0939dy5by1xhfmsjj6w63nlgk509fjrhpb2crics3dpcv7prl8lj";
|
||||||
};
|
};
|
||||||
|
|
||||||
patches = [
|
patches = [
|
||||||
# mes libc does not have locale support
|
# mes libc does not have locale support
|
||||||
(builtins.fetchurl {
|
(builtins.fetchurl {
|
||||||
url = "${liveBootstrap}/patches/mes-libc.patch";
|
url = "${liveBootstrap}/patches/mes-libc.patch";
|
||||||
sha256 = "0zksdjf6zbb3p4hqg6plq631y76hhhgab7kdvf7cnpk8bcykn12z";
|
sha256 = "0zksdjf6zbb3p4hqg6plq631y76hhhgab7kdvf7cnpk8bcykn12z";
|
||||||
})
|
})
|
||||||
# int name, namelen; is wrong for mes libc, it is char* name, so we modify tinycc
|
# int name, namelen; is wrong for mes libc, it is char* name, so we modify tinycc
|
||||||
# to reflect this.
|
# to reflect this.
|
||||||
(builtins.fetchurl {
|
(builtins.fetchurl {
|
||||||
url = "${liveBootstrap}/patches/tinycc.patch";
|
url = "${liveBootstrap}/patches/tinycc.patch";
|
||||||
sha256 = "042d2kr4a8klazk1hlvphxr6frn4mr53k957aq3apf6lbvrjgcj2";
|
sha256 = "042d2kr4a8klazk1hlvphxr6frn4mr53k957aq3apf6lbvrjgcj2";
|
||||||
})
|
})
|
||||||
# add ifdef's for features we don't want
|
# add ifdef's for features we don't want
|
||||||
(builtins.fetchurl {
|
(builtins.fetchurl {
|
||||||
url = "${liveBootstrap}/patches/missing-defines.patch";
|
url = "${liveBootstrap}/patches/missing-defines.patch";
|
||||||
sha256 = "1q0k1kj5mrvjkqqly7ki5575a5b3hy1ywnmvhrln318yh67qnkj4";
|
sha256 = "1q0k1kj5mrvjkqqly7ki5575a5b3hy1ywnmvhrln318yh67qnkj4";
|
||||||
})
|
})
|
||||||
# mes libc + setting locale = not worky
|
# mes libc + setting locale = not worky
|
||||||
(builtins.fetchurl {
|
(builtins.fetchurl {
|
||||||
url = "${liveBootstrap}/patches/locale.patch";
|
url = "${liveBootstrap}/patches/locale.patch";
|
||||||
sha256 = "1p1q1slhafsgj8x4k0dpn9h6ryq5fwfx7dicbbxhldbw7zvnnbx9";
|
sha256 = "1p1q1slhafsgj8x4k0dpn9h6ryq5fwfx7dicbbxhldbw7zvnnbx9";
|
||||||
})
|
})
|
||||||
# We do not have /dev at this stage of the bootstrap, including /dev/tty
|
# We do not have /dev at this stage of the bootstrap, including /dev/tty
|
||||||
(builtins.fetchurl {
|
(builtins.fetchurl {
|
||||||
url = "${liveBootstrap}/patches/dev-tty.patch";
|
url = "${liveBootstrap}/patches/dev-tty.patch";
|
||||||
sha256 = "1315slv5f7ziajqyxg4jlyanf1xwd06xw14y6pq7xpm3jzjk55j9";
|
sha256 = "1315slv5f7ziajqyxg4jlyanf1xwd06xw14y6pq7xpm3jzjk55j9";
|
||||||
})
|
})
|
||||||
];
|
];
|
||||||
in
|
in
|
||||||
builders.kaem.build {
|
builders.kaem.build {
|
||||||
name = "bash-${cfg.version}";
|
name = "bash-${cfg.version}";
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,10 @@ in
|
||||||
platforms = lib.options.create {
|
platforms = lib.options.create {
|
||||||
type = lib.types.list.of lib.types.string;
|
type = lib.types.list.of lib.types.string;
|
||||||
description = "Platforms the package supports.";
|
description = "Platforms the package supports.";
|
||||||
default.value = [ "i686-linux" ];
|
default.value = [
|
||||||
|
"i686-linux"
|
||||||
|
"x86_64-linux"
|
||||||
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
mainProgram = lib.options.create {
|
mainProgram = lib.options.create {
|
||||||
|
|
|
@ -32,7 +32,10 @@ in
|
||||||
platforms = lib.options.create {
|
platforms = lib.options.create {
|
||||||
type = lib.types.list.of lib.types.string;
|
type = lib.types.list.of lib.types.string;
|
||||||
description = "Platforms the package supports.";
|
description = "Platforms the package supports.";
|
||||||
default.value = [ "i686-linux" ];
|
default.value = [
|
||||||
|
"i686-linux"
|
||||||
|
"x86_64-linux"
|
||||||
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,10 @@ in
|
||||||
platforms = lib.options.create {
|
platforms = lib.options.create {
|
||||||
type = lib.types.list.of lib.types.string;
|
type = lib.types.list.of lib.types.string;
|
||||||
description = "Platforms the package supports.";
|
description = "Platforms the package supports.";
|
||||||
default.value = [ "i686-linux" ];
|
default.value = [
|
||||||
|
"i686-linux"
|
||||||
|
"x86_64-linux"
|
||||||
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,14 @@
|
||||||
{ lib, config }:
|
{
|
||||||
let
|
lib,
|
||||||
|
config,
|
||||||
|
}: let
|
||||||
cfg = config.aux.foundation.stages.stage1.bzip2;
|
cfg = config.aux.foundation.stages.stage1.bzip2;
|
||||||
|
|
||||||
platform = config.aux.platform;
|
platform = config.aux.platform;
|
||||||
builders = config.aux.foundation.builders;
|
builders = config.aux.foundation.builders;
|
||||||
|
|
||||||
stage1 = config.aux.foundation.stages.stage1;
|
stage1 = config.aux.foundation.stages.stage1;
|
||||||
in
|
in {
|
||||||
{
|
|
||||||
options.aux.foundation.stages.stage1.bzip2 = {
|
options.aux.foundation.stages.stage1.bzip2 = {
|
||||||
meta = {
|
meta = {
|
||||||
description = lib.options.create {
|
description = lib.options.create {
|
||||||
|
@ -33,7 +34,10 @@ in
|
||||||
type = lib.types.list.of lib.types.string;
|
type = lib.types.list.of lib.types.string;
|
||||||
description = "Platforms the package supports.";
|
description = "Platforms the package supports.";
|
||||||
# TODO: Support more platforms.
|
# TODO: Support more platforms.
|
||||||
default.value = [ "i686-linux" ];
|
default.value = [
|
||||||
|
"i686-linux"
|
||||||
|
"x86_64-linux"
|
||||||
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
{ lib, config }:
|
{
|
||||||
let
|
lib,
|
||||||
|
config,
|
||||||
|
}: let
|
||||||
cfg = config.aux.foundation.stages.stage1.coreutils.boot;
|
cfg = config.aux.foundation.stages.stage1.coreutils.boot;
|
||||||
|
|
||||||
builders = config.aux.foundation.builders;
|
builders = config.aux.foundation.builders;
|
||||||
|
|
||||||
stage1 = config.aux.foundation.stages.stage1;
|
stage1 = config.aux.foundation.stages.stage1;
|
||||||
in
|
in {
|
||||||
{
|
|
||||||
options.aux.foundation.stages.stage1.coreutils.boot = {
|
options.aux.foundation.stages.stage1.coreutils.boot = {
|
||||||
package = lib.options.create {
|
package = lib.options.create {
|
||||||
type = lib.types.derivation;
|
type = lib.types.derivation;
|
||||||
|
@ -33,64 +34,63 @@ in
|
||||||
sha256 = "10wq6k66i8adr4k08p0xmg87ff4ypiazvwzlmi7myib27xgffz62";
|
sha256 = "10wq6k66i8adr4k08p0xmg87ff4ypiazvwzlmi7myib27xgffz62";
|
||||||
};
|
};
|
||||||
|
|
||||||
package =
|
package = let
|
||||||
let
|
# Thanks to the live-bootstrap project!
|
||||||
# Thanks to the live-bootstrap project!
|
# See https://github.com/fosslinux/live-bootstrap/blob/a8752029f60217a5c41c548b16f5cdd2a1a0e0db/sysa/coreutils-5.0/coreutils-5.0.kaem
|
||||||
# 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";
|
||||||
liveBootstrap = "https://github.com/fosslinux/live-bootstrap/raw/a8752029f60217a5c41c548b16f5cdd2a1a0e0db/sysa/coreutils-5.0";
|
|
||||||
|
|
||||||
makefile = builtins.fetchurl {
|
makefile = builtins.fetchurl {
|
||||||
url = "${liveBootstrap}/mk/main.mk";
|
url = "${liveBootstrap}/mk/main.mk";
|
||||||
sha256 = "0njg4xccxfqrslrmlb8ls7h6hlnfmdx42nvxwmca8flvczwrplfd";
|
sha256 = "0njg4xccxfqrslrmlb8ls7h6hlnfmdx42nvxwmca8flvczwrplfd";
|
||||||
};
|
};
|
||||||
|
|
||||||
patches = [
|
patches = [
|
||||||
# modechange.h uses functions defined in sys/stat.h, so we need to move it to
|
# modechange.h uses functions defined in sys/stat.h, so we need to move it to
|
||||||
# after sys/stat.h include.
|
# after sys/stat.h include.
|
||||||
(builtins.fetchurl {
|
(builtins.fetchurl {
|
||||||
url = "${liveBootstrap}/patches/modechange.patch";
|
url = "${liveBootstrap}/patches/modechange.patch";
|
||||||
sha256 = "04xa4a5w2syjs3xs6qhh8kdzqavxnrxpxwyhc3qqykpk699p3ms5";
|
sha256 = "04xa4a5w2syjs3xs6qhh8kdzqavxnrxpxwyhc3qqykpk699p3ms5";
|
||||||
})
|
})
|
||||||
# mbstate_t is a struct that is required. However, it is not defined by mes libc.
|
# mbstate_t is a struct that is required. However, it is not defined by mes libc.
|
||||||
(builtins.fetchurl {
|
(builtins.fetchurl {
|
||||||
url = "${liveBootstrap}/patches/mbstate.patch";
|
url = "${liveBootstrap}/patches/mbstate.patch";
|
||||||
sha256 = "0rz3c0sflgxjv445xs87b83i7gmjpl2l78jzp6nm3khdbpcc53vy";
|
sha256 = "0rz3c0sflgxjv445xs87b83i7gmjpl2l78jzp6nm3khdbpcc53vy";
|
||||||
})
|
})
|
||||||
# strcoll() does not exist in mes libc, change it to strcmp.
|
# strcoll() does not exist in mes libc, change it to strcmp.
|
||||||
(builtins.fetchurl {
|
(builtins.fetchurl {
|
||||||
url = "${liveBootstrap}/patches/ls-strcmp.patch";
|
url = "${liveBootstrap}/patches/ls-strcmp.patch";
|
||||||
sha256 = "0lx8rz4sxq3bvncbbr6jf0kyn5bqwlfv9gxyafp0541dld6l55p6";
|
sha256 = "0lx8rz4sxq3bvncbbr6jf0kyn5bqwlfv9gxyafp0541dld6l55p6";
|
||||||
})
|
})
|
||||||
# getdate.c is pre-compiled from getdate.y
|
# getdate.c is pre-compiled from getdate.y
|
||||||
# At this point we don't have bison yet and in any case getdate.y does not
|
# At this point we don't have bison yet and in any case getdate.y does not
|
||||||
# compile when generated with modern bison.
|
# compile when generated with modern bison.
|
||||||
(builtins.fetchurl {
|
(builtins.fetchurl {
|
||||||
url = "${liveBootstrap}/patches/touch-getdate.patch";
|
url = "${liveBootstrap}/patches/touch-getdate.patch";
|
||||||
sha256 = "1xd3z57lvkj7r8vs5n0hb9cxzlyp58pji7d335snajbxzwy144ma";
|
sha256 = "1xd3z57lvkj7r8vs5n0hb9cxzlyp58pji7d335snajbxzwy144ma";
|
||||||
})
|
})
|
||||||
# touch: add -h to change symlink timestamps, where supported
|
# touch: add -h to change symlink timestamps, where supported
|
||||||
(builtins.fetchurl {
|
(builtins.fetchurl {
|
||||||
url = "${liveBootstrap}/patches/touch-dereference.patch";
|
url = "${liveBootstrap}/patches/touch-dereference.patch";
|
||||||
sha256 = "0wky5r3k028xwyf6g6ycwqxzc7cscgmbymncjg948vv4qxsxlfda";
|
sha256 = "0wky5r3k028xwyf6g6ycwqxzc7cscgmbymncjg948vv4qxsxlfda";
|
||||||
})
|
})
|
||||||
# strcoll() does not exist in mes libc, change it to strcmp.
|
# strcoll() does not exist in mes libc, change it to strcmp.
|
||||||
(builtins.fetchurl {
|
(builtins.fetchurl {
|
||||||
url = "${liveBootstrap}/patches/expr-strcmp.patch";
|
url = "${liveBootstrap}/patches/expr-strcmp.patch";
|
||||||
sha256 = "19f31lfsm1iwqzvp2fyv97lmqg4730prfygz9zip58651jf739a9";
|
sha256 = "19f31lfsm1iwqzvp2fyv97lmqg4730prfygz9zip58651jf739a9";
|
||||||
})
|
})
|
||||||
# strcoll() does not exist in mes libc, change it to strcmp.
|
# strcoll() does not exist in mes libc, change it to strcmp.
|
||||||
# hard_LC_COLLATE is used but not declared when HAVE_SETLOCALE is unset.
|
# hard_LC_COLLATE is used but not declared when HAVE_SETLOCALE is unset.
|
||||||
(builtins.fetchurl {
|
(builtins.fetchurl {
|
||||||
url = "${liveBootstrap}/patches/sort-locale.patch";
|
url = "${liveBootstrap}/patches/sort-locale.patch";
|
||||||
sha256 = "0bdch18mpyyxyl6gyqfs0wb4pap9flr11izqdyxccx1hhz0a2i6c";
|
sha256 = "0bdch18mpyyxyl6gyqfs0wb4pap9flr11izqdyxccx1hhz0a2i6c";
|
||||||
})
|
})
|
||||||
# don't assume fopen cannot return stdin or stdout.
|
# don't assume fopen cannot return stdin or stdout.
|
||||||
(builtins.fetchurl {
|
(builtins.fetchurl {
|
||||||
url = "${liveBootstrap}/patches/uniq-fopen.patch";
|
url = "${liveBootstrap}/patches/uniq-fopen.patch";
|
||||||
sha256 = "0qs6shyxl9j4h34v5j5sgpxrr4gjfljd2hxzw416ghwc3xzv63fp";
|
sha256 = "0qs6shyxl9j4h34v5j5sgpxrr4gjfljd2hxzw416ghwc3xzv63fp";
|
||||||
})
|
})
|
||||||
];
|
];
|
||||||
in
|
in
|
||||||
builders.kaem.build {
|
builders.kaem.build {
|
||||||
name = "coreutils-boot-${cfg.version}";
|
name = "coreutils-boot-${cfg.version}";
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,10 @@ in
|
||||||
platforms = lib.options.create {
|
platforms = lib.options.create {
|
||||||
type = lib.types.list.of lib.types.string;
|
type = lib.types.list.of lib.types.string;
|
||||||
description = "Platforms the package supports.";
|
description = "Platforms the package supports.";
|
||||||
default.value = [ "i686-linux" ];
|
default.value = [
|
||||||
|
"i686-linux"
|
||||||
|
"x86_64-linux"
|
||||||
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
{ lib, config }:
|
{
|
||||||
let
|
lib,
|
||||||
|
config,
|
||||||
|
}: let
|
||||||
cfg = config.aux.foundation.stages.stage1;
|
cfg = config.aux.foundation.stages.stage1;
|
||||||
|
|
||||||
stage1 = config.aux.foundation.stages.stage1;
|
stage1 = config.aux.foundation.stages.stage1;
|
||||||
in
|
in {
|
||||||
{
|
|
||||||
includes = [
|
includes = [
|
||||||
./nyacc
|
./nyacc
|
||||||
./mes
|
./mes
|
||||||
|
|
|
@ -32,7 +32,10 @@ in
|
||||||
platforms = lib.options.create {
|
platforms = lib.options.create {
|
||||||
type = lib.types.list.of lib.types.string;
|
type = lib.types.list.of lib.types.string;
|
||||||
description = "Platforms the package supports.";
|
description = "Platforms the package supports.";
|
||||||
default.value = [ "i686-linux" ];
|
default.value = [
|
||||||
|
"i686-linux"
|
||||||
|
"x86_64-linux"
|
||||||
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,10 @@ in
|
||||||
platforms = lib.options.create {
|
platforms = lib.options.create {
|
||||||
type = lib.types.list.of lib.types.string;
|
type = lib.types.list.of lib.types.string;
|
||||||
description = "Platforms the package supports.";
|
description = "Platforms the package supports.";
|
||||||
default.value = [ "i686-linux" ];
|
default.value = [
|
||||||
|
"i686-linux"
|
||||||
|
"x86_64-linux"
|
||||||
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,10 @@ in
|
||||||
platforms = lib.options.create {
|
platforms = lib.options.create {
|
||||||
type = lib.types.list.of lib.types.string;
|
type = lib.types.list.of lib.types.string;
|
||||||
description = "Platforms the package supports.";
|
description = "Platforms the package supports.";
|
||||||
default.value = [ "i686-linux" ];
|
default.value = [
|
||||||
|
"i686-linux"
|
||||||
|
"x86_64-linux"
|
||||||
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
mainProgram = lib.options.create {
|
mainProgram = lib.options.create {
|
||||||
|
|
|
@ -38,7 +38,10 @@ in
|
||||||
platforms = lib.options.create {
|
platforms = lib.options.create {
|
||||||
type = lib.types.list.of lib.types.string;
|
type = lib.types.list.of lib.types.string;
|
||||||
description = "Platforms the package supports.";
|
description = "Platforms the package supports.";
|
||||||
default.value = [ "i686-linux" ];
|
default.value = [
|
||||||
|
"i686-linux"
|
||||||
|
"x86_64-linux"
|
||||||
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
{ lib, config }:
|
{
|
||||||
let
|
lib,
|
||||||
|
config,
|
||||||
|
}: let
|
||||||
cfg = config.aux.foundation.stages.stage1.gnugrep;
|
cfg = config.aux.foundation.stages.stage1.gnugrep;
|
||||||
|
|
||||||
builders = config.aux.foundation.builders;
|
builders = config.aux.foundation.builders;
|
||||||
|
|
||||||
stage1 = config.aux.foundation.stages.stage1;
|
stage1 = config.aux.foundation.stages.stage1;
|
||||||
in
|
in {
|
||||||
{
|
|
||||||
options.aux.foundation.stages.stage1.gnugrep = {
|
options.aux.foundation.stages.stage1.gnugrep = {
|
||||||
meta = {
|
meta = {
|
||||||
description = lib.options.create {
|
description = lib.options.create {
|
||||||
|
@ -31,7 +32,10 @@ in
|
||||||
platforms = lib.options.create {
|
platforms = lib.options.create {
|
||||||
type = lib.types.list.of lib.types.string;
|
type = lib.types.list.of lib.types.string;
|
||||||
description = "Platforms the package supports.";
|
description = "Platforms the package supports.";
|
||||||
default.value = [ "i686-linux" ];
|
default.value = [
|
||||||
|
"i686-linux"
|
||||||
|
"x86_64-linux"
|
||||||
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
mainProgram = lib.options.create {
|
mainProgram = lib.options.create {
|
||||||
|
@ -66,15 +70,14 @@ in
|
||||||
sha256 = "05iayw5sfclc476vpviz67hdy03na0pz2kb5csa50232nfx34853";
|
sha256 = "05iayw5sfclc476vpviz67hdy03na0pz2kb5csa50232nfx34853";
|
||||||
};
|
};
|
||||||
|
|
||||||
package =
|
package = let
|
||||||
let
|
# Thanks to the live-bootstrap project!
|
||||||
# Thanks to the live-bootstrap project!
|
# See https://github.com/fosslinux/live-bootstrap/blob/1bc4296091c51f53a5598050c8956d16e945b0f5/sysa/grep-2.4
|
||||||
# See https://github.com/fosslinux/live-bootstrap/blob/1bc4296091c51f53a5598050c8956d16e945b0f5/sysa/grep-2.4
|
makefile = builtins.fetchurl {
|
||||||
makefile = builtins.fetchurl {
|
url = "https://github.com/fosslinux/live-bootstrap/raw/1bc4296091c51f53a5598050c8956d16e945b0f5/sysa/grep-2.4/mk/main.mk";
|
||||||
url = "https://github.com/fosslinux/live-bootstrap/raw/1bc4296091c51f53a5598050c8956d16e945b0f5/sysa/grep-2.4/mk/main.mk";
|
sha256 = "08an9ljlqry3p15w28hahm6swnd3jxizsd2188przvvsj093j91k";
|
||||||
sha256 = "08an9ljlqry3p15w28hahm6swnd3jxizsd2188przvvsj093j91k";
|
};
|
||||||
};
|
in
|
||||||
in
|
|
||||||
builders.bash.boot.build {
|
builders.bash.boot.build {
|
||||||
name = "gnugrep-${cfg.version}";
|
name = "gnugrep-${cfg.version}";
|
||||||
meta = cfg.meta;
|
meta = cfg.meta;
|
||||||
|
|
|
@ -32,7 +32,10 @@ in
|
||||||
platforms = lib.options.create {
|
platforms = lib.options.create {
|
||||||
type = lib.types.list.of lib.types.string;
|
type = lib.types.list.of lib.types.string;
|
||||||
description = "Platforms the package supports.";
|
description = "Platforms the package supports.";
|
||||||
default.value = [ "i686-linux" ];
|
default.value = [
|
||||||
|
"i686-linux"
|
||||||
|
"x86_64-linux"
|
||||||
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
{ lib, config }:
|
{
|
||||||
let
|
lib,
|
||||||
|
config,
|
||||||
|
}: let
|
||||||
cfg = config.aux.foundation.stages.stage1.gnumake.boot;
|
cfg = config.aux.foundation.stages.stage1.gnumake.boot;
|
||||||
|
|
||||||
builders = config.aux.foundation.builders;
|
builders = config.aux.foundation.builders;
|
||||||
|
|
||||||
stage1 = config.aux.foundation.stages.stage1;
|
stage1 = config.aux.foundation.stages.stage1;
|
||||||
in
|
in {
|
||||||
{
|
|
||||||
options.aux.foundation.stages.stage1.gnumake.boot = {
|
options.aux.foundation.stages.stage1.gnumake.boot = {
|
||||||
package = lib.options.create {
|
package = lib.options.create {
|
||||||
type = lib.types.derivation;
|
type = lib.types.derivation;
|
||||||
|
@ -33,88 +34,88 @@ in
|
||||||
sha256 = "1cwgcmwdn7gqn5da2ia91gkyiqs9birr10sy5ykpkaxzcwfzn5nx";
|
sha256 = "1cwgcmwdn7gqn5da2ia91gkyiqs9birr10sy5ykpkaxzcwfzn5nx";
|
||||||
};
|
};
|
||||||
|
|
||||||
package =
|
package = let
|
||||||
let
|
patches = [
|
||||||
patches = [
|
# Replaces /bin/sh with sh, see patch file for reasoning
|
||||||
# Replaces /bin/sh with sh, see patch file for reasoning
|
./patches/0001-No-impure-bin-sh.patch
|
||||||
./patches/0001-No-impure-bin-sh.patch
|
# Purity: don't look for library dependencies (of the form `-lfoo') in /lib
|
||||||
# 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
|
||||||
# and /usr/lib. It's a stupid feature anyway. Likewise, when searching for
|
# included Makefiles, don't look in /usr/include and friends.
|
||||||
# included Makefiles, don't look in /usr/include and friends.
|
./patches/0002-remove-impure-dirs.patch
|
||||||
./patches/0002-remove-impure-dirs.patch
|
# Fixes for tinycc. See comments in patch file for reasoning
|
||||||
# Fixes for tinycc. See comments in patch file for reasoning
|
./patches/0003-tinycc-support.patch
|
||||||
./patches/0003-tinycc-support.patch
|
];
|
||||||
];
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Maintenance notes:
|
Maintenance notes:
|
||||||
|
|
||||||
Generated by
|
Generated by
|
||||||
./configure \
|
./configure \
|
||||||
--build i686-pc-linux-gnu \
|
--build i686-pc-linux-gnu \
|
||||||
--host i686-pc-linux-gnu \
|
--host i686-pc-linux-gnu \
|
||||||
CC="${tinycc.compiler}/bin/tcc -B ${tinycc.libs}/lib" \
|
CC="${tinycc.compiler}/bin/tcc -B ${tinycc.libs}/lib" \
|
||||||
ac_cv_func_dup=no
|
ac_cv_func_dup=no
|
||||||
- `ac_cv_func_dup` disabled as mes-libc doesn't implement tmpfile()
|
- `ac_cv_func_dup` disabled as mes-libc doesn't implement tmpfile()
|
||||||
|
|
||||||
The output src/config.h was then manually filtered, removing definitions that
|
The output src/config.h was then manually filtered, removing definitions that
|
||||||
didn't have uses in the source code
|
didn't have uses in the source code
|
||||||
*/
|
*/
|
||||||
config = [
|
config = [
|
||||||
"-DFILE_TIMESTAMP_HI_RES=0"
|
"-DFILE_TIMESTAMP_HI_RES=0"
|
||||||
"-DHAVE_ALLOCA"
|
"-DHAVE_ALLOCA"
|
||||||
"-DHAVE_ALLOCA_H"
|
"-DHAVE_ALLOCA_H"
|
||||||
"-DHAVE_ATEXIT"
|
"-DHAVE_ATEXIT"
|
||||||
"-DHAVE_DECL_BSD_SIGNAL=0"
|
"-DHAVE_DECL_BSD_SIGNAL=0"
|
||||||
"-DHAVE_DECL_GETLOADAVG=0"
|
"-DHAVE_DECL_GETLOADAVG=0"
|
||||||
"-DHAVE_DECL_SYS_SIGLIST=0"
|
"-DHAVE_DECL_SYS_SIGLIST=0"
|
||||||
"-DHAVE_DECL__SYS_SIGLIST=0"
|
"-DHAVE_DECL__SYS_SIGLIST=0"
|
||||||
"-DHAVE_DECL___SYS_SIGLIST=0"
|
"-DHAVE_DECL___SYS_SIGLIST=0"
|
||||||
"-DHAVE_DIRENT_H"
|
"-DHAVE_DIRENT_H"
|
||||||
"-DHAVE_DUP2"
|
"-DHAVE_DUP2"
|
||||||
"-DHAVE_FCNTL_H"
|
"-DHAVE_FCNTL_H"
|
||||||
"-DHAVE_FDOPEN"
|
"-DHAVE_FDOPEN"
|
||||||
"-DHAVE_GETCWD"
|
"-DHAVE_GETCWD"
|
||||||
"-DHAVE_GETTIMEOFDAY"
|
"-DHAVE_GETTIMEOFDAY"
|
||||||
"-DHAVE_INTTYPES_H"
|
"-DHAVE_INTTYPES_H"
|
||||||
"-DHAVE_ISATTY"
|
"-DHAVE_ISATTY"
|
||||||
"-DHAVE_LIMITS_H"
|
"-DHAVE_LIMITS_H"
|
||||||
"-DHAVE_LOCALE_H"
|
"-DHAVE_LOCALE_H"
|
||||||
"-DHAVE_MEMORY_H"
|
"-DHAVE_MEMORY_H"
|
||||||
"-DHAVE_MKTEMP"
|
"-DHAVE_MKTEMP"
|
||||||
"-DHAVE_SA_RESTART"
|
"-DHAVE_SA_RESTART"
|
||||||
"-DHAVE_SETVBUF"
|
"-DHAVE_SETVBUF"
|
||||||
"-DHAVE_SIGACTION"
|
"-DHAVE_SIGACTION"
|
||||||
"-DHAVE_SIGSETMASK"
|
"-DHAVE_SIGSETMASK"
|
||||||
"-DHAVE_STDINT_H"
|
"-DHAVE_STDINT_H"
|
||||||
"-DHAVE_STDLIB_H"
|
"-DHAVE_STDLIB_H"
|
||||||
"-DHAVE_STRDUP"
|
"-DHAVE_STRDUP"
|
||||||
"-DHAVE_STRERROR"
|
"-DHAVE_STRERROR"
|
||||||
"-DHAVE_STRINGS_H"
|
"-DHAVE_STRINGS_H"
|
||||||
"-DHAVE_STRING_H"
|
"-DHAVE_STRING_H"
|
||||||
"-DHAVE_STRTOLL"
|
"-DHAVE_STRTOLL"
|
||||||
"-DHAVE_SYS_FILE_H"
|
"-DHAVE_SYS_FILE_H"
|
||||||
"-DHAVE_SYS_PARAM_H"
|
"-DHAVE_SYS_PARAM_H"
|
||||||
"-DHAVE_SYS_RESOURCE_H"
|
"-DHAVE_SYS_RESOURCE_H"
|
||||||
"-DHAVE_SYS_SELECT_H"
|
"-DHAVE_SYS_SELECT_H"
|
||||||
"-DHAVE_SYS_STAT_H"
|
"-DHAVE_SYS_STAT_H"
|
||||||
"-DHAVE_SYS_TIMEB_H"
|
"-DHAVE_SYS_TIMEB_H"
|
||||||
"-DHAVE_SYS_TIME_H"
|
"-DHAVE_SYS_TIME_H"
|
||||||
"-DHAVE_SYS_WAIT_H"
|
"-DHAVE_SYS_WAIT_H"
|
||||||
"-DHAVE_TTYNAME"
|
"-DHAVE_TTYNAME"
|
||||||
"-DHAVE_UMASK"
|
"-DHAVE_UMASK"
|
||||||
"-DHAVE_UNISTD_H"
|
"-DHAVE_UNISTD_H"
|
||||||
"-DHAVE_WAITPID"
|
"-DHAVE_WAITPID"
|
||||||
"-DMAKE_JOBSERVER"
|
"-DMAKE_JOBSERVER"
|
||||||
"-DMAKE_SYMLINKS"
|
"-DMAKE_SYMLINKS"
|
||||||
"-DPATH_SEPARATOR_CHAR=':'"
|
"-DPATH_SEPARATOR_CHAR=':'"
|
||||||
"-DSCCS_GET=\\\"get\\\""
|
"-DSCCS_GET=\\\"get\\\""
|
||||||
"-DSTDC_HEADERS"
|
"-DSTDC_HEADERS"
|
||||||
"-Dsig_atomic_t=int"
|
"-Dsig_atomic_t=int"
|
||||||
"-Dvfork=fork"
|
"-Dvfork=fork"
|
||||||
];
|
];
|
||||||
|
|
||||||
cflags = [
|
cflags =
|
||||||
|
[
|
||||||
"-I./src"
|
"-I./src"
|
||||||
"-I./lib"
|
"-I./lib"
|
||||||
"-DHAVE_CONFIG_H"
|
"-DHAVE_CONFIG_H"
|
||||||
|
@ -126,53 +127,67 @@ in
|
||||||
"-DNO_OUTPUT_SYNC=1"
|
"-DNO_OUTPUT_SYNC=1"
|
||||||
# mes-libc doesn't define O_TMPFILE
|
# mes-libc doesn't define O_TMPFILE
|
||||||
"-DO_TMPFILE=020000000"
|
"-DO_TMPFILE=020000000"
|
||||||
] ++ config;
|
]
|
||||||
|
++ config;
|
||||||
|
|
||||||
sources = {
|
sources = {
|
||||||
# Maintenance note: list of source files derived from Basic.mk
|
# Maintenance note: list of source files derived from Basic.mk
|
||||||
make = [
|
make = [
|
||||||
"src/ar.c"
|
"src/ar.c"
|
||||||
"src/arscan.c"
|
"src/arscan.c"
|
||||||
"src/commands.c"
|
"src/commands.c"
|
||||||
"src/default.c"
|
"src/default.c"
|
||||||
"src/dir.c"
|
"src/dir.c"
|
||||||
"src/expand.c"
|
"src/expand.c"
|
||||||
"src/file.c"
|
"src/file.c"
|
||||||
"src/function.c"
|
"src/function.c"
|
||||||
"src/getopt.c"
|
"src/getopt.c"
|
||||||
"src/getopt1.c"
|
"src/getopt1.c"
|
||||||
"src/guile.c"
|
"src/guile.c"
|
||||||
"src/hash.c"
|
"src/hash.c"
|
||||||
"src/implicit.c"
|
"src/implicit.c"
|
||||||
"src/job.c"
|
"src/job.c"
|
||||||
"src/load.c"
|
"src/load.c"
|
||||||
"src/loadapi.c"
|
"src/loadapi.c"
|
||||||
"src/main.c"
|
"src/main.c"
|
||||||
"src/misc.c"
|
"src/misc.c"
|
||||||
"src/output.c"
|
"src/output.c"
|
||||||
"src/read.c"
|
"src/read.c"
|
||||||
"src/remake.c"
|
"src/remake.c"
|
||||||
"src/rule.c"
|
"src/rule.c"
|
||||||
"src/shuffle.c"
|
"src/shuffle.c"
|
||||||
"src/signame.c"
|
"src/signame.c"
|
||||||
"src/strcache.c"
|
"src/strcache.c"
|
||||||
"src/variable.c"
|
"src/variable.c"
|
||||||
"src/version.c"
|
"src/version.c"
|
||||||
"src/vpath.c"
|
"src/vpath.c"
|
||||||
];
|
];
|
||||||
glob = [
|
glob = [
|
||||||
"lib/fnmatch.c"
|
"lib/fnmatch.c"
|
||||||
"lib/glob.c"
|
"lib/glob.c"
|
||||||
];
|
];
|
||||||
remote = [ "src/remote-stub.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 (
|
objects =
|
||||||
value: builtins.replaceStrings [ ".c" ] [ ".o" ] (builtins.baseNameOf value)
|
builtins.map
|
||||||
) files;
|
(
|
||||||
in
|
value:
|
||||||
|
builtins.replaceStrings [".c"] [".o"]
|
||||||
|
(builtins.baseNameOf value)
|
||||||
|
)
|
||||||
|
files;
|
||||||
|
in
|
||||||
builders.kaem.build {
|
builders.kaem.build {
|
||||||
name = "gnumake-${cfg.version}";
|
name = "gnumake-${cfg.version}";
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,10 @@ in
|
||||||
platforms = lib.options.create {
|
platforms = lib.options.create {
|
||||||
type = lib.types.list.of lib.types.string;
|
type = lib.types.list.of lib.types.string;
|
||||||
description = "Platforms the package supports.";
|
description = "Platforms the package supports.";
|
||||||
default.value = [ "i686-linux" ];
|
default.value = [
|
||||||
|
"i686-linux"
|
||||||
|
"x86_64-linux"
|
||||||
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
{ lib, config }:
|
{
|
||||||
let
|
lib,
|
||||||
|
config,
|
||||||
|
}: let
|
||||||
cfg = config.aux.foundation.stages.stage1.gnupatch;
|
cfg = config.aux.foundation.stages.stage1.gnupatch;
|
||||||
|
|
||||||
builders = config.aux.foundation.builders;
|
builders = config.aux.foundation.builders;
|
||||||
|
|
||||||
stage1 = config.aux.foundation.stages.stage1;
|
stage1 = config.aux.foundation.stages.stage1;
|
||||||
in
|
in {
|
||||||
{
|
|
||||||
options.aux.foundation.stages.stage1.gnupatch = {
|
options.aux.foundation.stages.stage1.gnupatch = {
|
||||||
meta = {
|
meta = {
|
||||||
description = lib.options.create {
|
description = lib.options.create {
|
||||||
|
@ -31,7 +32,10 @@ in
|
||||||
platforms = lib.options.create {
|
platforms = lib.options.create {
|
||||||
type = lib.types.list.of lib.types.string;
|
type = lib.types.list.of lib.types.string;
|
||||||
description = "Platforms the package supports.";
|
description = "Platforms the package supports.";
|
||||||
default.value = [ "i686-linux" ];
|
default.value = [
|
||||||
|
"i686-linux"
|
||||||
|
"x86_64-linux"
|
||||||
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -60,72 +64,75 @@ in
|
||||||
sha256 = "12nv7jx3gxfp50y11nxzlnmqqrpicjggw6pcsq0wyavkkm3cddgc";
|
sha256 = "12nv7jx3gxfp50y11nxzlnmqqrpicjggw6pcsq0wyavkkm3cddgc";
|
||||||
};
|
};
|
||||||
|
|
||||||
package =
|
package = let
|
||||||
let
|
# Thanks to the live-bootstrap project!
|
||||||
# Thanks to the live-bootstrap project!
|
# https://github.com/fosslinux/live-bootstrap/blob/1bc4296091c51f53a5598050c8956d16e945b0f5/sysa/patch-2.5.9/mk/main.mk
|
||||||
# https://github.com/fosslinux/live-bootstrap/blob/1bc4296091c51f53a5598050c8956d16e945b0f5/sysa/patch-2.5.9/mk/main.mk
|
cflags = [
|
||||||
cflags = [
|
"-I."
|
||||||
"-I."
|
"-DHAVE_DECL_GETENV"
|
||||||
"-DHAVE_DECL_GETENV"
|
"-DHAVE_DECL_MALLOC"
|
||||||
"-DHAVE_DECL_MALLOC"
|
"-DHAVE_DIRENT_H"
|
||||||
"-DHAVE_DIRENT_H"
|
"-DHAVE_LIMITS_H"
|
||||||
"-DHAVE_LIMITS_H"
|
"-DHAVE_GETEUID"
|
||||||
"-DHAVE_GETEUID"
|
"-DHAVE_MKTEMP"
|
||||||
"-DHAVE_MKTEMP"
|
"-DPACKAGE_BUGREPORT="
|
||||||
"-DPACKAGE_BUGREPORT="
|
"-Ded_PROGRAM=\\\"/nullop\\\""
|
||||||
"-Ded_PROGRAM=\\\"/nullop\\\""
|
"-Dmbstate_t=int" # When HAVE_MBRTOWC is not enabled uses of mbstate_t are always a no-op
|
||||||
"-Dmbstate_t=int" # When HAVE_MBRTOWC is not enabled uses of mbstate_t are always a no-op
|
"-DRETSIGTYPE=int"
|
||||||
"-DRETSIGTYPE=int"
|
"-DHAVE_MKDIR"
|
||||||
"-DHAVE_MKDIR"
|
"-DHAVE_RMDIR"
|
||||||
"-DHAVE_RMDIR"
|
"-DHAVE_FCNTL_H"
|
||||||
"-DHAVE_FCNTL_H"
|
"-DPACKAGE_NAME=\\\"patch\\\""
|
||||||
"-DPACKAGE_NAME=\\\"patch\\\""
|
"-DPACKAGE_VERSION=\\\"${cfg.version}\\\""
|
||||||
"-DPACKAGE_VERSION=\\\"${cfg.version}\\\""
|
"-DHAVE_MALLOC"
|
||||||
"-DHAVE_MALLOC"
|
"-DHAVE_REALLOC"
|
||||||
"-DHAVE_REALLOC"
|
"-DSTDC_HEADERS"
|
||||||
"-DSTDC_HEADERS"
|
"-DHAVE_STRING_H"
|
||||||
"-DHAVE_STRING_H"
|
"-DHAVE_STDLIB_H"
|
||||||
"-DHAVE_STDLIB_H"
|
];
|
||||||
];
|
|
||||||
|
|
||||||
# Maintenance note: List of sources from Makefile.in
|
# Maintenance note: List of sources from Makefile.in
|
||||||
files = [
|
files = [
|
||||||
"addext.c"
|
"addext.c"
|
||||||
"argmatch.c"
|
"argmatch.c"
|
||||||
"backupfile.c"
|
"backupfile.c"
|
||||||
"basename.c"
|
"basename.c"
|
||||||
"dirname.c"
|
"dirname.c"
|
||||||
"getopt.c"
|
"getopt.c"
|
||||||
"getopt1.c"
|
"getopt1.c"
|
||||||
"inp.c"
|
"inp.c"
|
||||||
"maketime.c"
|
"maketime.c"
|
||||||
"partime.c"
|
"partime.c"
|
||||||
"patch.c"
|
"patch.c"
|
||||||
"pch.c"
|
"pch.c"
|
||||||
"quote.c"
|
"quote.c"
|
||||||
"quotearg.c"
|
"quotearg.c"
|
||||||
"quotesys.c"
|
"quotesys.c"
|
||||||
"util.c"
|
"util.c"
|
||||||
"version.c"
|
"version.c"
|
||||||
"xmalloc.c"
|
"xmalloc.c"
|
||||||
];
|
];
|
||||||
|
|
||||||
sources = files ++ [
|
sources =
|
||||||
|
files
|
||||||
|
++ [
|
||||||
# mes-libc doesn't implement `error()`
|
# mes-libc doesn't implement `error()`
|
||||||
"error.c"
|
"error.c"
|
||||||
];
|
];
|
||||||
|
|
||||||
objects = builtins.map (
|
objects =
|
||||||
value: builtins.replaceStrings [ ".c" ] [ ".o" ] (builtins.baseNameOf value)
|
builtins.map (
|
||||||
) sources;
|
value: builtins.replaceStrings [".c"] [".o"] (builtins.baseNameOf value)
|
||||||
in
|
)
|
||||||
|
sources;
|
||||||
|
in
|
||||||
builders.kaem.build {
|
builders.kaem.build {
|
||||||
name = "gnupatch-${cfg.version}";
|
name = "gnupatch-${cfg.version}";
|
||||||
|
|
||||||
meta = cfg.meta;
|
meta = cfg.meta;
|
||||||
src = cfg.src;
|
src = cfg.src;
|
||||||
|
|
||||||
deps.build.host = [ stage1.tinycc.mes.compiler.package ];
|
deps.build.host = [stage1.tinycc.mes.compiler.package];
|
||||||
|
|
||||||
script = ''
|
script = ''
|
||||||
# Unpack
|
# Unpack
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
{ lib, config }:
|
{
|
||||||
let
|
lib,
|
||||||
|
config,
|
||||||
|
}: let
|
||||||
cfg = config.aux.foundation.stages.stage1.gnused.boot;
|
cfg = config.aux.foundation.stages.stage1.gnused.boot;
|
||||||
|
|
||||||
builders = config.aux.foundation.builders;
|
builders = config.aux.foundation.builders;
|
||||||
|
|
||||||
stage1 = config.aux.foundation.stages.stage1;
|
stage1 = config.aux.foundation.stages.stage1;
|
||||||
in
|
in {
|
||||||
{
|
|
||||||
options.aux.foundation.stages.stage1.gnused.boot = {
|
options.aux.foundation.stages.stage1.gnused.boot = {
|
||||||
package = lib.options.create {
|
package = lib.options.create {
|
||||||
type = lib.types.derivation;
|
type = lib.types.derivation;
|
||||||
|
@ -33,15 +34,14 @@ in
|
||||||
sha256 = "0006gk1dw2582xsvgx6y6rzs9zw8b36rhafjwm288zqqji3qfrf3";
|
sha256 = "0006gk1dw2582xsvgx6y6rzs9zw8b36rhafjwm288zqqji3qfrf3";
|
||||||
};
|
};
|
||||||
|
|
||||||
package =
|
package = let
|
||||||
let
|
# Thanks to the live-bootstrap project!
|
||||||
# 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
|
||||||
# See https://github.com/fosslinux/live-bootstrap/blob/1bc4296091c51f53a5598050c8956d16e945b0f5/sysa/sed-4.0.9/sed-4.0.9.kaem
|
makefile = builtins.fetchurl {
|
||||||
makefile = builtins.fetchurl {
|
url = "https://github.com/fosslinux/live-bootstrap/raw/1bc4296091c51f53a5598050c8956d16e945b0f5/sysa/sed-4.0.9/mk/main.mk";
|
||||||
url = "https://github.com/fosslinux/live-bootstrap/raw/1bc4296091c51f53a5598050c8956d16e945b0f5/sysa/sed-4.0.9/mk/main.mk";
|
sha256 = "0w1f5ri0g5zla31m6l6xyzbqwdvandqfnzrsw90dd6ak126w3mya";
|
||||||
sha256 = "0w1f5ri0g5zla31m6l6xyzbqwdvandqfnzrsw90dd6ak126w3mya";
|
};
|
||||||
};
|
in
|
||||||
in
|
|
||||||
builders.bash.boot.build {
|
builders.bash.boot.build {
|
||||||
name = "gnused-boot-${cfg.version}";
|
name = "gnused-boot-${cfg.version}";
|
||||||
|
|
||||||
|
|
|
@ -1,14 +1,15 @@
|
||||||
{ lib, config }:
|
{
|
||||||
let
|
lib,
|
||||||
|
config,
|
||||||
|
}: let
|
||||||
cfg = config.aux.foundation.stages.stage1.gnused;
|
cfg = config.aux.foundation.stages.stage1.gnused;
|
||||||
|
|
||||||
platform = config.aux.platform;
|
platform = config.aux.platform;
|
||||||
builders = config.aux.foundation.builders;
|
builders = config.aux.foundation.builders;
|
||||||
|
|
||||||
stage1 = config.aux.foundation.stages.stage1;
|
stage1 = config.aux.foundation.stages.stage1;
|
||||||
in
|
in {
|
||||||
{
|
includes = [./boot.nix];
|
||||||
includes = [ ./boot.nix ];
|
|
||||||
|
|
||||||
options.aux.foundation.stages.stage1.gnused = {
|
options.aux.foundation.stages.stage1.gnused = {
|
||||||
meta = {
|
meta = {
|
||||||
|
@ -34,7 +35,10 @@ in
|
||||||
platforms = lib.options.create {
|
platforms = lib.options.create {
|
||||||
type = lib.types.list.of lib.types.string;
|
type = lib.types.list.of lib.types.string;
|
||||||
description = "Platforms the package supports.";
|
description = "Platforms the package supports.";
|
||||||
default.value = [ "i686-linux" ];
|
default.value = [
|
||||||
|
"i686-linux"
|
||||||
|
"x86_64-linux"
|
||||||
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
mainProgram = lib.options.create {
|
mainProgram = lib.options.create {
|
||||||
|
|
|
@ -37,7 +37,10 @@ in
|
||||||
platforms = lib.options.create {
|
platforms = lib.options.create {
|
||||||
type = lib.types.list.of lib.types.string;
|
type = lib.types.list.of lib.types.string;
|
||||||
description = "Platforms the package supports.";
|
description = "Platforms the package supports.";
|
||||||
default.value = [ "i686-linux" ];
|
default.value = [
|
||||||
|
"i686-linux"
|
||||||
|
"x86_64-linux"
|
||||||
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
mainProgram = lib.options.create {
|
mainProgram = lib.options.create {
|
||||||
|
|
|
@ -31,7 +31,10 @@ in
|
||||||
platforms = lib.options.create {
|
platforms = lib.options.create {
|
||||||
type = lib.types.list.of lib.types.string;
|
type = lib.types.list.of lib.types.string;
|
||||||
description = "Platforms the package supports.";
|
description = "Platforms the package supports.";
|
||||||
default.value = [ "i686-linux" ];
|
default.value = [
|
||||||
|
"i686-linux"
|
||||||
|
"x86_64-linux"
|
||||||
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -60,39 +63,37 @@ in
|
||||||
sha256 = "0ryr5b00qz3xcdcv03qwjdfji8pasp0007ay3ppmk71wl8c1i90w";
|
sha256 = "0ryr5b00qz3xcdcv03qwjdfji8pasp0007ay3ppmk71wl8c1i90w";
|
||||||
};
|
};
|
||||||
|
|
||||||
package =
|
package = builders.bash.boot.build {
|
||||||
let
|
name = "gzip-${cfg.version}";
|
||||||
in
|
meta = cfg.meta;
|
||||||
builders.bash.boot.build {
|
|
||||||
name = "gzip-${cfg.version}";
|
|
||||||
meta = cfg.meta;
|
|
||||||
|
|
||||||
deps.build.host = [
|
deps.build.host = [
|
||||||
stage1.tinycc.mes.compiler.package
|
stage1.tinycc.mes.compiler.package
|
||||||
stage1.gnumake.boot.package
|
stage1.gnumake.boot.package
|
||||||
stage1.gnused.boot.package
|
stage1.gnused.boot.package
|
||||||
stage1.gnugrep.package
|
stage1.gnugrep.package
|
||||||
];
|
];
|
||||||
|
|
||||||
script = ''
|
script = ''
|
||||||
# Unpack
|
# Unpack
|
||||||
ungz --file ${cfg.src} --output gzip.tar
|
ungz --file ${cfg.src} --output gzip.tar
|
||||||
untar --file gzip.tar
|
untar --file gzip.tar
|
||||||
rm gzip.tar
|
rm gzip.tar
|
||||||
cd gzip-${cfg.version}
|
cd gzip-${cfg.version}
|
||||||
|
|
||||||
# Configure
|
# Configure
|
||||||
export CC="tcc -B ${stage1.tinycc.mes.libs.package}/lib -Dstrlwr=unused"
|
export CC="tcc -B ${stage1.tinycc.mes.libs.package}/lib -Dstrlwr=unused"
|
||||||
bash ./configure --prefix=$out
|
chmod +x ./configure
|
||||||
|
./configure --prefix=$out
|
||||||
|
|
||||||
# Build
|
# Build
|
||||||
make
|
make
|
||||||
|
|
||||||
# Install
|
# Install
|
||||||
mkdir $out
|
mkdir $out
|
||||||
make install
|
make install
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
{ lib, config }:
|
{
|
||||||
let
|
lib,
|
||||||
|
config,
|
||||||
|
}: let
|
||||||
cfg = config.aux.foundation.stages.stage1.heirloom;
|
cfg = config.aux.foundation.stages.stage1.heirloom;
|
||||||
|
|
||||||
platform = config.aux.platform;
|
platform = config.aux.platform;
|
||||||
|
@ -7,9 +9,8 @@ let
|
||||||
|
|
||||||
stage1 = config.aux.foundation.stages.stage1;
|
stage1 = config.aux.foundation.stages.stage1;
|
||||||
stage2 = config.aux.foundation.stages.stage2;
|
stage2 = config.aux.foundation.stages.stage2;
|
||||||
in
|
in {
|
||||||
{
|
includes = [./devtools.nix];
|
||||||
includes = [ ./devtools.nix ];
|
|
||||||
|
|
||||||
options.aux.foundation.stages.stage1.heirloom = {
|
options.aux.foundation.stages.stage1.heirloom = {
|
||||||
meta = {
|
meta = {
|
||||||
|
@ -45,7 +46,10 @@ in
|
||||||
platforms = lib.options.create {
|
platforms = lib.options.create {
|
||||||
type = lib.types.list.of lib.types.string;
|
type = lib.types.list.of lib.types.string;
|
||||||
description = "Platforms the package supports.";
|
description = "Platforms the package supports.";
|
||||||
default.value = [ "i686-linux" ];
|
default.value = [
|
||||||
|
"i686-linux"
|
||||||
|
"x86_64-linux"
|
||||||
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -74,62 +78,61 @@ in
|
||||||
sha256 = "6zP3C8wBmx0OCkHx11UtRcV6FicuThxIY07D5ESWow8=";
|
sha256 = "6zP3C8wBmx0OCkHx11UtRcV6FicuThxIY07D5ESWow8=";
|
||||||
};
|
};
|
||||||
|
|
||||||
package =
|
package = let
|
||||||
let
|
patches = [
|
||||||
patches = [
|
# we pre-generate nawk's proctab.c as meslibc is not capable of running maketab
|
||||||
# we pre-generate nawk's proctab.c as meslibc is not capable of running maketab
|
# during build time (insufficient sscanf support)
|
||||||
# during build time (insufficient sscanf support)
|
./patches/proctab.patch
|
||||||
./patches/proctab.patch
|
|
||||||
|
|
||||||
# disable utilities that don't build successfully
|
# disable utilities that don't build successfully
|
||||||
./patches/disable-programs.patch
|
./patches/disable-programs.patch
|
||||||
|
|
||||||
# "tcc -ar" doesn't support creating empty archives
|
# "tcc -ar" doesn't support creating empty archives
|
||||||
./patches/tcc-empty-ar.patch
|
./patches/tcc-empty-ar.patch
|
||||||
# meslibc doesn't have seperate libm
|
# meslibc doesn't have seperate libm
|
||||||
./patches/dont-link-lm.patch
|
./patches/dont-link-lm.patch
|
||||||
# meslibc's vprintf doesn't support %ll
|
# meslibc's vprintf doesn't support %ll
|
||||||
./patches/vprintf.patch
|
./patches/vprintf.patch
|
||||||
# meslibc doesn't support sysconf()
|
# meslibc doesn't support sysconf()
|
||||||
./patches/sysconf.patch
|
./patches/sysconf.patch
|
||||||
# meslibc doesn't support locale
|
# meslibc doesn't support locale
|
||||||
./patches/strcoll.patch
|
./patches/strcoll.patch
|
||||||
# meslibc doesn't support termios.h
|
# meslibc doesn't support termios.h
|
||||||
./patches/termios.patch
|
./patches/termios.patch
|
||||||
# meslibc doesn't support utime.h
|
# meslibc doesn't support utime.h
|
||||||
./patches/utime.patch
|
./patches/utime.patch
|
||||||
# meslibc doesn't support langinfo.h
|
# meslibc doesn't support langinfo.h
|
||||||
./patches/langinfo.patch
|
./patches/langinfo.patch
|
||||||
# support building with meslibc
|
# support building with meslibc
|
||||||
./patches/meslibc-support.patch
|
./patches/meslibc-support.patch
|
||||||
# remove socket functionality as unsupported by meslibc
|
# remove socket functionality as unsupported by meslibc
|
||||||
./patches/cp-no-socket.patch
|
./patches/cp-no-socket.patch
|
||||||
];
|
];
|
||||||
|
|
||||||
makeFlags = [
|
makeFlags = [
|
||||||
# mk.config build options
|
# mk.config build options
|
||||||
"CC='tcc -B ${stage1.tinycc.mes.libs.package}/lib -include ${./stubs.h} -include ${./musl.h}'"
|
"CC='tcc -B ${stage1.tinycc.mes.libs.package}/lib -include ${./stubs.h} -include ${./musl.h}'"
|
||||||
"AR='tcc -ar'"
|
"AR='tcc -ar'"
|
||||||
"RANLIB=true"
|
"RANLIB=true"
|
||||||
"STRIP=true"
|
"STRIP=true"
|
||||||
"SHELL=${stage1.bash.package}/bin/sh"
|
"SHELL=${stage1.bash.package}/bin/sh"
|
||||||
"POSIX_SHELL=${stage1.bash.package}/bin/sh"
|
"POSIX_SHELL=${stage1.bash.package}/bin/sh"
|
||||||
"DEFBIN=/bin"
|
"DEFBIN=/bin"
|
||||||
"SV3BIN=/5bin"
|
"SV3BIN=/5bin"
|
||||||
"S42BIN=/5bin/s42"
|
"S42BIN=/5bin/s42"
|
||||||
"SUSBIN=/bin"
|
"SUSBIN=/bin"
|
||||||
"SU3BIN=/5bin/posix2001"
|
"SU3BIN=/5bin/posix2001"
|
||||||
"UCBBIN=/ucb"
|
"UCBBIN=/ucb"
|
||||||
"CCSBIN=/ccs/bin"
|
"CCSBIN=/ccs/bin"
|
||||||
"DEFLIB=/lib"
|
"DEFLIB=/lib"
|
||||||
"DEFSBIN=/bin"
|
"DEFSBIN=/bin"
|
||||||
"MANDIR=/share/man"
|
"MANDIR=/share/man"
|
||||||
"LCURS=" # disable ncurses
|
"LCURS=" # disable ncurses
|
||||||
"USE_ZLIB=0" # disable zlib
|
"USE_ZLIB=0" # disable zlib
|
||||||
"IWCHAR='-I../libwchar'"
|
"IWCHAR='-I../libwchar'"
|
||||||
"LWCHAR='-L../libwchar -lwchar'"
|
"LWCHAR='-L../libwchar -lwchar'"
|
||||||
];
|
];
|
||||||
in
|
in
|
||||||
builders.bash.boot.build {
|
builders.bash.boot.build {
|
||||||
name = "heirloom-${cfg.version}";
|
name = "heirloom-${cfg.version}";
|
||||||
meta = cfg.meta;
|
meta = cfg.meta;
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
{ lib, config }:
|
{
|
||||||
let
|
lib,
|
||||||
|
config,
|
||||||
|
}: let
|
||||||
cfg = config.aux.foundation.stages.stage1.heirloom.devtools;
|
cfg = config.aux.foundation.stages.stage1.heirloom.devtools;
|
||||||
|
|
||||||
platform = config.aux.platform;
|
platform = config.aux.platform;
|
||||||
|
@ -8,8 +10,7 @@ let
|
||||||
stage0 = config.aux.foundation.stages.stage0;
|
stage0 = config.aux.foundation.stages.stage0;
|
||||||
stage1 = config.aux.foundation.stages.stage1;
|
stage1 = config.aux.foundation.stages.stage1;
|
||||||
stage2 = config.aux.foundation.stages.stage2;
|
stage2 = config.aux.foundation.stages.stage2;
|
||||||
in
|
in {
|
||||||
{
|
|
||||||
options.aux.foundation.stages.stage1.heirloom.devtools = {
|
options.aux.foundation.stages.stage1.heirloom.devtools = {
|
||||||
package = lib.options.create {
|
package = lib.options.create {
|
||||||
type = lib.types.derivation;
|
type = lib.types.derivation;
|
||||||
|
@ -53,7 +54,10 @@ in
|
||||||
platforms = lib.options.create {
|
platforms = lib.options.create {
|
||||||
type = lib.types.list.of lib.types.string;
|
type = lib.types.list.of lib.types.string;
|
||||||
description = "Platforms the package supports.";
|
description = "Platforms the package supports.";
|
||||||
default.value = [ "i686-linux" ];
|
default.value = [
|
||||||
|
"i686-linux"
|
||||||
|
"x86_64-linux"
|
||||||
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -67,25 +71,24 @@ in
|
||||||
sha256 = "9f233d8b78e4351fe9dd2d50d83958a0e5af36f54e9818521458a08e058691ba";
|
sha256 = "9f233d8b78e4351fe9dd2d50d83958a0e5af36f54e9818521458a08e058691ba";
|
||||||
};
|
};
|
||||||
|
|
||||||
package =
|
package = let
|
||||||
let
|
# Thanks to the live-bootstrap project!
|
||||||
# Thanks to the live-bootstrap project!
|
# See https://github.com/fosslinux/live-bootstrap/blob/d918b984ad6fe4fc7680f3be060fd82f8c9fddd9/sysa/heirloom-devtools-070527/heirloom-devtools-070527.kaem
|
||||||
# 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";
|
||||||
liveBootstrap = "https://github.com/fosslinux/live-bootstrap/raw/d918b984ad6fe4fc7680f3be060fd82f8c9fddd9/sysa/heirloom-devtools-070527";
|
|
||||||
|
|
||||||
patches = [
|
patches = [
|
||||||
# Remove all kinds of wchar support. Mes Libc does not support wchar in any form
|
# Remove all kinds of wchar support. Mes Libc does not support wchar in any form
|
||||||
(builtins.fetchurl {
|
(builtins.fetchurl {
|
||||||
url = "${liveBootstrap}/patches/yacc_remove_wchar.patch";
|
url = "${liveBootstrap}/patches/yacc_remove_wchar.patch";
|
||||||
sha256 = "0wgiz02bb7xzjy2gnbjp8y31qy6rc4b29v01zi32zh9lw54j68hc";
|
sha256 = "0wgiz02bb7xzjy2gnbjp8y31qy6rc4b29v01zi32zh9lw54j68hc";
|
||||||
})
|
})
|
||||||
# Similarly to yacc, remove wchar. See yacc patch for further information
|
# Similarly to yacc, remove wchar. See yacc patch for further information
|
||||||
(builtins.fetchurl {
|
(builtins.fetchurl {
|
||||||
url = "${liveBootstrap}/patches/lex_remove_wchar.patch";
|
url = "${liveBootstrap}/patches/lex_remove_wchar.patch";
|
||||||
sha256 = "168dfngi51ljjqgd55wbvmffaq61gk48gak50ymnl1br92qkp4zh";
|
sha256 = "168dfngi51ljjqgd55wbvmffaq61gk48gak50ymnl1br92qkp4zh";
|
||||||
})
|
})
|
||||||
];
|
];
|
||||||
in
|
in
|
||||||
builders.kaem.build {
|
builders.kaem.build {
|
||||||
name = "heirloom-${cfg.version}";
|
name = "heirloom-${cfg.version}";
|
||||||
meta = cfg.meta;
|
meta = cfg.meta;
|
||||||
|
|
|
@ -1,13 +1,14 @@
|
||||||
{ lib, config }:
|
{
|
||||||
let
|
lib,
|
||||||
|
config,
|
||||||
|
}: let
|
||||||
cfg = config.aux.foundation.stages.stage1.linux-headers;
|
cfg = config.aux.foundation.stages.stage1.linux-headers;
|
||||||
|
|
||||||
platform = config.aux.platform;
|
platform = config.aux.platform;
|
||||||
builders = config.aux.foundation.builders;
|
builders = config.aux.foundation.builders;
|
||||||
|
|
||||||
stage1 = config.aux.foundation.stages.stage1;
|
stage1 = config.aux.foundation.stages.stage1;
|
||||||
in
|
in {
|
||||||
{
|
|
||||||
options.aux.foundation.stages.stage1.linux-headers = {
|
options.aux.foundation.stages.stage1.linux-headers = {
|
||||||
meta = {
|
meta = {
|
||||||
description = lib.options.create {
|
description = lib.options.create {
|
||||||
|
@ -26,7 +27,10 @@ in
|
||||||
platforms = lib.options.create {
|
platforms = lib.options.create {
|
||||||
type = lib.types.list.of lib.types.string;
|
type = lib.types.list.of lib.types.string;
|
||||||
description = "Platforms the package supports.";
|
description = "Platforms the package supports.";
|
||||||
default.value = [ "i686-linux" ];
|
default.value = [
|
||||||
|
"i686-linux"
|
||||||
|
"x86_64-linux"
|
||||||
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,14 @@
|
||||||
{ lib, config }:
|
{
|
||||||
let
|
lib,
|
||||||
|
config,
|
||||||
|
}: let
|
||||||
cfg = config.aux.foundation.stages.stage1.ln-boot;
|
cfg = config.aux.foundation.stages.stage1.ln-boot;
|
||||||
|
|
||||||
builders = config.aux.foundation.builders;
|
builders = config.aux.foundation.builders;
|
||||||
|
|
||||||
stage0 = config.aux.foundation.stages.stage0;
|
stage0 = config.aux.foundation.stages.stage0;
|
||||||
stage1 = config.aux.foundation.stages.stage1;
|
stage1 = config.aux.foundation.stages.stage1;
|
||||||
in
|
in {
|
||||||
{
|
|
||||||
options.aux.foundation.stages.stage1.ln-boot = {
|
options.aux.foundation.stages.stage1.ln-boot = {
|
||||||
meta = {
|
meta = {
|
||||||
description = lib.options.create {
|
description = lib.options.create {
|
||||||
|
@ -32,7 +33,10 @@ in
|
||||||
platforms = lib.options.create {
|
platforms = lib.options.create {
|
||||||
type = lib.types.list.of lib.types.string;
|
type = lib.types.list.of lib.types.string;
|
||||||
description = "Platforms the package supports.";
|
description = "Platforms the package supports.";
|
||||||
default.value = [ "i686-linux" ];
|
default.value = [
|
||||||
|
"i686-linux"
|
||||||
|
"x86_64-linux"
|
||||||
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
{ lib, config }:
|
{
|
||||||
let
|
lib,
|
||||||
|
config,
|
||||||
|
}: let
|
||||||
cfg = config.aux.foundation.stages.stage1.mes.compiler;
|
cfg = config.aux.foundation.stages.stage1.mes.compiler;
|
||||||
|
|
||||||
system = config.aux.system;
|
system = config.aux.system;
|
||||||
|
@ -7,8 +9,7 @@ let
|
||||||
|
|
||||||
stage0 = config.aux.foundation.stages.stage0;
|
stage0 = config.aux.foundation.stages.stage0;
|
||||||
stage1 = config.aux.foundation.stages.stage1;
|
stage1 = config.aux.foundation.stages.stage1;
|
||||||
in
|
in {
|
||||||
{
|
|
||||||
options.aux.foundation.stages.stage1.mes.compiler = {
|
options.aux.foundation.stages.stage1.mes.compiler = {
|
||||||
meta = {
|
meta = {
|
||||||
description = lib.options.create {
|
description = lib.options.create {
|
||||||
|
@ -33,7 +34,10 @@ in
|
||||||
platforms = lib.options.create {
|
platforms = lib.options.create {
|
||||||
type = lib.types.list.of lib.types.string;
|
type = lib.types.list.of lib.types.string;
|
||||||
description = "Platforms the package supports.";
|
description = "Platforms the package supports.";
|
||||||
default.value = [ "i686-linux" ];
|
default.value = [
|
||||||
|
"i686-linux"
|
||||||
|
"x86_64-linux"
|
||||||
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -45,46 +49,43 @@ in
|
||||||
|
|
||||||
config = {
|
config = {
|
||||||
aux.foundation.stages.stage1.mes.compiler = {
|
aux.foundation.stages.stage1.mes.compiler = {
|
||||||
package =
|
package = let
|
||||||
let
|
compile = path: let
|
||||||
compile =
|
file = builtins.baseNameOf path;
|
||||||
path:
|
fileWithoutExtension = builtins.replaceStrings [".c"] [""] file;
|
||||||
let
|
|
||||||
file = builtins.baseNameOf path;
|
|
||||||
fileWithoutExtension = builtins.replaceStrings [ ".c" ] [ "" ] file;
|
|
||||||
|
|
||||||
cc = builtins.concatStringsSep " " [
|
cc = builtins.concatStringsSep " " [
|
||||||
"${stage1.mes.libs.src.bin}/bin/mes-m2"
|
"${stage1.mes.libs.src.bin}/bin/mes-m2"
|
||||||
"-e"
|
"-e"
|
||||||
"main"
|
"main"
|
||||||
"${stage1.mes.libs.src.bin}/bin/mescc.scm"
|
"${stage1.mes.libs.src.bin}/bin/mescc.scm"
|
||||||
"--"
|
"--"
|
||||||
"-D"
|
"-D"
|
||||||
"HAVE_CONFIG_H=1"
|
"HAVE_CONFIG_H=1"
|
||||||
"-I"
|
"-I"
|
||||||
"${stage1.mes.libs.prefix}/include"
|
"${stage1.mes.libs.prefix}/include"
|
||||||
"-I"
|
"-I"
|
||||||
"${stage1.mes.libs.prefix}/include/linux/x86"
|
"${stage1.mes.libs.prefix}/include/linux/x86"
|
||||||
];
|
];
|
||||||
in
|
|
||||||
builders.kaem.build {
|
|
||||||
name = fileWithoutExtension;
|
|
||||||
|
|
||||||
script = ''
|
|
||||||
mkdir ''${out}
|
|
||||||
cd ''${out}
|
|
||||||
${cc} -c ${stage1.mes.libs.prefix}/${path}
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
getSourcePath = suffix: source: "${source}/${source.name}${suffix}";
|
|
||||||
|
|
||||||
sources = import ./sources.nix;
|
|
||||||
|
|
||||||
files = lib.strings.concatMapSep " " (getSourcePath ".o") (
|
|
||||||
builtins.map compile sources.x86.linux.mescc.mes
|
|
||||||
);
|
|
||||||
in
|
in
|
||||||
|
builders.kaem.build {
|
||||||
|
name = fileWithoutExtension;
|
||||||
|
|
||||||
|
script = ''
|
||||||
|
mkdir ''${out}
|
||||||
|
cd ''${out}
|
||||||
|
${cc} -c ${stage1.mes.libs.prefix}/${path}
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
getSourcePath = suffix: source: "${source}/${source.name}${suffix}";
|
||||||
|
|
||||||
|
sources = import ./sources.nix;
|
||||||
|
|
||||||
|
files = lib.strings.concatMapSep " " (getSourcePath ".o") (
|
||||||
|
builtins.map compile sources.x86.linux.mescc.mes
|
||||||
|
);
|
||||||
|
in
|
||||||
builders.kaem.build {
|
builders.kaem.build {
|
||||||
name = "mes-${stage1.mes.version}";
|
name = "mes-${stage1.mes.version}";
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
{ lib, config }:
|
{
|
||||||
let
|
lib,
|
||||||
|
config,
|
||||||
|
}: let
|
||||||
cfg = config.aux.foundation.stages.stage1.mes;
|
cfg = config.aux.foundation.stages.stage1.mes;
|
||||||
|
|
||||||
system = config.aux.system;
|
system = config.aux.system;
|
||||||
builders = config.aux.foundation.builders;
|
builders = config.aux.foundation.builders;
|
||||||
in
|
in {
|
||||||
{
|
|
||||||
includes = [
|
includes = [
|
||||||
./compiler.nix
|
./compiler.nix
|
||||||
./libs.nix
|
./libs.nix
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
{ lib, config }:
|
{
|
||||||
let
|
lib,
|
||||||
|
config,
|
||||||
|
}: let
|
||||||
cfg = config.aux.foundation.stages.stage1.mes.libc;
|
cfg = config.aux.foundation.stages.stage1.mes.libc;
|
||||||
|
|
||||||
builders = config.aux.foundation.builders;
|
builders = config.aux.foundation.builders;
|
||||||
|
|
||||||
stage1 = config.aux.foundation.stages.stage1;
|
stage1 = config.aux.foundation.stages.stage1;
|
||||||
in
|
in {
|
||||||
{
|
|
||||||
options.aux.foundation.stages.stage1.mes.libc = {
|
options.aux.foundation.stages.stage1.mes.libc = {
|
||||||
meta = {
|
meta = {
|
||||||
description = lib.options.create {
|
description = lib.options.create {
|
||||||
|
@ -31,7 +32,10 @@ in
|
||||||
platforms = lib.options.create {
|
platforms = lib.options.create {
|
||||||
type = lib.types.list.of lib.types.string;
|
type = lib.types.list.of lib.types.string;
|
||||||
description = "Platforms the package supports.";
|
description = "Platforms the package supports.";
|
||||||
default.value = [ "i686-linux" ];
|
default.value = [
|
||||||
|
"i686-linux"
|
||||||
|
"x86_64-linux"
|
||||||
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -43,21 +47,20 @@ in
|
||||||
|
|
||||||
config = {
|
config = {
|
||||||
aux.foundation.stages.stage1.mes.libc = {
|
aux.foundation.stages.stage1.mes.libc = {
|
||||||
package =
|
package = let
|
||||||
let
|
sources = import ./sources.nix;
|
||||||
sources = import ./sources.nix;
|
|
||||||
|
|
||||||
libtcc1 = sources.x86.linux.gcc.libtcc1;
|
libtcc1 = sources.x86.linux.gcc.libtcc1;
|
||||||
|
|
||||||
first = lib.lists.take 100 sources.x86.linux.gcc.libc_gnu;
|
first = lib.lists.take 100 sources.x86.linux.gcc.libc_gnu;
|
||||||
last = lib.lists.drop 100 sources.x86.linux.gcc.libc_gnu;
|
last = lib.lists.drop 100 sources.x86.linux.gcc.libc_gnu;
|
||||||
in
|
in
|
||||||
builders.kaem.build {
|
builders.kaem.build {
|
||||||
name = "mes-libc-${stage1.mes.version}";
|
name = "mes-libc-${stage1.mes.version}";
|
||||||
|
|
||||||
meta = cfg.meta;
|
meta = cfg.meta;
|
||||||
|
|
||||||
deps.build.host = [ stage1.ln-boot.package ];
|
deps.build.host = [stage1.ln-boot.package];
|
||||||
|
|
||||||
script = ''
|
script = ''
|
||||||
cd ${stage1.mes.libs.prefix}
|
cd ${stage1.mes.libs.prefix}
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
{ lib, config }:
|
{
|
||||||
let
|
lib,
|
||||||
|
config,
|
||||||
|
}: let
|
||||||
cfg = config.aux.foundation.stages.stage1.mes.libs;
|
cfg = config.aux.foundation.stages.stage1.mes.libs;
|
||||||
|
|
||||||
system = config.aux.system;
|
system = config.aux.system;
|
||||||
|
@ -7,8 +9,7 @@ let
|
||||||
|
|
||||||
stage0 = config.aux.foundation.stages.stage0;
|
stage0 = config.aux.foundation.stages.stage0;
|
||||||
stage1 = config.aux.foundation.stages.stage1;
|
stage1 = config.aux.foundation.stages.stage1;
|
||||||
in
|
in {
|
||||||
{
|
|
||||||
options.aux.foundation.stages.stage1.mes.libs = {
|
options.aux.foundation.stages.stage1.mes.libs = {
|
||||||
meta = {
|
meta = {
|
||||||
description = lib.options.create {
|
description = lib.options.create {
|
||||||
|
@ -33,7 +34,10 @@ in
|
||||||
platforms = lib.options.create {
|
platforms = lib.options.create {
|
||||||
type = lib.types.list.of lib.types.string;
|
type = lib.types.list.of lib.types.string;
|
||||||
description = "Platforms the package supports.";
|
description = "Platforms the package supports.";
|
||||||
default.value = [ "i686-linux" ];
|
default.value = [
|
||||||
|
"i686-linux"
|
||||||
|
"x86_64-linux"
|
||||||
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -57,13 +61,12 @@ in
|
||||||
aux.foundation.stages.stage1.mes.libs = {
|
aux.foundation.stages.stage1.mes.libs = {
|
||||||
prefix = "${cfg.src.out}/mes-${stage1.mes.version}";
|
prefix = "${cfg.src.out}/mes-${stage1.mes.version}";
|
||||||
|
|
||||||
src =
|
src = let
|
||||||
let
|
config_h = builtins.toFile "config.h" ''
|
||||||
config_h = builtins.toFile "config.h" ''
|
#undef SYSTEM_LIBC
|
||||||
#undef SYSTEM_LIBC
|
#define MES_VERSION "${stage1.mes.version}"
|
||||||
#define MES_VERSION "${stage1.mes.version}"
|
'';
|
||||||
'';
|
in
|
||||||
in
|
|
||||||
builders.kaem.build {
|
builders.kaem.build {
|
||||||
name = "mes-src-${stage1.mes.version}";
|
name = "mes-src-${stage1.mes.version}";
|
||||||
|
|
||||||
|
@ -140,82 +143,73 @@ in
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
package =
|
package = let
|
||||||
let
|
compile = path: let
|
||||||
compile =
|
file = builtins.baseNameOf path;
|
||||||
path:
|
fileWithoutExtension = builtins.replaceStrings [".c"] [""] file;
|
||||||
let
|
|
||||||
file = builtins.baseNameOf path;
|
|
||||||
fileWithoutExtension = builtins.replaceStrings [ ".c" ] [ "" ] file;
|
|
||||||
|
|
||||||
cc = builtins.concatStringsSep " " [
|
cc = builtins.concatStringsSep " " [
|
||||||
"${cfg.src.bin}/bin/mes-m2"
|
"${cfg.src.bin}/bin/mes-m2"
|
||||||
"-e"
|
"-e"
|
||||||
"main"
|
"main"
|
||||||
"${cfg.src.bin}/bin/mescc.scm"
|
"${cfg.src.bin}/bin/mescc.scm"
|
||||||
"--"
|
"--"
|
||||||
"-D"
|
"-D"
|
||||||
"HAVE_CONFIG_H=1"
|
"HAVE_CONFIG_H=1"
|
||||||
"-I"
|
"-I"
|
||||||
"${cfg.prefix}/include"
|
"${cfg.prefix}/include"
|
||||||
"-I"
|
"-I"
|
||||||
"${cfg.prefix}/include/linux/x86"
|
"${cfg.prefix}/include/linux/x86"
|
||||||
];
|
];
|
||||||
in
|
|
||||||
builders.kaem.build {
|
|
||||||
name = fileWithoutExtension;
|
|
||||||
|
|
||||||
script = ''
|
|
||||||
mkdir ''${out}
|
|
||||||
cd ''${out}
|
|
||||||
${cc} -c ${cfg.prefix}/${path}
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
getSourcePath = suffix: source: "${source}/${source.name}${suffix}";
|
|
||||||
|
|
||||||
archive =
|
|
||||||
destination: sources:
|
|
||||||
"catm ${destination} ${lib.strings.concatMapSep " " (getSourcePath ".o") sources}";
|
|
||||||
source =
|
|
||||||
destination: sources:
|
|
||||||
"catm ${destination} ${lib.strings.concatMapSep " " (getSourcePath ".s") sources}";
|
|
||||||
|
|
||||||
createLib =
|
|
||||||
name: sources:
|
|
||||||
let
|
|
||||||
compiled = builtins.map compile sources;
|
|
||||||
in
|
|
||||||
builders.kaem.build {
|
|
||||||
name = "mes-${name}-${stage1.mes.version}";
|
|
||||||
|
|
||||||
meta = cfg.meta;
|
|
||||||
|
|
||||||
script = ''
|
|
||||||
LIBDIR=''${out}/lib
|
|
||||||
mkdir -p ''${LIBDIR}
|
|
||||||
cd ''${LIBDIR}
|
|
||||||
|
|
||||||
${archive "${name}.a" compiled}
|
|
||||||
${source "${name}.s" compiled}
|
|
||||||
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
sources = import ./sources.nix;
|
|
||||||
|
|
||||||
crt1 = compile "lib/linux/x86-mes-mescc/crt1.c";
|
|
||||||
libc-mini = createLib "libc-mini" sources.x86.linux.mescc.libc_mini;
|
|
||||||
libmescc = createLib "libmescc" sources.x86.linux.mescc.libmescc;
|
|
||||||
libc = createLib "libc" sources.x86.linux.mescc.libc;
|
|
||||||
libc_tcc = createLib "libc+tcc" (
|
|
||||||
sources.x86.linux.mescc.libc_tcc
|
|
||||||
++ [
|
|
||||||
# We need `symlink` support for `ln-boot` to work.
|
|
||||||
"lib/linux/symlink.c"
|
|
||||||
]
|
|
||||||
);
|
|
||||||
in
|
in
|
||||||
|
builders.kaem.build {
|
||||||
|
name = fileWithoutExtension;
|
||||||
|
|
||||||
|
script = ''
|
||||||
|
mkdir ''${out}
|
||||||
|
cd ''${out}
|
||||||
|
${cc} -c ${cfg.prefix}/${path}
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
getSourcePath = suffix: source: "${source}/${source.name}${suffix}";
|
||||||
|
|
||||||
|
archive = destination: sources: "catm ${destination} ${lib.strings.concatMapSep " " (getSourcePath ".o") sources}";
|
||||||
|
source = destination: sources: "catm ${destination} ${lib.strings.concatMapSep " " (getSourcePath ".s") sources}";
|
||||||
|
|
||||||
|
createLib = name: sources: let
|
||||||
|
compiled = builtins.map compile sources;
|
||||||
|
in
|
||||||
|
builders.kaem.build {
|
||||||
|
name = "mes-${name}-${stage1.mes.version}";
|
||||||
|
|
||||||
|
meta = cfg.meta;
|
||||||
|
|
||||||
|
script = ''
|
||||||
|
LIBDIR=''${out}/lib
|
||||||
|
mkdir -p ''${LIBDIR}
|
||||||
|
cd ''${LIBDIR}
|
||||||
|
|
||||||
|
${archive "${name}.a" compiled}
|
||||||
|
${source "${name}.s" compiled}
|
||||||
|
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
sources = import ./sources.nix;
|
||||||
|
|
||||||
|
crt1 = compile "lib/linux/x86-mes-mescc/crt1.c";
|
||||||
|
libc-mini = createLib "libc-mini" sources.x86.linux.mescc.libc_mini;
|
||||||
|
libmescc = createLib "libmescc" sources.x86.linux.mescc.libmescc;
|
||||||
|
libc = createLib "libc" sources.x86.linux.mescc.libc;
|
||||||
|
libc_tcc = createLib "libc+tcc" (
|
||||||
|
sources.x86.linux.mescc.libc_tcc
|
||||||
|
++ [
|
||||||
|
# We need `symlink` support for `ln-boot` to work.
|
||||||
|
"lib/linux/symlink.c"
|
||||||
|
]
|
||||||
|
);
|
||||||
|
in
|
||||||
builders.kaem.build {
|
builders.kaem.build {
|
||||||
name = "mes-m2-libs-${stage1.mes.version}";
|
name = "mes-m2-libs-${stage1.mes.version}";
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,9 @@
|
||||||
"lib/mes/globals.c"
|
"lib/mes/globals.c"
|
||||||
"lib/linux/x86-mes-mescc/syscall-internal.c"
|
"lib/linux/x86-mes-mescc/syscall-internal.c"
|
||||||
];
|
];
|
||||||
libtcc1 = [ "lib/libtcc1.c" ];
|
libtcc1 = [
|
||||||
|
"lib/libtcc1.c"
|
||||||
|
];
|
||||||
libc = [
|
libc = [
|
||||||
"lib/mes/__init_io.c"
|
"lib/mes/__init_io.c"
|
||||||
"lib/mes/eputs.c"
|
"lib/mes/eputs.c"
|
||||||
|
@ -544,7 +546,9 @@
|
||||||
"lib/mes/globals.c"
|
"lib/mes/globals.c"
|
||||||
"lib/linux/x86-mes-gcc/syscall-internal.c"
|
"lib/linux/x86-mes-gcc/syscall-internal.c"
|
||||||
];
|
];
|
||||||
libtcc1 = [ "lib/libtcc1.c" ];
|
libtcc1 = [
|
||||||
|
"lib/libtcc1.c"
|
||||||
|
];
|
||||||
libc = [
|
libc = [
|
||||||
"lib/mes/__init_io.c"
|
"lib/mes/__init_io.c"
|
||||||
"lib/mes/eputs.c"
|
"lib/mes/eputs.c"
|
||||||
|
|
|
@ -35,7 +35,10 @@ in
|
||||||
type = lib.types.list.of lib.types.string;
|
type = lib.types.list.of lib.types.string;
|
||||||
description = "Platforms the package supports.";
|
description = "Platforms the package supports.";
|
||||||
# TODO: Support more platforms.
|
# TODO: Support more platforms.
|
||||||
default.value = [ "i686-linux" ];
|
default.value = [
|
||||||
|
"i686-linux"
|
||||||
|
"x86-64_linux"
|
||||||
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
{ lib, config }:
|
{
|
||||||
let
|
lib,
|
||||||
|
config,
|
||||||
|
}: let
|
||||||
cfg = config.aux.foundation.stages.stage1.nyacc;
|
cfg = config.aux.foundation.stages.stage1.nyacc;
|
||||||
|
|
||||||
builders = config.aux.foundation.builders;
|
builders = config.aux.foundation.builders;
|
||||||
|
@ -8,8 +10,7 @@ let
|
||||||
|
|
||||||
pname = "nyacc";
|
pname = "nyacc";
|
||||||
version = "1.00.2";
|
version = "1.00.2";
|
||||||
in
|
in {
|
||||||
{
|
|
||||||
options.aux.foundation.stages.stage1.nyacc = {
|
options.aux.foundation.stages.stage1.nyacc = {
|
||||||
meta = {
|
meta = {
|
||||||
description = lib.options.create {
|
description = lib.options.create {
|
||||||
|
@ -34,7 +35,10 @@ in
|
||||||
platforms = lib.options.create {
|
platforms = lib.options.create {
|
||||||
type = lib.types.list.of lib.types.string;
|
type = lib.types.list.of lib.types.string;
|
||||||
description = "Platforms the package supports.";
|
description = "Platforms the package supports.";
|
||||||
default.value = [ "i686-linux" ];
|
default.value = [
|
||||||
|
"i686-linux"
|
||||||
|
"x86_64-linux"
|
||||||
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,10 @@ in
|
||||||
platforms = lib.options.create {
|
platforms = lib.options.create {
|
||||||
type = lib.types.list.of lib.types.string;
|
type = lib.types.list.of lib.types.string;
|
||||||
description = "Platforms the package supports.";
|
description = "Platforms the package supports.";
|
||||||
default.value = [ "i686-linux" ];
|
default.value = [
|
||||||
|
"i686-linux"
|
||||||
|
"x86_64-linux"
|
||||||
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
args@{ lib, config }:
|
args @ {
|
||||||
let
|
lib,
|
||||||
|
config,
|
||||||
|
}: let
|
||||||
cfg = config.aux.foundation.stages.stage1.tinycc.boot;
|
cfg = config.aux.foundation.stages.stage1.tinycc.boot;
|
||||||
|
|
||||||
builders = config.aux.foundation.builders;
|
builders = config.aux.foundation.builders;
|
||||||
|
@ -9,8 +11,7 @@ let
|
||||||
pname = "tinycc-boot";
|
pname = "tinycc-boot";
|
||||||
|
|
||||||
helpers = lib.fp.withDynamicArgs (import ./helpers.nix) args;
|
helpers = lib.fp.withDynamicArgs (import ./helpers.nix) args;
|
||||||
in
|
in {
|
||||||
{
|
|
||||||
options.aux.foundation.stages.stage1.tinycc.boot = {
|
options.aux.foundation.stages.stage1.tinycc.boot = {
|
||||||
meta = {
|
meta = {
|
||||||
description = lib.options.create {
|
description = lib.options.create {
|
||||||
|
@ -35,10 +36,7 @@ in
|
||||||
platforms = lib.options.create {
|
platforms = lib.options.create {
|
||||||
type = lib.types.list.of lib.types.string;
|
type = lib.types.list.of lib.types.string;
|
||||||
description = "Platforms the package supports.";
|
description = "Platforms the package supports.";
|
||||||
default.value = [
|
default.value = ["x86_64-linux" "i686-linux"];
|
||||||
"x86_64-linux"
|
|
||||||
"i686-linux"
|
|
||||||
];
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -68,130 +66,129 @@ in
|
||||||
};
|
};
|
||||||
|
|
||||||
config = {
|
config = {
|
||||||
aux.foundation.stages.stage1.tinycc.boot =
|
aux.foundation.stages.stage1.tinycc.boot = let
|
||||||
let
|
tinycc-boot = let
|
||||||
tinycc-boot =
|
tinycc-mes-bootstrappable = helpers.createBoot {
|
||||||
let
|
pname = "tinycc-mes-bootstrappable";
|
||||||
tinycc-mes-bootstrappable = helpers.createBoot {
|
version = stage1.tinycc.version;
|
||||||
pname = "tinycc-mes-bootstrappable";
|
src = cfg.src;
|
||||||
version = stage1.tinycc.version;
|
};
|
||||||
src = cfg.src;
|
|
||||||
};
|
|
||||||
|
|
||||||
tinycc-boot0 = helpers.createTinyccMes {
|
tinycc-boot0 = helpers.createTinyccMes {
|
||||||
pname = "tinycc-boot0";
|
pname = "tinycc-boot0";
|
||||||
version = stage1.tinycc.version;
|
version = stage1.tinycc.version;
|
||||||
src = cfg.src;
|
src = cfg.src;
|
||||||
args = [
|
args = [
|
||||||
"-D HAVE_LONG_LONG_STUB=1"
|
"-D HAVE_LONG_LONG_STUB=1"
|
||||||
"-D HAVE_SETJMP=1"
|
"-D HAVE_SETJMP=1"
|
||||||
];
|
];
|
||||||
lib.args = [ "-D HAVE_LONG_LONG_STUB=1" ];
|
lib.args = [
|
||||||
boot = tinycc-mes-bootstrappable;
|
"-D HAVE_LONG_LONG_STUB=1"
|
||||||
meta = cfg.meta;
|
];
|
||||||
};
|
boot = tinycc-mes-bootstrappable;
|
||||||
|
meta = cfg.meta;
|
||||||
|
};
|
||||||
|
|
||||||
tinycc-boot1 = helpers.createTinyccMes {
|
tinycc-boot1 = helpers.createTinyccMes {
|
||||||
pname = "tinycc-boot1";
|
pname = "tinycc-boot1";
|
||||||
version = stage1.tinycc.version;
|
version = stage1.tinycc.version;
|
||||||
src = cfg.src;
|
src = cfg.src;
|
||||||
args = [
|
args = [
|
||||||
"-D HAVE_BITFIELD=1"
|
"-D HAVE_BITFIELD=1"
|
||||||
"-D HAVE_LONG_LONG=1"
|
"-D HAVE_LONG_LONG=1"
|
||||||
"-D HAVE_SETJMP=1"
|
"-D HAVE_SETJMP=1"
|
||||||
];
|
];
|
||||||
lib.args = [ "-D HAVE_LONG_LONG=1" ];
|
lib.args = [
|
||||||
boot = tinycc-boot0;
|
"-D HAVE_LONG_LONG=1"
|
||||||
meta = cfg.meta;
|
];
|
||||||
};
|
boot = tinycc-boot0;
|
||||||
|
meta = cfg.meta;
|
||||||
|
};
|
||||||
|
|
||||||
tinycc-boot2 = helpers.createTinyccMes {
|
tinycc-boot2 = helpers.createTinyccMes {
|
||||||
pname = "tinycc-boot2";
|
pname = "tinycc-boot2";
|
||||||
version = stage1.tinycc.version;
|
version = stage1.tinycc.version;
|
||||||
src = cfg.src;
|
src = cfg.src;
|
||||||
args = [
|
args = [
|
||||||
"-D HAVE_BITFIELD=1"
|
"-D HAVE_BITFIELD=1"
|
||||||
"-D HAVE_FLOAT_STUB=1"
|
"-D HAVE_FLOAT_STUB=1"
|
||||||
"-D HAVE_LONG_LONG=1"
|
"-D HAVE_LONG_LONG=1"
|
||||||
"-D HAVE_SETJMP=1"
|
"-D HAVE_SETJMP=1"
|
||||||
];
|
];
|
||||||
lib.args = [
|
lib.args = [
|
||||||
"-D HAVE_FLOAT_STUB=1"
|
"-D HAVE_FLOAT_STUB=1"
|
||||||
"-D HAVE_LONG_LONG=1"
|
"-D HAVE_LONG_LONG=1"
|
||||||
];
|
];
|
||||||
boot = tinycc-boot1;
|
boot = tinycc-boot1;
|
||||||
meta = cfg.meta;
|
meta = cfg.meta;
|
||||||
};
|
};
|
||||||
|
|
||||||
tinycc-boot3 = helpers.createTinyccMes {
|
tinycc-boot3 = helpers.createTinyccMes {
|
||||||
pname = "tinycc-boot3";
|
pname = "tinycc-boot3";
|
||||||
version = stage1.tinycc.version;
|
version = stage1.tinycc.version;
|
||||||
src = cfg.src;
|
src = cfg.src;
|
||||||
args = [
|
args = [
|
||||||
"-D HAVE_BITFIELD=1"
|
"-D HAVE_BITFIELD=1"
|
||||||
"-D HAVE_FLOAT=1"
|
"-D HAVE_FLOAT=1"
|
||||||
"-D HAVE_LONG_LONG=1"
|
"-D HAVE_LONG_LONG=1"
|
||||||
"-D HAVE_SETJMP=1"
|
"-D HAVE_SETJMP=1"
|
||||||
];
|
];
|
||||||
lib.args = [
|
lib.args = [
|
||||||
"-D HAVE_FLOAT=1"
|
"-D HAVE_FLOAT=1"
|
||||||
"-D HAVE_LONG_LONG=1"
|
"-D HAVE_LONG_LONG=1"
|
||||||
];
|
];
|
||||||
boot = tinycc-boot2;
|
boot = tinycc-boot2;
|
||||||
meta = cfg.meta;
|
meta = cfg.meta;
|
||||||
};
|
};
|
||||||
in
|
|
||||||
helpers.createTinyccMes {
|
|
||||||
pname = "tinycc-boot";
|
|
||||||
version = stage1.tinycc.version;
|
|
||||||
src = cfg.src;
|
|
||||||
args = [
|
|
||||||
"-D HAVE_BITFIELD=1"
|
|
||||||
"-D HAVE_FLOAT=1"
|
|
||||||
"-D HAVE_LONG_LONG=1"
|
|
||||||
"-D HAVE_SETJMP=1"
|
|
||||||
];
|
|
||||||
lib.args = [
|
|
||||||
"-D HAVE_FLOAT=1"
|
|
||||||
"-D HAVE_LONG_LONG=1"
|
|
||||||
];
|
|
||||||
boot = tinycc-boot3;
|
|
||||||
meta = cfg.meta;
|
|
||||||
};
|
|
||||||
in
|
in
|
||||||
{
|
helpers.createTinyccMes {
|
||||||
revision = "80114c4da6b17fbaabb399cc29f427e368309bc8";
|
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";
|
||||||
|
|
||||||
libs.package = tinycc-boot.libs;
|
libs.package = tinycc-boot.libs;
|
||||||
compiler.package = tinycc-boot.compiler;
|
compiler.package = tinycc-boot.compiler;
|
||||||
|
|
||||||
src =
|
src = let
|
||||||
let
|
tarball = builtins.fetchurl {
|
||||||
tarball = builtins.fetchurl {
|
url = "https://gitlab.com/janneke/tinycc/-/archive/${cfg.revision}/tinycc-${cfg.revision}.tar.gz";
|
||||||
url = "https://gitlab.com/janneke/tinycc/-/archive/${cfg.revision}/tinycc-${cfg.revision}.tar.gz";
|
sha256 = "1a0cw9a62qc76qqn5sjmp3xrbbvsz2dxrw21lrnx9q0s74mwaxbq";
|
||||||
sha256 = "1a0cw9a62qc76qqn5sjmp3xrbbvsz2dxrw21lrnx9q0s74mwaxbq";
|
};
|
||||||
};
|
|
||||||
|
|
||||||
patched = builders.kaem.build {
|
patched = builders.kaem.build {
|
||||||
name = "${pname}-src";
|
name = "${pname}-src";
|
||||||
|
|
||||||
meta = stage1.tinycc.meta;
|
meta = stage1.tinycc.meta;
|
||||||
|
|
||||||
script = ''
|
script = ''
|
||||||
ungz --file ${tarball} --output tinycc.tar
|
ungz --file ${tarball} --output tinycc.tar
|
||||||
mkdir -p ''${out}
|
mkdir -p ''${out}
|
||||||
cd ''${out}
|
cd ''${out}
|
||||||
untar --file ''${NIX_BUILD_TOP}/tinycc.tar
|
untar --file ''${NIX_BUILD_TOP}/tinycc.tar
|
||||||
|
|
||||||
# Patch
|
# Patch
|
||||||
cd tinycc-${cfg.revision}
|
cd tinycc-${cfg.revision}
|
||||||
|
|
||||||
# Static link by default
|
# Static link by default
|
||||||
replace --file libtcc.c --output libtcc.c --match-on "s->ms_extensions = 1;" --replace-with "s->ms_extensions = 1; s->static_link = 1;"
|
replace --file libtcc.c --output libtcc.c --match-on "s->ms_extensions = 1;" --replace-with "s->ms_extensions = 1; s->static_link = 1;"
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
in
|
in "${patched}/tinycc-${cfg.revision}";
|
||||||
"${patched}/tinycc-${cfg.revision}";
|
};
|
||||||
};
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
{ lib, config }:
|
{
|
||||||
let
|
lib,
|
||||||
|
config,
|
||||||
|
}: let
|
||||||
cfg = config.aux.foundation.stages.stage1.tinycc;
|
cfg = config.aux.foundation.stages.stage1.tinycc;
|
||||||
|
|
||||||
builders = config.aux.foundation.builders;
|
builders = config.aux.foundation.builders;
|
||||||
|
|
||||||
stage1 = config.aux.foundation.stages.stage1;
|
stage1 = config.aux.foundation.stages.stage1;
|
||||||
in
|
in {
|
||||||
{
|
|
||||||
includes = [
|
includes = [
|
||||||
./boot.nix
|
./boot.nix
|
||||||
./mes.nix
|
./mes.nix
|
||||||
|
@ -37,7 +38,10 @@ in
|
||||||
platforms = lib.options.create {
|
platforms = lib.options.create {
|
||||||
type = lib.types.list.of lib.types.string;
|
type = lib.types.list.of lib.types.string;
|
||||||
description = "Platforms the package supports.";
|
description = "Platforms the package supports.";
|
||||||
default.value = [ "i686-linux" ];
|
default.value = [
|
||||||
|
"x86_64-linux"
|
||||||
|
"i686-linux"
|
||||||
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
{ lib, config }:
|
{
|
||||||
let
|
lib,
|
||||||
|
config,
|
||||||
|
}: let
|
||||||
cfg = config.aux.foundation.stages.stage1.tinycc.boot;
|
cfg = config.aux.foundation.stages.stage1.tinycc.boot;
|
||||||
|
|
||||||
builders = config.aux.foundation.builders;
|
builders = config.aux.foundation.builders;
|
||||||
|
@ -7,163 +9,151 @@ let
|
||||||
stage1 = config.aux.foundation.stages.stage1;
|
stage1 = config.aux.foundation.stages.stage1;
|
||||||
cflags = stage1.mes.libc.package.extras.CFLAGS;
|
cflags = stage1.mes.libc.package.extras.CFLAGS;
|
||||||
|
|
||||||
createBoot =
|
createBoot = {
|
||||||
{
|
pname,
|
||||||
pname,
|
version,
|
||||||
version,
|
src,
|
||||||
src,
|
}: let
|
||||||
}:
|
compiler = builders.kaem.build {
|
||||||
let
|
name = "${pname}-${version}";
|
||||||
compiler = builders.kaem.build {
|
|
||||||
name = "${pname}-${version}";
|
|
||||||
|
|
||||||
script = ''
|
script = ''
|
||||||
catm config.h
|
catm config.h
|
||||||
${stage1.mes.compiler.package}/bin/mes --no-auto-compile -e main ${stage1.mes.libs.src.bin}/bin/mescc.scm -- \
|
${stage1.mes.compiler.package}/bin/mes --no-auto-compile -e main ${stage1.mes.libs.src.bin}/bin/mescc.scm -- \
|
||||||
-S \
|
-S \
|
||||||
-o tcc.s \
|
-o tcc.s \
|
||||||
-I . \
|
-I . \
|
||||||
-D BOOTSTRAP=1 \
|
-D BOOTSTRAP=1 \
|
||||||
-I ${src} \
|
-I ${src} \
|
||||||
-D TCC_TARGET_I386=1 \
|
-D TCC_TARGET_I386=1 \
|
||||||
-D inline= \
|
-D inline= \
|
||||||
-D CONFIG_TCCDIR=\"\" \
|
-D CONFIG_TCCDIR=\"\" \
|
||||||
-D CONFIG_SYSROOT=\"\" \
|
-D CONFIG_SYSROOT=\"\" \
|
||||||
-D CONFIG_TCC_CRTPREFIX=\"{B}\" \
|
-D CONFIG_TCC_CRTPREFIX=\"{B}\" \
|
||||||
-D CONFIG_TCC_ELFINTERP=\"/mes/loader\" \
|
-D CONFIG_TCC_ELFINTERP=\"/mes/loader\" \
|
||||||
-D CONFIG_TCC_LIBPATHS=\"{B}\" \
|
-D CONFIG_TCC_LIBPATHS=\"{B}\" \
|
||||||
-D CONFIG_TCC_SYSINCLUDEPATHS=\"${stage1.mes.libc.package}/include\" \
|
-D CONFIG_TCC_SYSINCLUDEPATHS=\"${stage1.mes.libc.package}/include\" \
|
||||||
-D TCC_LIBGCC=\"${stage1.mes.libc.package}/lib/x86-mes/libc.a\" \
|
-D TCC_LIBGCC=\"${stage1.mes.libc.package}/lib/x86-mes/libc.a\" \
|
||||||
-D CONFIG_TCC_LIBTCC1_MES=0 \
|
-D CONFIG_TCC_LIBTCC1_MES=0 \
|
||||||
-D CONFIG_TCCBOOT=1 \
|
-D CONFIG_TCCBOOT=1 \
|
||||||
-D CONFIG_TCC_STATIC=1 \
|
-D CONFIG_TCC_STATIC=1 \
|
||||||
-D CONFIG_USE_LIBGCC=1 \
|
-D CONFIG_USE_LIBGCC=1 \
|
||||||
-D TCC_MES_LIBC=1 \
|
-D TCC_MES_LIBC=1 \
|
||||||
-D TCC_VERSION=\"${version}\" \
|
-D TCC_VERSION=\"${version}\" \
|
||||||
-D ONE_SOURCE=1 \
|
-D ONE_SOURCE=1 \
|
||||||
${src}/tcc.c
|
${src}/tcc.c
|
||||||
mkdir -p ''${out}/bin
|
mkdir -p ''${out}/bin
|
||||||
${stage1.mes.compiler.package}/bin/mes --no-auto-compile -e main ${stage1.mes.libs.src.bin}/bin/mescc.scm -- \
|
${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 ${stage1.mes.libs.package}/lib \
|
||||||
-l c+tcc \
|
-l c+tcc \
|
||||||
-o ''${out}/bin/tcc \
|
-o ''${out}/bin/tcc \
|
||||||
tcc.s
|
tcc.s
|
||||||
'';
|
'';
|
||||||
};
|
|
||||||
|
|
||||||
libs = createLibc {
|
|
||||||
inherit pname version;
|
|
||||||
src = stage1.mes.libc.package;
|
|
||||||
args = cflags;
|
|
||||||
tinycc = compiler;
|
|
||||||
};
|
|
||||||
in
|
|
||||||
{
|
|
||||||
inherit compiler libs;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
createTinyccMes =
|
libs = createLibc {
|
||||||
{
|
inherit pname version;
|
||||||
pname,
|
src = stage1.mes.libc.package;
|
||||||
version,
|
args = cflags;
|
||||||
src,
|
tinycc = compiler;
|
||||||
args,
|
};
|
||||||
boot,
|
in {inherit compiler libs;};
|
||||||
lib ? { },
|
|
||||||
meta,
|
|
||||||
}:
|
|
||||||
let
|
|
||||||
compiler = builders.kaem.build {
|
|
||||||
name = "${pname}-${version}";
|
|
||||||
|
|
||||||
inherit meta;
|
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;
|
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
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
args = builtins.concatStringsSep " " (
|
libs = createLibc {
|
||||||
[
|
inherit pname version src;
|
||||||
"-c"
|
|
||||||
"-D"
|
args =
|
||||||
"TCC_TARGET_I386=1"
|
builtins.concatStringsSep
|
||||||
]
|
" "
|
||||||
++ (lib.args or [ ])
|
(
|
||||||
|
["-c" "-D" "TCC_TARGET_I386=1"]
|
||||||
|
++ (lib.args or [])
|
||||||
);
|
);
|
||||||
|
|
||||||
tinycc = compiler;
|
tinycc = compiler;
|
||||||
};
|
|
||||||
in
|
|
||||||
{
|
|
||||||
inherit compiler libs boot;
|
|
||||||
};
|
};
|
||||||
|
in {
|
||||||
|
inherit compiler libs boot;
|
||||||
|
};
|
||||||
|
|
||||||
createLibc =
|
createLibc = {
|
||||||
{
|
pname,
|
||||||
pname,
|
version,
|
||||||
version,
|
src,
|
||||||
src,
|
args,
|
||||||
args,
|
tinycc,
|
||||||
tinycc,
|
}: let
|
||||||
}:
|
createLibrary = name: args: source:
|
||||||
let
|
builders.kaem.build {
|
||||||
createLibrary =
|
name = "${name}.a";
|
||||||
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 = ''
|
script = ''
|
||||||
mkdir -p ''${out}/lib
|
${tinycc}/bin/tcc ${args} -c -o ${name}.o ${source}
|
||||||
${tinycc}/bin/tcc ${cflags} -c -o ''${out}/lib/crt1.o ${stage1.mes.libc.package}/lib/crt1.c
|
${tinycc}/bin/tcc -ar cr ''${out} ${name}.o
|
||||||
${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";
|
crt = builders.kaem.build {
|
||||||
libc = createLibrary "libc" cflags "${stage1.mes.libc.package}/lib/libc.c";
|
name = "crt";
|
||||||
libgetopt = createLibrary "libgetopt" cflags "${stage1.mes.libc.package}/lib/libgetopt.c";
|
|
||||||
in
|
script = ''
|
||||||
|
mkdir -p ''${out}/lib
|
||||||
|
${tinycc}/bin/tcc ${cflags} -c -o ''${out}/lib/crt1.o ${stage1.mes.libc.package}/lib/crt1.c
|
||||||
|
${tinycc}/bin/tcc ${cflags} -c -o ''${out}/lib/crtn.o ${stage1.mes.libc.package}/lib/crtn.c
|
||||||
|
${tinycc}/bin/tcc ${cflags} -c -o ''${out}/lib/crti.o ${stage1.mes.libc.package}/lib/crti.c
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
libtcc1 = createLibrary "libtcc1" args "${src}/lib/libtcc1.c";
|
||||||
|
libc = createLibrary "libc" cflags "${stage1.mes.libc.package}/lib/libc.c";
|
||||||
|
libgetopt = createLibrary "libgetopt" cflags "${stage1.mes.libc.package}/lib/libgetopt.c";
|
||||||
|
in
|
||||||
builders.kaem.build {
|
builders.kaem.build {
|
||||||
name = "${pname}-libs-${version}";
|
name = "${pname}-libs-${version}";
|
||||||
|
|
||||||
|
@ -177,7 +167,10 @@ let
|
||||||
cp ${libgetopt} ''${out}/lib/libgetopt.a
|
cp ${libgetopt} ''${out}/lib/libgetopt.a
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
in
|
in {
|
||||||
{
|
inherit
|
||||||
inherit createBoot createTinyccMes createLibc;
|
createBoot
|
||||||
|
createTinyccMes
|
||||||
|
createLibc
|
||||||
|
;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
args@{ lib, config }:
|
args @ {
|
||||||
let
|
lib,
|
||||||
|
config,
|
||||||
|
}: let
|
||||||
cfg = config.aux.foundation.stages.stage1.tinycc.mes;
|
cfg = config.aux.foundation.stages.stage1.tinycc.mes;
|
||||||
|
|
||||||
builders = config.aux.foundation.builders;
|
builders = config.aux.foundation.builders;
|
||||||
|
@ -9,8 +11,7 @@ let
|
||||||
pname = "tinycc-mes";
|
pname = "tinycc-mes";
|
||||||
|
|
||||||
helpers = lib.fp.withDynamicArgs (import ./helpers.nix) args;
|
helpers = lib.fp.withDynamicArgs (import ./helpers.nix) args;
|
||||||
in
|
in {
|
||||||
{
|
|
||||||
options.aux.foundation.stages.stage1.tinycc.mes = {
|
options.aux.foundation.stages.stage1.tinycc.mes = {
|
||||||
compiler = {
|
compiler = {
|
||||||
package = lib.options.create {
|
package = lib.options.create {
|
||||||
|
@ -38,109 +39,104 @@ in
|
||||||
};
|
};
|
||||||
|
|
||||||
config = {
|
config = {
|
||||||
aux.foundation.stages.stage1.tinycc.mes =
|
aux.foundation.stages.stage1.tinycc.mes = let
|
||||||
let
|
tinycc-mes = let
|
||||||
tinycc-mes =
|
tccdefs = builders.kaem.build {
|
||||||
let
|
name = "tccdefs-${stage1.tinycc.version}";
|
||||||
tccdefs = builders.kaem.build {
|
|
||||||
name = "tccdefs-${stage1.tinycc.version}";
|
|
||||||
|
|
||||||
script = ''
|
script = ''
|
||||||
mkdir ''${out}
|
mkdir ''${out}
|
||||||
${stage1.tinycc.boot.compiler.package}/bin/tcc \
|
${stage1.tinycc.boot.compiler.package}/bin/tcc \
|
||||||
-B ${stage1.tinycc.boot.libs.package}/lib \
|
-B ${stage1.tinycc.boot.libs.package}/lib \
|
||||||
-DC2STR \
|
-DC2STR \
|
||||||
-o c2str \
|
-o c2str \
|
||||||
${cfg.src}/conftest.c
|
${cfg.src}/conftest.c
|
||||||
./c2str ${cfg.src}/include/tccdefs.h ''${out}/tccdefs_.h
|
./c2str ${cfg.src}/include/tccdefs.h ''${out}/tccdefs_.h
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
tinycc-mes-boot = helpers.createTinyccMes {
|
tinycc-mes-boot = helpers.createTinyccMes {
|
||||||
pname = "${pname}-boot";
|
pname = "${pname}-boot";
|
||||||
version = stage1.tinycc.version;
|
version = stage1.tinycc.version;
|
||||||
src = cfg.src;
|
src = cfg.src;
|
||||||
args = [
|
args = [
|
||||||
"-D HAVE_BITFIELD=1"
|
"-D HAVE_BITFIELD=1"
|
||||||
"-D HAVE_FLOAT=1"
|
"-D HAVE_FLOAT=1"
|
||||||
"-D HAVE_LONG_LONG=1"
|
"-D HAVE_LONG_LONG=1"
|
||||||
"-D HAVE_SETJMP=1"
|
"-D HAVE_SETJMP=1"
|
||||||
"-D CONFIG_TCC_PREDEFS=1"
|
"-D CONFIG_TCC_PREDEFS=1"
|
||||||
"-I ${tccdefs}"
|
"-I ${tccdefs}"
|
||||||
"-D CONFIG_TCC_SEMLOCK=0"
|
"-D CONFIG_TCC_SEMLOCK=0"
|
||||||
];
|
];
|
||||||
lib.args = [
|
lib.args = [
|
||||||
"-D HAVE_FLOAT=1"
|
"-D HAVE_FLOAT=1"
|
||||||
"-D HAVE_LONG_LONG=1"
|
"-D HAVE_LONG_LONG=1"
|
||||||
"-D CONFIG_TCC_PREDEFS=1"
|
"-D CONFIG_TCC_PREDEFS=1"
|
||||||
"-I ${tccdefs}"
|
"-I ${tccdefs}"
|
||||||
"-D CONFIG_TCC_SEMLOCK=0"
|
"-D CONFIG_TCC_SEMLOCK=0"
|
||||||
];
|
];
|
||||||
boot = {
|
boot = {
|
||||||
libs = stage1.tinycc.boot.libs.package;
|
libs = stage1.tinycc.boot.libs.package;
|
||||||
compiler = stage1.tinycc.boot.compiler.package;
|
compiler = stage1.tinycc.boot.compiler.package;
|
||||||
};
|
|
||||||
meta = stage1.tinycc.meta;
|
|
||||||
};
|
|
||||||
in
|
|
||||||
helpers.createTinyccMes {
|
|
||||||
inherit pname;
|
|
||||||
version = stage1.tinycc.version;
|
|
||||||
src = cfg.src;
|
|
||||||
args = [
|
|
||||||
"-std=c99"
|
|
||||||
"-D HAVE_BITFIELD=1"
|
|
||||||
"-D HAVE_FLOAT=1"
|
|
||||||
"-D HAVE_LONG_LONG=1"
|
|
||||||
"-D HAVE_SETJMP=1"
|
|
||||||
"-D CONFIG_TCC_PREDEFS=1"
|
|
||||||
"-I ${tccdefs}"
|
|
||||||
"-D CONFIG_TCC_SEMLOCK=0"
|
|
||||||
];
|
|
||||||
lib.args = [
|
|
||||||
"-D HAVE_FLOAT=1"
|
|
||||||
"-D HAVE_LONG_LONG=1"
|
|
||||||
"-D CONFIG_TCC_PREDEFS=1"
|
|
||||||
"-I ${tccdefs}"
|
|
||||||
"-D CONFIG_TCC_SEMLOCK=0"
|
|
||||||
];
|
|
||||||
boot = tinycc-mes-boot;
|
|
||||||
meta = stage1.tinycc.meta;
|
|
||||||
};
|
};
|
||||||
|
meta = stage1.tinycc.meta;
|
||||||
|
};
|
||||||
in
|
in
|
||||||
{
|
helpers.createTinyccMes {
|
||||||
revision = "86f3d8e33105435946383aee52487b5ddf918140";
|
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";
|
||||||
|
|
||||||
libs.package = tinycc-mes.libs;
|
libs.package = tinycc-mes.libs;
|
||||||
compiler.package = tinycc-mes.compiler;
|
compiler.package = tinycc-mes.compiler;
|
||||||
|
|
||||||
src =
|
src = let
|
||||||
let
|
tarball = builtins.fetchurl {
|
||||||
tarball = builtins.fetchurl {
|
url = "https://repo.or.cz/tinycc.git/snapshot/${cfg.revision}.tar.gz";
|
||||||
url = "https://repo.or.cz/tinycc.git/snapshot/${cfg.revision}.tar.gz";
|
sha256 = "11idrvbwfgj1d03crv994mpbbbyg63j1k64lw1gjy7mkiifw2xap";
|
||||||
sha256 = "11idrvbwfgj1d03crv994mpbbbyg63j1k64lw1gjy7mkiifw2xap";
|
};
|
||||||
};
|
|
||||||
|
|
||||||
patched = builders.kaem.build {
|
patched = builders.kaem.build {
|
||||||
name = "${pname}-src";
|
name = "${pname}-src";
|
||||||
|
|
||||||
meta = stage1.tinycc.meta;
|
meta = stage1.tinycc.meta;
|
||||||
|
|
||||||
script = ''
|
script = ''
|
||||||
ungz --file ${tarball} --output tinycc.tar
|
ungz --file ${tarball} --output tinycc.tar
|
||||||
mkdir -p ''${out}
|
mkdir -p ''${out}
|
||||||
cd ''${out}
|
cd ''${out}
|
||||||
untar --file ''${NIX_BUILD_TOP}/tinycc.tar
|
untar --file ''${NIX_BUILD_TOP}/tinycc.tar
|
||||||
|
|
||||||
# Patch
|
# Patch
|
||||||
cd tinycc-${builtins.substring 0 7 cfg.revision}
|
cd tinycc-${builtins.substring 0 7 cfg.revision}
|
||||||
|
|
||||||
# Static link by default
|
# Static link by default
|
||||||
replace --file libtcc.c --output libtcc.c --match-on "s->ms_extensions = 1;" --replace-with "s->ms_extensions = 1; s->static_link = 1;"
|
replace --file libtcc.c --output libtcc.c --match-on "s->ms_extensions = 1;" --replace-with "s->ms_extensions = 1; s->static_link = 1;"
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
in
|
in "${patched}/tinycc-${builtins.substring 0 7 cfg.revision}";
|
||||||
"${patched}/tinycc-${builtins.substring 0 7 cfg.revision}";
|
};
|
||||||
};
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
args@{ lib, config }:
|
args @ {
|
||||||
let
|
lib,
|
||||||
|
config,
|
||||||
|
}: let
|
||||||
cfg = config.aux.foundation.stages.stage1.tinycc.musl;
|
cfg = config.aux.foundation.stages.stage1.tinycc.musl;
|
||||||
|
|
||||||
builders = config.aux.foundation.builders;
|
builders = config.aux.foundation.builders;
|
||||||
|
@ -9,8 +11,7 @@ let
|
||||||
pname = "tinycc-musl";
|
pname = "tinycc-musl";
|
||||||
|
|
||||||
helpers = lib.fp.withDynamicArgs (import ./helpers.nix) args;
|
helpers = lib.fp.withDynamicArgs (import ./helpers.nix) args;
|
||||||
in
|
in {
|
||||||
{
|
|
||||||
options.aux.foundation.stages.stage1.tinycc.musl = {
|
options.aux.foundation.stages.stage1.tinycc.musl = {
|
||||||
compiler = {
|
compiler = {
|
||||||
package = lib.options.create {
|
package = lib.options.create {
|
||||||
|
@ -38,141 +39,139 @@ in
|
||||||
};
|
};
|
||||||
|
|
||||||
config = {
|
config = {
|
||||||
aux.foundation.stages.stage1.tinycc.musl =
|
aux.foundation.stages.stage1.tinycc.musl = let
|
||||||
let
|
patches = [
|
||||||
patches = [
|
./patches/ignore-duplicate-symbols.patch
|
||||||
./patches/ignore-duplicate-symbols.patch
|
./patches/ignore-static-inside-array.patch
|
||||||
./patches/ignore-static-inside-array.patch
|
./patches/static-link.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
|
||||||
];
|
];
|
||||||
|
|
||||||
tinycc-musl = builders.bash.boot.build {
|
script = ''
|
||||||
name = "${pname}-${stage1.tinycc.version}";
|
# Unpack
|
||||||
|
tar xzf ${cfg.src}
|
||||||
|
cd tinycc-${builtins.substring 0 7 cfg.revision}
|
||||||
|
|
||||||
meta = stage1.tinycc.meta;
|
# Patch
|
||||||
|
${lib.strings.concatMapSep "\n" (file: "patch -Np0 -i ${file}") patches}
|
||||||
|
|
||||||
deps.build.host = [
|
# Configure
|
||||||
stage1.tinycc.boot.compiler.package
|
touch config.h
|
||||||
stage1.gnupatch.package
|
|
||||||
stage1.gnutar.boot.package
|
|
||||||
stage1.gzip.package
|
|
||||||
];
|
|
||||||
|
|
||||||
script = ''
|
# Build
|
||||||
# Unpack
|
# We first have to recompile using tcc-0.9.26 as tcc-0.9.27 is not self-hosting,
|
||||||
tar xzf ${cfg.src}
|
# but when linked with musl it is.
|
||||||
cd tinycc-${builtins.substring 0 7 cfg.revision}
|
ln -s ${stage1.musl.boot.package}/lib/libtcc1.a ./libtcc1.a
|
||||||
|
|
||||||
# Patch
|
tcc \
|
||||||
${lib.strings.concatMapSep "\n" (file: "patch -Np0 -i ${file}") patches}
|
-B ${stage1.tinycc.boot.libs.package}/lib \
|
||||||
|
-DC2STR \
|
||||||
|
-o c2str \
|
||||||
|
conftest.c
|
||||||
|
./c2str include/tccdefs.h tccdefs_.h
|
||||||
|
|
||||||
# Configure
|
tcc -v \
|
||||||
touch config.h
|
-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
|
||||||
|
|
||||||
# Build
|
# Rebuild tcc-musl with itself
|
||||||
# We first have to recompile using tcc-0.9.26 as tcc-0.9.27 is not self-hosting,
|
./tcc-musl \
|
||||||
# but when linked with musl it is.
|
-v \
|
||||||
ln -s ${stage1.musl.boot.package}/lib/libtcc1.a ./libtcc1.a
|
-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
|
||||||
|
|
||||||
tcc \
|
# Install
|
||||||
-B ${stage1.tinycc.boot.libs.package}/lib \
|
install -D tcc-musl $out/bin/tcc
|
||||||
-DC2STR \
|
install -Dm444 libtcc1.a $out/lib/libtcc1.a
|
||||||
-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
|
||||||
|
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,10 @@ in
|
||||||
platforms = lib.options.create {
|
platforms = lib.options.create {
|
||||||
type = lib.types.list.of lib.types.string;
|
type = lib.types.list.of lib.types.string;
|
||||||
description = "Platforms the package supports.";
|
description = "Platforms the package supports.";
|
||||||
default.value = [ "i686-linux" ];
|
default.value = [
|
||||||
|
"x86_64-linux"
|
||||||
|
"i686-linux"
|
||||||
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,10 @@ in
|
||||||
platforms = lib.options.create {
|
platforms = lib.options.create {
|
||||||
type = lib.types.list.of lib.types.string;
|
type = lib.types.list.of lib.types.string;
|
||||||
description = "Platforms the package supports.";
|
description = "Platforms the package supports.";
|
||||||
default.value = [ "i686-linux" ];
|
default.value = [
|
||||||
|
"x86_64-linux"
|
||||||
|
"i686-linux"
|
||||||
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,10 @@ in
|
||||||
platforms = lib.options.create {
|
platforms = lib.options.create {
|
||||||
type = lib.types.list.of lib.types.string;
|
type = lib.types.list.of lib.types.string;
|
||||||
description = "Platforms the package supports.";
|
description = "Platforms the package supports.";
|
||||||
default.value = [ "i686-linux" ];
|
default.value = [
|
||||||
|
"x86_64-linux"
|
||||||
|
"i686-linux"
|
||||||
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
mainProgram = lib.options.create {
|
mainProgram = lib.options.create {
|
||||||
|
|
|
@ -32,7 +32,10 @@ in
|
||||||
platforms = lib.options.create {
|
platforms = lib.options.create {
|
||||||
type = lib.types.list.of lib.types.string;
|
type = lib.types.list.of lib.types.string;
|
||||||
description = "Platforms the package supports.";
|
description = "Platforms the package supports.";
|
||||||
default.value = [ "i686-linux" ];
|
default.value = [
|
||||||
|
"x86_64-linux"
|
||||||
|
"i686-linux"
|
||||||
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
{ lib, config }:
|
{
|
||||||
let
|
lib,
|
||||||
|
config,
|
||||||
|
}: let
|
||||||
cfg = config.aux.foundation.stages.stage2.busybox;
|
cfg = config.aux.foundation.stages.stage2.busybox;
|
||||||
|
|
||||||
platform = config.aux.platform;
|
platform = config.aux.platform;
|
||||||
|
@ -7,8 +9,7 @@ let
|
||||||
|
|
||||||
stage1 = config.aux.foundation.stages.stage1;
|
stage1 = config.aux.foundation.stages.stage1;
|
||||||
stage2 = config.aux.foundation.stages.stage2;
|
stage2 = config.aux.foundation.stages.stage2;
|
||||||
in
|
in {
|
||||||
{
|
|
||||||
options.aux.foundation.stages.stage2.busybox = {
|
options.aux.foundation.stages.stage2.busybox = {
|
||||||
meta = {
|
meta = {
|
||||||
description = lib.options.create {
|
description = lib.options.create {
|
||||||
|
@ -33,7 +34,10 @@ in
|
||||||
platforms = lib.options.create {
|
platforms = lib.options.create {
|
||||||
type = lib.types.list.of lib.types.string;
|
type = lib.types.list.of lib.types.string;
|
||||||
description = "Platforms the package supports.";
|
description = "Platforms the package supports.";
|
||||||
default.value = [ "i686-linux" ];
|
default.value = [
|
||||||
|
"x86_64-linux"
|
||||||
|
"i686-linux"
|
||||||
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -62,19 +66,18 @@ in
|
||||||
sha256 = "uMwkyVdNgJ5yecO+NJeVxdXOtv3xnKcJ+AzeUOR94xQ=";
|
sha256 = "uMwkyVdNgJ5yecO+NJeVxdXOtv3xnKcJ+AzeUOR94xQ=";
|
||||||
};
|
};
|
||||||
|
|
||||||
package =
|
package = let
|
||||||
let
|
patches = [./patches/busybox-in-store.patch];
|
||||||
patches = [ ./patches/busybox-in-store.patch ];
|
|
||||||
|
|
||||||
busyboxConfig = [
|
busyboxConfig = [
|
||||||
"CC=musl-gcc"
|
"CC=musl-gcc"
|
||||||
"HOSTCC=musl-gcc"
|
"HOSTCC=musl-gcc"
|
||||||
"CFLAGS=-I${stage1.linux-headers.package}/include"
|
"CFLAGS=-I${stage1.linux-headers.package}/include"
|
||||||
"KCONFIG_NOTIMESTAMP=y"
|
"KCONFIG_NOTIMESTAMP=y"
|
||||||
"CONFIG_PREFIX=${builtins.placeholder "out"}"
|
"CONFIG_PREFIX=${builtins.placeholder "out"}"
|
||||||
"CONFIG_STATIC=y"
|
"CONFIG_STATIC=y"
|
||||||
];
|
];
|
||||||
in
|
in
|
||||||
builders.bash.build {
|
builders.bash.build {
|
||||||
name = "busybox-static-${cfg.version}";
|
name = "busybox-static-${cfg.version}";
|
||||||
meta = cfg.meta;
|
meta = cfg.meta;
|
||||||
|
|
|
@ -1,13 +1,14 @@
|
||||||
{ lib, config }:
|
{
|
||||||
let
|
lib,
|
||||||
|
config,
|
||||||
|
}: let
|
||||||
cfg = config.aux.foundation.stages.stage2.bzip2;
|
cfg = config.aux.foundation.stages.stage2.bzip2;
|
||||||
|
|
||||||
platform = config.aux.platform;
|
platform = config.aux.platform;
|
||||||
builders = config.aux.foundation.builders;
|
builders = config.aux.foundation.builders;
|
||||||
|
|
||||||
stage1 = config.aux.foundation.stages.stage1;
|
stage1 = config.aux.foundation.stages.stage1;
|
||||||
in
|
in {
|
||||||
{
|
|
||||||
options.aux.foundation.stages.stage2.bzip2 = {
|
options.aux.foundation.stages.stage2.bzip2 = {
|
||||||
meta = {
|
meta = {
|
||||||
description = lib.options.create {
|
description = lib.options.create {
|
||||||
|
@ -33,7 +34,10 @@ in
|
||||||
type = lib.types.list.of lib.types.string;
|
type = lib.types.list.of lib.types.string;
|
||||||
description = "Platforms the package supports.";
|
description = "Platforms the package supports.";
|
||||||
# TODO: Support more platforms.
|
# TODO: Support more platforms.
|
||||||
default.value = [ "i686-linux" ];
|
default.value = [
|
||||||
|
"x86_64-linux"
|
||||||
|
"i686-linux"
|
||||||
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,10 @@ in
|
||||||
platforms = lib.options.create {
|
platforms = lib.options.create {
|
||||||
type = lib.types.list.of lib.types.string;
|
type = lib.types.list.of lib.types.string;
|
||||||
description = "Platforms the package supports.";
|
description = "Platforms the package supports.";
|
||||||
default.value = [ "i686-linux" ];
|
default.value = [
|
||||||
|
"x86_64-linux"
|
||||||
|
"i686-linux"
|
||||||
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
{ lib, config }:
|
|
||||||
let
|
|
||||||
stage2 = config.aux.foundation.stages.stage2;
|
|
||||||
in
|
|
||||||
{
|
{
|
||||||
|
lib,
|
||||||
|
config,
|
||||||
|
}: let
|
||||||
|
stage2 = config.aux.foundation.stages.stage2;
|
||||||
|
in {
|
||||||
includes = [
|
includes = [
|
||||||
./bash
|
./bash
|
||||||
./binutils
|
./binutils
|
||||||
|
|
|
@ -32,7 +32,10 @@ in
|
||||||
platforms = lib.options.create {
|
platforms = lib.options.create {
|
||||||
type = lib.types.list.of lib.types.string;
|
type = lib.types.list.of lib.types.string;
|
||||||
description = "Platforms the package supports.";
|
description = "Platforms the package supports.";
|
||||||
default.value = [ "i686-linux" ];
|
default.value = [
|
||||||
|
"x86_64-linux"
|
||||||
|
"i686-linux"
|
||||||
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,10 @@ in
|
||||||
platforms = lib.options.create {
|
platforms = lib.options.create {
|
||||||
type = lib.types.list.of lib.types.string;
|
type = lib.types.list.of lib.types.string;
|
||||||
description = "Platforms the package supports.";
|
description = "Platforms the package supports.";
|
||||||
default.value = [ "i686-linux" ];
|
default.value = [
|
||||||
|
"x86_64-linux"
|
||||||
|
"i686-linux"
|
||||||
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,10 @@ in
|
||||||
platforms = lib.options.create {
|
platforms = lib.options.create {
|
||||||
type = lib.types.list.of lib.types.string;
|
type = lib.types.list.of lib.types.string;
|
||||||
description = "Platforms the package supports.";
|
description = "Platforms the package supports.";
|
||||||
default.value = [ "i686-linux" ];
|
default.value = [
|
||||||
|
"x86_64-linux"
|
||||||
|
"i686-linux"
|
||||||
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
mainProgram = lib.options.create {
|
mainProgram = lib.options.create {
|
||||||
|
|
|
@ -32,7 +32,10 @@ in
|
||||||
platforms = lib.options.create {
|
platforms = lib.options.create {
|
||||||
type = lib.types.list.of lib.types.string;
|
type = lib.types.list.of lib.types.string;
|
||||||
description = "Platforms the package supports.";
|
description = "Platforms the package supports.";
|
||||||
default.value = [ "i686-linux" ];
|
default.value = [
|
||||||
|
"x86_64-linux"
|
||||||
|
"i686-linux"
|
||||||
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,10 @@ in
|
||||||
platforms = lib.options.create {
|
platforms = lib.options.create {
|
||||||
type = lib.types.list.of lib.types.string;
|
type = lib.types.list.of lib.types.string;
|
||||||
description = "Platforms the package supports.";
|
description = "Platforms the package supports.";
|
||||||
default.value = [ "i686-linux" ];
|
default.value = [
|
||||||
|
"x86_64-linux"
|
||||||
|
"i686-linux"
|
||||||
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,10 @@ in
|
||||||
platforms = lib.options.create {
|
platforms = lib.options.create {
|
||||||
type = lib.types.list.of lib.types.string;
|
type = lib.types.list.of lib.types.string;
|
||||||
description = "Platforms the package supports.";
|
description = "Platforms the package supports.";
|
||||||
default.value = [ "i686-linux" ];
|
default.value = [
|
||||||
|
"x86_64-linux"
|
||||||
|
"i686-linux"
|
||||||
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
mainProgram = lib.options.create {
|
mainProgram = lib.options.create {
|
||||||
|
|
|
@ -33,7 +33,10 @@ in
|
||||||
platforms = lib.options.create {
|
platforms = lib.options.create {
|
||||||
type = lib.types.list.of lib.types.string;
|
type = lib.types.list.of lib.types.string;
|
||||||
description = "Platforms the package supports.";
|
description = "Platforms the package supports.";
|
||||||
default.value = [ "i686-linux" ];
|
default.value = [
|
||||||
|
"x86_64-linux"
|
||||||
|
"i686-linux"
|
||||||
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,10 @@ in
|
||||||
platforms = lib.options.create {
|
platforms = lib.options.create {
|
||||||
type = lib.types.list.of lib.types.string;
|
type = lib.types.list.of lib.types.string;
|
||||||
description = "Platforms the package supports.";
|
description = "Platforms the package supports.";
|
||||||
default.value = [ "i686-linux" ];
|
default.value = [
|
||||||
|
"x86_64-linux"
|
||||||
|
"i686-linux"
|
||||||
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,10 @@ in
|
||||||
platforms = lib.options.create {
|
platforms = lib.options.create {
|
||||||
type = lib.types.list.of lib.types.string;
|
type = lib.types.list.of lib.types.string;
|
||||||
description = "Platforms the package supports.";
|
description = "Platforms the package supports.";
|
||||||
default.value = [ "i686-linux" ];
|
default.value = [
|
||||||
|
"x86_64-linux"
|
||||||
|
"i686-linux"
|
||||||
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
mainProgram = lib.options.create {
|
mainProgram = lib.options.create {
|
||||||
|
|
|
@ -32,7 +32,10 @@ in
|
||||||
platforms = lib.options.create {
|
platforms = lib.options.create {
|
||||||
type = lib.types.list.of lib.types.string;
|
type = lib.types.list.of lib.types.string;
|
||||||
description = "Platforms the package supports.";
|
description = "Platforms the package supports.";
|
||||||
default.value = [ "i686-linux" ];
|
default.value = [
|
||||||
|
"x86_64-linux"
|
||||||
|
"i686-linux"
|
||||||
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
mainProgram = lib.options.create {
|
mainProgram = lib.options.create {
|
||||||
|
|
|
@ -32,7 +32,10 @@ in
|
||||||
platforms = lib.options.create {
|
platforms = lib.options.create {
|
||||||
type = lib.types.list.of lib.types.string;
|
type = lib.types.list.of lib.types.string;
|
||||||
description = "Platforms the package supports.";
|
description = "Platforms the package supports.";
|
||||||
default.value = [ "i686-linux" ];
|
default.value = [
|
||||||
|
"x86_64-linux"
|
||||||
|
"i686-linux"
|
||||||
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,10 @@ in
|
||||||
platforms = lib.options.create {
|
platforms = lib.options.create {
|
||||||
type = lib.types.list.of lib.types.string;
|
type = lib.types.list.of lib.types.string;
|
||||||
description = "Platforms the package supports.";
|
description = "Platforms the package supports.";
|
||||||
default.value = [ "i686-linux" ];
|
default.value = [
|
||||||
|
"x86_64-linux"
|
||||||
|
"i686-linux"
|
||||||
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
{ lib }:
|
{lib}: {
|
||||||
{
|
|
||||||
options.aux = {
|
options.aux = {
|
||||||
system = lib.options.create {
|
system = lib.options.create {
|
||||||
type = lib.types.string;
|
type = lib.types.string;
|
||||||
|
|
|
@ -25,51 +25,54 @@ let
|
||||||
./src/versions/default.test.nix
|
./src/versions/default.test.nix
|
||||||
];
|
];
|
||||||
|
|
||||||
resolve =
|
resolve = file: let
|
||||||
file:
|
imported = import file;
|
||||||
let
|
value =
|
||||||
imported = import file;
|
if builtins.isFunction imported
|
||||||
value = if builtins.isFunction imported then imported { inherit lib; } else imported;
|
then imported {inherit lib;}
|
||||||
relative = lib.strings.removePrefix (builtins.toString root) (builtins.toString file);
|
else imported;
|
||||||
in
|
relative = lib.strings.removePrefix (builtins.toString root) (builtins.toString file);
|
||||||
{
|
in {
|
||||||
inherit file value;
|
inherit file value;
|
||||||
relative = if lib.strings.hasPrefix "/" relative then "." + relative else relative;
|
relative =
|
||||||
namespace = getNamespace file;
|
if lib.strings.hasPrefix "/" relative
|
||||||
};
|
then "." + relative
|
||||||
|
else relative;
|
||||||
|
namespace = getNamespace file;
|
||||||
|
};
|
||||||
|
|
||||||
resolved = builtins.map resolve files;
|
resolved = builtins.map resolve files;
|
||||||
|
|
||||||
getNamespace =
|
getNamespace = path: let
|
||||||
path:
|
relative = lib.strings.removePrefix (builtins.toString root) (builtins.toString path);
|
||||||
let
|
parts = lib.strings.split "/" relative;
|
||||||
relative = lib.strings.removePrefix (builtins.toString root) (builtins.toString path);
|
in
|
||||||
parts = lib.strings.split "/" relative;
|
if builtins.length parts > 2
|
||||||
in
|
then builtins.elemAt parts 2
|
||||||
if builtins.length parts > 2 then builtins.elemAt parts 2 else relative;
|
else relative;
|
||||||
|
|
||||||
results =
|
results = let
|
||||||
let
|
getTests = file: prefix: suite: let
|
||||||
getTests =
|
nested = lib.attrs.mapToList (name: value: getTests file (prefix ++ [name]) value) suite;
|
||||||
file: prefix: suite:
|
relative = lib.strings.removePrefix (builtins.toString root) (builtins.toString file);
|
||||||
let
|
|
||||||
nested = lib.attrs.mapToList (name: value: getTests file (prefix ++ [ name ]) value) suite;
|
|
||||||
relative = lib.strings.removePrefix (builtins.toString root) (builtins.toString file);
|
|
||||||
in
|
|
||||||
if builtins.isAttrs suite then
|
|
||||||
builtins.concatLists nested
|
|
||||||
else
|
|
||||||
[
|
|
||||||
{
|
|
||||||
inherit prefix file;
|
|
||||||
name = builtins.concatStringsSep " > " prefix;
|
|
||||||
value = suite;
|
|
||||||
relative = if lib.strings.hasPrefix "/" relative then "." + relative else relative;
|
|
||||||
}
|
|
||||||
];
|
|
||||||
|
|
||||||
base = builtins.map (entry: getTests entry.file [ entry.namespace ] entry.value) resolved;
|
|
||||||
in
|
in
|
||||||
|
if builtins.isAttrs suite
|
||||||
|
then builtins.concatLists nested
|
||||||
|
else [
|
||||||
|
{
|
||||||
|
inherit prefix file;
|
||||||
|
name = builtins.concatStringsSep " > " prefix;
|
||||||
|
value = suite;
|
||||||
|
relative =
|
||||||
|
if lib.strings.hasPrefix "/" relative
|
||||||
|
then "." + relative
|
||||||
|
else relative;
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
base =
|
||||||
|
builtins.map (entry: getTests entry.file [entry.namespace] entry.value) resolved;
|
||||||
|
in
|
||||||
builtins.concatLists base;
|
builtins.concatLists base;
|
||||||
|
|
||||||
successes = builtins.filter (test: test.value) results;
|
successes = builtins.filter (test: test.value) results;
|
||||||
|
@ -77,23 +80,29 @@ let
|
||||||
|
|
||||||
total = "${builtins.toString (builtins.length successes)} / ${builtins.toString (builtins.length results)}";
|
total = "${builtins.toString (builtins.length successes)} / ${builtins.toString (builtins.length results)}";
|
||||||
in
|
in
|
||||||
if failures == [ ] then
|
if failures == []
|
||||||
let
|
then let
|
||||||
message = lib.strings.concatMapSep "\n" (test: "✅ ${test.name}") successes;
|
message =
|
||||||
in
|
lib.strings.concatMapSep "\n"
|
||||||
''
|
(test: "✅ ${test.name}")
|
||||||
|
successes;
|
||||||
|
in ''
|
||||||
SUCCESS (${total})
|
SUCCESS (${total})
|
||||||
|
|
||||||
${message}
|
${message}
|
||||||
''
|
''
|
||||||
else
|
else let
|
||||||
let
|
successMessage =
|
||||||
successMessage = lib.strings.concatMapSep "\n" (test: "✅ ${test.name}") successes;
|
lib.strings.concatMapSep "\n"
|
||||||
failureMessage = lib.strings.concatMapSep "\n\n" (
|
(test: "✅ ${test.name}")
|
||||||
test: "❎ ${test.name}\n" + " -> ${test.relative}"
|
successes;
|
||||||
) failures;
|
failureMessage =
|
||||||
in
|
lib.strings.concatMapSep "\n\n"
|
||||||
''
|
(test:
|
||||||
|
"❎ ${test.name}\n"
|
||||||
|
+ " -> ${test.relative}")
|
||||||
|
failures;
|
||||||
|
in ''
|
||||||
FAILURE (${total})
|
FAILURE (${total})
|
||||||
|
|
||||||
${failureMessage}
|
${failureMessage}
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
{
|
{
|
||||||
description = "A NixPkgs library replacement containing helper functions and a module system.";
|
description = "A NixPkgs library replacement containing helper functions and a module system.";
|
||||||
|
|
||||||
outputs = _: { lib = import ./src; };
|
outputs = _: {
|
||||||
|
lib = import ./src;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,205 +10,185 @@ lib: {
|
||||||
## from `y` first if it exists and then `x` otherwise.
|
## from `y` first if it exists and then `x` otherwise.
|
||||||
##
|
##
|
||||||
## @type Attrs a b c => (String -> Any -> Any -> Bool) -> a -> b -> c
|
## @type Attrs a b c => (String -> Any -> Any -> Bool) -> a -> b -> c
|
||||||
mergeRecursiveUntil =
|
mergeRecursiveUntil = predicate: x: y: let
|
||||||
predicate: x: y:
|
process = path:
|
||||||
let
|
builtins.zipAttrsWith (
|
||||||
process =
|
name: values: let
|
||||||
path:
|
currentPath = path ++ [name];
|
||||||
builtins.zipAttrsWith (
|
isSingleValue = builtins.length values == 1;
|
||||||
name: values:
|
isComplete =
|
||||||
let
|
predicate currentPath
|
||||||
currentPath = path ++ [ name ];
|
(builtins.elemAt values 1)
|
||||||
isSingleValue = builtins.length values == 1;
|
(builtins.elemAt values 0);
|
||||||
isComplete = predicate currentPath (builtins.elemAt values 1) (builtins.elemAt values 0);
|
in
|
||||||
in
|
if isSingleValue
|
||||||
if isSingleValue then
|
then builtins.elemAt values 0
|
||||||
builtins.elemAt values 0
|
else if isComplete
|
||||||
else if isComplete then
|
then builtins.elemAt values 1
|
||||||
builtins.elemAt values 1
|
else process currentPath values
|
||||||
else
|
);
|
||||||
process currentPath values
|
in
|
||||||
);
|
process [] [x y];
|
||||||
in
|
|
||||||
process [ ] [
|
|
||||||
x
|
|
||||||
y
|
|
||||||
];
|
|
||||||
|
|
||||||
## Merge two attribute sets recursively. Any values that are _not_ attribute sets
|
## Merge two attribute sets recursively. Any values that are _not_ attribute sets
|
||||||
## will be overridden with the value from `y` first if it exists and then `x`
|
## will be overridden with the value from `y` first if it exists and then `x`
|
||||||
## otherwise.
|
## otherwise.
|
||||||
##
|
##
|
||||||
## @type Attrs a b c => a -> b -> c
|
## @type Attrs a b c => a -> b -> c
|
||||||
mergeRecursive = lib.attrs.mergeRecursiveUntil (
|
mergeRecursive =
|
||||||
path: x: y:
|
lib.attrs.mergeRecursiveUntil
|
||||||
!(builtins.isAttrs x && builtins.isAttrs y)
|
(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,
|
## Get a value from an attribute set by a path. If the path does not exist,
|
||||||
## a fallback value will be returned instead.
|
## a fallback value will be returned instead.
|
||||||
##
|
##
|
||||||
## @type (List String) -> a -> Attrs -> a | b
|
## @type (List String) -> a -> Attrs -> a | b
|
||||||
select =
|
select = path: fallback: target: let
|
||||||
path: fallback: target:
|
name = builtins.head path;
|
||||||
let
|
rest = builtins.tail path;
|
||||||
name = builtins.head path;
|
in
|
||||||
rest = builtins.tail path;
|
if path == []
|
||||||
in
|
then target
|
||||||
if path == [ ] then
|
else if target ? ${name}
|
||||||
target
|
then lib.attrs.select rest fallback target.${name}
|
||||||
else if target ? ${name} then
|
else fallback;
|
||||||
lib.attrs.select rest fallback target.${name}
|
|
||||||
else
|
|
||||||
fallback;
|
|
||||||
|
|
||||||
## Get a value from an attribute set by a path. If the path does not exist,
|
## Get a value from an attribute set by a path. If the path does not exist,
|
||||||
## an error will be thrown.
|
## an error will be thrown.
|
||||||
##
|
##
|
||||||
## @type (List String) -> Attrs -> a
|
## @type (List String) -> Attrs -> a
|
||||||
selectOrThrow =
|
selectOrThrow = path: target: let
|
||||||
path: target:
|
pathAsString = builtins.concatStringsSep "." path;
|
||||||
let
|
error = builtins.throw "Path not found in attribute set: ${pathAsString}";
|
||||||
pathAsString = builtins.concatStringsSep "." path;
|
in
|
||||||
error = builtins.throw "Path not found in attribute set: ${pathAsString}";
|
if lib.attrs.has path target
|
||||||
in
|
then lib.attrs.select path null target
|
||||||
if lib.attrs.has path target then lib.attrs.select path null target else error;
|
else error;
|
||||||
|
|
||||||
## Zip specific attributes from a list of attribute sets.
|
## Zip specific attributes from a list of attribute sets.
|
||||||
##
|
##
|
||||||
## @type List String -> (List Any -> Any) -> List Attrs -> Attrs
|
## @type List String -> (List Any -> Any) -> List Attrs -> Attrs
|
||||||
zipWithNames =
|
zipWithNames = names: f: list: let
|
||||||
names: f: list:
|
transform = name: {
|
||||||
let
|
inherit name;
|
||||||
transform = name: {
|
value = f name (builtins.catAttrs name list);
|
||||||
inherit name;
|
};
|
||||||
value = f name (builtins.catAttrs name list);
|
results = builtins.map transform names;
|
||||||
};
|
in
|
||||||
results = builtins.map transform names;
|
|
||||||
in
|
|
||||||
builtins.listToAttrs results;
|
builtins.listToAttrs results;
|
||||||
|
|
||||||
## Match an attribute set against a pattern.
|
## Match an attribute set against a pattern.
|
||||||
##
|
##
|
||||||
## @type Attrs -> Attrs -> Bool
|
## @type Attrs -> Attrs -> Bool
|
||||||
match =
|
match = pattern: value: let
|
||||||
pattern: value:
|
process = name: values: let
|
||||||
let
|
first = builtins.elemAt values 0;
|
||||||
process =
|
second = builtins.elemAt values 1;
|
||||||
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
|
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
|
||||||
assert lib.errors.trace (builtins.isAttrs pattern) "Pattern must be an attribute set";
|
assert lib.errors.trace (builtins.isAttrs pattern) "Pattern must be an attribute set";
|
||||||
assert lib.errors.trace (builtins.isAttrs value) "Value must be an attribute set";
|
assert lib.errors.trace (builtins.isAttrs value) "Value must be an attribute set";
|
||||||
builtins.all lib.fp.id (builtins.attrValues result);
|
builtins.all lib.fp.id (builtins.attrValues result);
|
||||||
|
|
||||||
## Create a nested attribute set with a value as the leaf node.
|
## Create a nested attribute set with a value as the leaf node.
|
||||||
##
|
##
|
||||||
## @type (List String) -> a -> Attrs
|
## @type (List String) -> a -> Attrs
|
||||||
set =
|
set = path: value: let
|
||||||
path: value:
|
length = builtins.length path;
|
||||||
let
|
process = depth:
|
||||||
length = builtins.length path;
|
if depth == length
|
||||||
process =
|
then value
|
||||||
depth: if depth == length then value else { ${builtins.elemAt path depth} = process (depth + 1); };
|
else {
|
||||||
in
|
${builtins.elemAt path depth} = process (depth + 1);
|
||||||
|
};
|
||||||
|
in
|
||||||
process 0;
|
process 0;
|
||||||
|
|
||||||
## Check if a path exists in an attribute set.
|
## Check if a path exists in an attribute set.
|
||||||
##
|
##
|
||||||
## @type (List String) -> Attrs -> Bool
|
## @type (List String) -> Attrs -> Bool
|
||||||
has =
|
has = path: target: let
|
||||||
path: target:
|
name = builtins.head path;
|
||||||
let
|
rest = builtins.tail path;
|
||||||
name = builtins.head path;
|
in
|
||||||
rest = builtins.tail path;
|
if path == []
|
||||||
in
|
then true
|
||||||
if path == [ ] then
|
else if target ? ${name}
|
||||||
true
|
then lib.attrs.has rest target.${name}
|
||||||
else if target ? ${name} then
|
else false;
|
||||||
lib.attrs.has rest target.${name}
|
|
||||||
else
|
|
||||||
false;
|
|
||||||
|
|
||||||
## Depending on a given condition, either use the given value or an empty
|
## Depending on a given condition, either use the given value or an empty
|
||||||
## attribute set.
|
## attribute set.
|
||||||
##
|
##
|
||||||
## @type Attrs a b => Bool -> a -> a | b
|
## @type Attrs a b => Bool -> a -> a | b
|
||||||
when = condition: value: if condition then value else { };
|
when = condition: value:
|
||||||
|
if condition
|
||||||
|
then value
|
||||||
|
else {};
|
||||||
|
|
||||||
## Map an attribute set's names and values to a list.
|
## Map an attribute set's names and values to a list.
|
||||||
##
|
##
|
||||||
## @type Any a => (String -> Any -> a) -> Attrs -> List a
|
## @type Any a => (String -> Any -> a) -> Attrs -> List a
|
||||||
mapToList = f: target: 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.
|
## Map an attribute set recursively. Only non-set leaf nodes will be mapped.
|
||||||
##
|
##
|
||||||
## @type (List String -> Any -> Any) -> Attrs -> Attrs
|
## @type (List String -> Any -> Any) -> Attrs -> Attrs
|
||||||
mapRecursive = f: target: 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.
|
## Map an attribute set recursively when a given predicate returns true.
|
||||||
## Only leaf nodes according to the predicate will be mapped.
|
## Only leaf nodes according to the predicate will be mapped.
|
||||||
##
|
##
|
||||||
## @type (Attrs -> Bool) -> (List String -> Any -> Any) -> Attrs -> Attrs
|
## @type (Attrs -> Bool) -> (List String -> Any -> Any) -> Attrs -> Attrs
|
||||||
mapRecursiveWhen =
|
mapRecursiveWhen = predicate: f: target: let
|
||||||
predicate: f: target:
|
process = path:
|
||||||
let
|
builtins.mapAttrs (
|
||||||
process =
|
name: value:
|
||||||
path:
|
if builtins.isAttrs value && predicate value
|
||||||
builtins.mapAttrs (
|
then process (path ++ [name]) value
|
||||||
name: value:
|
else f (path ++ [name]) value
|
||||||
if builtins.isAttrs value && predicate value then
|
);
|
||||||
process (path ++ [ name ]) value
|
in
|
||||||
else
|
process [] target;
|
||||||
f (path ++ [ name ]) value
|
|
||||||
);
|
|
||||||
in
|
|
||||||
process [ ] target;
|
|
||||||
|
|
||||||
## Filter an attribute set by a given predicate. The filter is only performed
|
## Filter an attribute set by a given predicate. The filter is only performed
|
||||||
## on the base level of the attribute set.
|
## on the base level of the attribute set.
|
||||||
##
|
##
|
||||||
## @type (String -> Any -> Bool) -> Attrs -> Attrs
|
## @type (String -> Any -> Bool) -> Attrs -> Attrs
|
||||||
filter =
|
filter = predicate: target: let
|
||||||
predicate: target:
|
names = builtins.attrNames target;
|
||||||
let
|
process = name: let
|
||||||
names = builtins.attrNames target;
|
value = target.${name};
|
||||||
process =
|
|
||||||
name:
|
|
||||||
let
|
|
||||||
value = target.${name};
|
|
||||||
in
|
|
||||||
if predicate name value then [ { inherit name value; } ] else [ ];
|
|
||||||
valid = builtins.concatMap process names;
|
|
||||||
in
|
in
|
||||||
|
if predicate name value
|
||||||
|
then [{inherit name value;}]
|
||||||
|
else [];
|
||||||
|
valid = builtins.concatMap process names;
|
||||||
|
in
|
||||||
builtins.listToAttrs valid;
|
builtins.listToAttrs valid;
|
||||||
|
|
||||||
## Generate an attribute set from a list of names and a function that is
|
## Generate an attribute set from a list of names and a function that is
|
||||||
## applied to each name.
|
## applied to each name.
|
||||||
##
|
##
|
||||||
## @type (List String) -> (String -> Any) -> Attrs
|
## @type (List String) -> (String -> Any) -> Attrs
|
||||||
generate =
|
generate = names: f: let
|
||||||
names: f:
|
pairs =
|
||||||
let
|
builtins.map (name: {
|
||||||
pairs = builtins.map (name: {
|
|
||||||
inherit name;
|
inherit name;
|
||||||
value = f name;
|
value = f name;
|
||||||
}) names;
|
})
|
||||||
in
|
names;
|
||||||
|
in
|
||||||
builtins.listToAttrs pairs;
|
builtins.listToAttrs pairs;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,342 +1,329 @@
|
||||||
let
|
let
|
||||||
lib = import ./../default.nix;
|
lib = import ./../default.nix;
|
||||||
in
|
in {
|
||||||
{
|
|
||||||
"merge" = {
|
"merge" = {
|
||||||
"merges two shallow sets" =
|
"merges two shallow sets" = let
|
||||||
let
|
expected = {
|
||||||
expected = {
|
x = 1;
|
||||||
x = 1;
|
y = 2;
|
||||||
y = 2;
|
};
|
||||||
};
|
|
||||||
|
|
||||||
actual = lib.attrs.merge { x = 1; } { y = 2; };
|
actual = lib.attrs.merge {x = 1;} {y = 2;};
|
||||||
in
|
in
|
||||||
expected == actual;
|
expected == actual;
|
||||||
|
|
||||||
"overwrites values from the first set" =
|
"overwrites values from the first set" = let
|
||||||
let
|
expected = {
|
||||||
expected = {
|
x = 2;
|
||||||
x = 2;
|
};
|
||||||
};
|
actual = lib.attrs.merge {x = 1;} {x = 2;};
|
||||||
actual = lib.attrs.merge { x = 1; } { x = 2; };
|
in
|
||||||
in
|
|
||||||
actual == expected;
|
actual == expected;
|
||||||
|
|
||||||
"does not merge nested sets" =
|
"does not merge nested sets" = let
|
||||||
let
|
expected = {
|
||||||
expected = {
|
x.y = 2;
|
||||||
x.y = 2;
|
};
|
||||||
};
|
actual = lib.attrs.merge {x.z = 1;} {x.y = 2;};
|
||||||
actual = lib.attrs.merge { x.z = 1; } { x.y = 2; };
|
in
|
||||||
in
|
|
||||||
actual == expected;
|
actual == expected;
|
||||||
};
|
};
|
||||||
|
|
||||||
"mergeRecursiveUntil" = {
|
"mergeRecursiveUntil" = {
|
||||||
"merges with predicate" =
|
"merges with predicate" = let
|
||||||
let
|
expected = {
|
||||||
expected = {
|
x.y.z = 1;
|
||||||
x.y.z = 1;
|
};
|
||||||
};
|
actual =
|
||||||
actual = lib.attrs.mergeRecursiveUntil (
|
lib.attrs.mergeRecursiveUntil
|
||||||
path: x: y:
|
(path: x: y: lib.lists.last path == "z")
|
||||||
lib.lists.last path == "z"
|
{x.y.z = 2;}
|
||||||
) { x.y.z = 2; } { x.y.z = 1; };
|
{x.y.z = 1;};
|
||||||
in
|
in
|
||||||
actual == expected;
|
actual == expected;
|
||||||
|
|
||||||
"handles shallow merges" =
|
"handles shallow merges" = let
|
||||||
let
|
expected = {
|
||||||
expected = {
|
x.y.z = 1;
|
||||||
x.y.z = 1;
|
};
|
||||||
};
|
actual =
|
||||||
actual =
|
lib.attrs.mergeRecursiveUntil
|
||||||
lib.attrs.mergeRecursiveUntil
|
(path: x: y: true)
|
||||||
(
|
{
|
||||||
path: x: y:
|
x = {
|
||||||
true
|
y.z = 2;
|
||||||
)
|
|
||||||
{
|
|
||||||
x = {
|
|
||||||
y.z = 2;
|
|
||||||
|
|
||||||
a = false;
|
a = false;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
{ x.y.z = 1; };
|
{x.y.z = 1;};
|
||||||
in
|
in
|
||||||
actual == expected;
|
actual == expected;
|
||||||
};
|
};
|
||||||
|
|
||||||
"mergeRecursive" = {
|
"mergeRecursive" = {
|
||||||
"merges two sets deeply" =
|
"merges two sets deeply" = let
|
||||||
let
|
expected = {
|
||||||
expected = {
|
x.y.z = 1;
|
||||||
x.y.z = 1;
|
};
|
||||||
};
|
actual =
|
||||||
actual = lib.attrs.mergeRecursive { x.y.z = 2; } { x.y.z = 1; };
|
lib.attrs.mergeRecursive
|
||||||
in
|
{x.y.z = 2;}
|
||||||
|
{x.y.z = 1;};
|
||||||
|
in
|
||||||
actual == expected;
|
actual == expected;
|
||||||
};
|
};
|
||||||
|
|
||||||
"select" = {
|
"select" = {
|
||||||
"selects a nested value" =
|
"selects a nested value" = let
|
||||||
let
|
expected = "value";
|
||||||
expected = "value";
|
actual =
|
||||||
actual = lib.attrs.select [
|
lib.attrs.select
|
||||||
"x"
|
["x" "y" "z"]
|
||||||
"y"
|
null
|
||||||
"z"
|
{
|
||||||
] null { x.y.z = expected; };
|
x.y.z = expected;
|
||||||
in
|
};
|
||||||
|
in
|
||||||
actual == expected;
|
actual == expected;
|
||||||
|
|
||||||
"handles empty path" =
|
"handles empty path" = let
|
||||||
let
|
expected = {
|
||||||
expected = {
|
x = {
|
||||||
|
y = {
|
||||||
|
z = 1;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
actual =
|
||||||
|
lib.attrs.select
|
||||||
|
[]
|
||||||
|
null
|
||||||
|
{
|
||||||
x = {
|
x = {
|
||||||
y = {
|
y = {
|
||||||
z = 1;
|
z = 1;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
actual = lib.attrs.select [ ] null {
|
in
|
||||||
x = {
|
|
||||||
y = {
|
|
||||||
z = 1;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
in
|
|
||||||
actual == expected;
|
actual == expected;
|
||||||
|
|
||||||
"handles fallback value" =
|
"handles fallback value" = let
|
||||||
let
|
expected = "fallback";
|
||||||
expected = "fallback";
|
actual =
|
||||||
actual = lib.attrs.select [
|
lib.attrs.select
|
||||||
"x"
|
["x" "y" "z"]
|
||||||
"y"
|
expected
|
||||||
"z"
|
{};
|
||||||
] expected { };
|
in
|
||||||
in
|
|
||||||
actual == expected;
|
actual == expected;
|
||||||
};
|
};
|
||||||
|
|
||||||
"selectOrThrow" = {
|
"selectOrThrow" = {
|
||||||
"selects a nested value" =
|
"selects a nested value" = let
|
||||||
let
|
expected = "value";
|
||||||
expected = "value";
|
actual =
|
||||||
actual = lib.attrs.selectOrThrow [
|
lib.attrs.selectOrThrow
|
||||||
"x"
|
["x" "y" "z"]
|
||||||
"y"
|
{
|
||||||
"z"
|
x.y.z = expected;
|
||||||
] { x.y.z = expected; };
|
};
|
||||||
in
|
in
|
||||||
actual == expected;
|
actual == expected;
|
||||||
|
|
||||||
"handles empty path" =
|
"handles empty path" = let
|
||||||
let
|
expected = {
|
||||||
expected = {
|
x = {
|
||||||
|
y = {
|
||||||
|
z = 1;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
actual =
|
||||||
|
lib.attrs.selectOrThrow
|
||||||
|
[]
|
||||||
|
{
|
||||||
x = {
|
x = {
|
||||||
y = {
|
y = {
|
||||||
z = 1;
|
z = 1;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
actual = lib.attrs.selectOrThrow [ ] {
|
in
|
||||||
x = {
|
|
||||||
y = {
|
|
||||||
z = 1;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
in
|
|
||||||
actual == expected;
|
actual == expected;
|
||||||
|
|
||||||
"throws on nonexistent path" =
|
"throws on nonexistent path" = let
|
||||||
let
|
actual =
|
||||||
actual = lib.attrs.selectOrThrow [
|
lib.attrs.selectOrThrow
|
||||||
"x"
|
["x" "y" "z"]
|
||||||
"y"
|
{};
|
||||||
"z"
|
|
||||||
] { };
|
|
||||||
|
|
||||||
evaluated = builtins.tryEval (builtins.deepSeq actual actual);
|
evaluated = builtins.tryEval (builtins.deepSeq actual actual);
|
||||||
in
|
in
|
||||||
!evaluated.success;
|
!evaluated.success;
|
||||||
};
|
};
|
||||||
|
|
||||||
"set" = {
|
"set" = {
|
||||||
"creates a nested set" =
|
"creates a nested set" = let
|
||||||
let
|
expected = {
|
||||||
expected = {
|
x = {
|
||||||
x = {
|
y = {
|
||||||
y = {
|
z = 1;
|
||||||
z = 1;
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
actual = lib.attrs.set [
|
};
|
||||||
"x"
|
actual = lib.attrs.set ["x" "y" "z"] 1;
|
||||||
"y"
|
in
|
||||||
"z"
|
|
||||||
] 1;
|
|
||||||
in
|
|
||||||
actual == expected;
|
actual == expected;
|
||||||
|
|
||||||
"handles empty path" =
|
"handles empty path" = let
|
||||||
let
|
expected = 1;
|
||||||
expected = 1;
|
actual = lib.attrs.set [] 1;
|
||||||
actual = lib.attrs.set [ ] 1;
|
in
|
||||||
in
|
|
||||||
actual == expected;
|
actual == expected;
|
||||||
};
|
};
|
||||||
|
|
||||||
"has" = {
|
"has" = {
|
||||||
"returns true for a nested value" =
|
"returns true for a nested value" = let
|
||||||
let
|
exists = lib.attrs.has ["x" "y" "z"] {x.y.z = 1;};
|
||||||
exists = lib.attrs.has [
|
in
|
||||||
"x"
|
|
||||||
"y"
|
|
||||||
"z"
|
|
||||||
] { x.y.z = 1; };
|
|
||||||
in
|
|
||||||
exists;
|
exists;
|
||||||
|
|
||||||
"returns false for a nonexistent value" =
|
"returns false for a nonexistent value" = let
|
||||||
let
|
exists = lib.attrs.has ["x" "y" "z"] {};
|
||||||
exists = lib.attrs.has [
|
in
|
||||||
"x"
|
|
||||||
"y"
|
|
||||||
"z"
|
|
||||||
] { };
|
|
||||||
in
|
|
||||||
!exists;
|
!exists;
|
||||||
|
|
||||||
"handles empty path" =
|
"handles empty path" = let
|
||||||
let
|
exists = lib.attrs.has [] {};
|
||||||
exists = lib.attrs.has [ ] { };
|
in
|
||||||
in
|
|
||||||
exists;
|
exists;
|
||||||
};
|
};
|
||||||
|
|
||||||
"when" = {
|
"when" = {
|
||||||
"returns the value when condition is true" =
|
"returns the value when condition is true" = let
|
||||||
let
|
expected = "value";
|
||||||
expected = "value";
|
actual = lib.attrs.when true expected;
|
||||||
actual = lib.attrs.when true expected;
|
in
|
||||||
in
|
|
||||||
actual == expected;
|
actual == expected;
|
||||||
|
|
||||||
"returns an empty set when condition is false" =
|
"returns an empty set when condition is false" = let
|
||||||
let
|
expected = {};
|
||||||
expected = { };
|
actual = lib.attrs.when false "value";
|
||||||
actual = lib.attrs.when false "value";
|
in
|
||||||
in
|
|
||||||
actual == expected;
|
actual == expected;
|
||||||
};
|
};
|
||||||
|
|
||||||
"mapToList" = {
|
"mapToList" = {
|
||||||
"converts a set to a list" =
|
"converts a set to a list" = let
|
||||||
let
|
expected = [
|
||||||
expected = [
|
{
|
||||||
{
|
name = "x";
|
||||||
name = "x";
|
value = 1;
|
||||||
value = 1;
|
}
|
||||||
}
|
{
|
||||||
{
|
name = "y";
|
||||||
name = "y";
|
value = 2;
|
||||||
value = 2;
|
}
|
||||||
}
|
];
|
||||||
];
|
actual =
|
||||||
actual = lib.attrs.mapToList (name: value: { inherit name value; }) {
|
lib.attrs.mapToList
|
||||||
|
(name: value: {inherit name value;})
|
||||||
|
{
|
||||||
x = 1;
|
x = 1;
|
||||||
y = 2;
|
y = 2;
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
actual == expected;
|
actual == expected;
|
||||||
};
|
};
|
||||||
|
|
||||||
"mapRecursiveWhen" = {
|
"mapRecursiveWhen" = {
|
||||||
"maps a set recursively" =
|
"maps a set recursively" = let
|
||||||
let
|
expected = {
|
||||||
expected = {
|
x = {
|
||||||
x = {
|
y = {
|
||||||
y = {
|
z = 2;
|
||||||
z = 2;
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
actual = lib.attrs.mapRecursiveWhen (value: true) (path: value: value + 1) {
|
};
|
||||||
|
actual =
|
||||||
|
lib.attrs.mapRecursiveWhen
|
||||||
|
(value: true)
|
||||||
|
(path: value: value + 1)
|
||||||
|
{
|
||||||
x = {
|
x = {
|
||||||
y = {
|
y = {
|
||||||
z = 1;
|
z = 1;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
actual == expected;
|
actual == expected;
|
||||||
|
|
||||||
"maps a set given a condition" =
|
"maps a set given a condition" = let
|
||||||
let
|
expected = {
|
||||||
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)
|
||||||
|
{
|
||||||
x = {
|
x = {
|
||||||
y = {
|
y = {
|
||||||
z = 1;
|
z = 1;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
actual =
|
in
|
||||||
lib.attrs.mapRecursiveWhen (value: !(value ? z))
|
|
||||||
(
|
|
||||||
path: value:
|
|
||||||
# We map before we get to a non-set value
|
|
||||||
if builtins.isAttrs value then value else value + 1
|
|
||||||
)
|
|
||||||
{
|
|
||||||
x = {
|
|
||||||
y = {
|
|
||||||
z = 1;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
in
|
|
||||||
actual == expected;
|
actual == expected;
|
||||||
};
|
};
|
||||||
|
|
||||||
"mapRecursive" = {
|
"mapRecursive" = {
|
||||||
"maps a set recursively" =
|
"maps a set recursively" = let
|
||||||
let
|
expected = {
|
||||||
expected = {
|
x = {
|
||||||
x = {
|
y = {
|
||||||
y = {
|
z = 2;
|
||||||
z = 2;
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
actual = lib.attrs.mapRecursive (path: value: value + 1) {
|
};
|
||||||
|
actual =
|
||||||
|
lib.attrs.mapRecursive
|
||||||
|
(path: value: value + 1)
|
||||||
|
{
|
||||||
x = {
|
x = {
|
||||||
y = {
|
y = {
|
||||||
z = 1;
|
z = 1;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
actual == expected;
|
actual == expected;
|
||||||
};
|
};
|
||||||
|
|
||||||
"filter" = {
|
"filter" = {
|
||||||
"filters a set" =
|
"filters a set" = let
|
||||||
let
|
expected = {
|
||||||
expected = {
|
y = 2;
|
||||||
y = 2;
|
};
|
||||||
};
|
actual =
|
||||||
actual = lib.attrs.filter (name: value: name == "y") {
|
lib.attrs.filter
|
||||||
|
(name: value: name == "y")
|
||||||
|
{
|
||||||
x = 1;
|
x = 1;
|
||||||
y = 2;
|
y = 2;
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
actual == expected;
|
actual == expected;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,21 +4,28 @@ lib: {
|
||||||
## Convert a boolean value into a string.
|
## Convert a boolean value into a string.
|
||||||
##
|
##
|
||||||
## @type Bool -> 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".
|
## Convert a boolean into either the string "yes" or "no".
|
||||||
##
|
##
|
||||||
## @type Bool -> String
|
## @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
|
## Choose between two values based on a condition. When true, the first value
|
||||||
## is returned, otherwise the second value is returned.
|
## is returned, otherwise the second value is returned.
|
||||||
##
|
##
|
||||||
## @type Bool -> a -> b -> a | b
|
## @type Bool -> a -> b -> a | b
|
||||||
when =
|
when = condition: x: y:
|
||||||
condition: x: y:
|
if condition
|
||||||
if condition then x else y;
|
then x
|
||||||
|
else y;
|
||||||
|
|
||||||
## Perform a logical AND operation on two values.
|
## Perform a logical AND operation on two values.
|
||||||
##
|
##
|
||||||
|
@ -28,7 +35,9 @@ lib: {
|
||||||
## Perform a logical AND operation on two functions being applied to a value.
|
## Perform a logical AND operation on two functions being applied to a value.
|
||||||
##
|
##
|
||||||
## @type (a -> Bool) -> (a -> Bool) -> a -> Bool
|
## @type (a -> Bool) -> (a -> Bool) -> a -> Bool
|
||||||
and' = f: g: (x: (f x) && (g x));
|
and' = f: g: (
|
||||||
|
x: (f x) && (g x)
|
||||||
|
);
|
||||||
|
|
||||||
## Perform a logical OR operation on two values.
|
## Perform a logical OR operation on two values.
|
||||||
##
|
##
|
||||||
|
@ -38,7 +47,9 @@ lib: {
|
||||||
## Perform a logical OR operation on two functions being applied to a value.
|
## Perform a logical OR operation on two functions being applied to a value.
|
||||||
##
|
##
|
||||||
## @type (a -> Bool) -> (a -> Bool) -> a -> Bool
|
## @type (a -> Bool) -> (a -> Bool) -> a -> Bool
|
||||||
or' = f: g: (x: (f x) || (g x));
|
or' = f: g: (
|
||||||
|
x: (f x) || (g x)
|
||||||
|
);
|
||||||
|
|
||||||
## Perform a logical NOT operation on a value.
|
## Perform a logical NOT operation on a value.
|
||||||
##
|
##
|
||||||
|
|
|
@ -1,190 +1,161 @@
|
||||||
let
|
let
|
||||||
lib = import ./../default.nix;
|
lib = import ./../default.nix;
|
||||||
in
|
in {
|
||||||
{
|
|
||||||
"into" = {
|
"into" = {
|
||||||
"string" = {
|
"string" = {
|
||||||
"handles true" =
|
"handles true" = let
|
||||||
let
|
expected = "true";
|
||||||
expected = "true";
|
actual = lib.bools.into.string true;
|
||||||
actual = lib.bools.into.string true;
|
in
|
||||||
in
|
|
||||||
actual == expected;
|
actual == expected;
|
||||||
|
|
||||||
"handles false" =
|
"handles false" = let
|
||||||
let
|
expected = "false";
|
||||||
expected = "false";
|
actual = lib.bools.into.string false;
|
||||||
actual = lib.bools.into.string false;
|
in
|
||||||
in
|
|
||||||
actual == expected;
|
actual == expected;
|
||||||
};
|
};
|
||||||
|
|
||||||
"yesno" = {
|
"yesno" = {
|
||||||
"handles true" =
|
"handles true" = let
|
||||||
let
|
expected = "yes";
|
||||||
expected = "yes";
|
actual = lib.bools.into.yesno true;
|
||||||
actual = lib.bools.into.yesno true;
|
in
|
||||||
in
|
|
||||||
actual == expected;
|
actual == expected;
|
||||||
"handles false" =
|
"handles false" = let
|
||||||
let
|
expected = "no";
|
||||||
expected = "no";
|
actual = lib.bools.into.yesno false;
|
||||||
actual = lib.bools.into.yesno false;
|
in
|
||||||
in
|
|
||||||
actual == expected;
|
actual == expected;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
"when" = {
|
"when" = {
|
||||||
"returns first value when true" =
|
"returns first value when true" = let
|
||||||
let
|
expected = "foo";
|
||||||
expected = "foo";
|
actual = lib.bools.when true expected "bar";
|
||||||
actual = lib.bools.when true expected "bar";
|
in
|
||||||
in
|
|
||||||
actual == expected;
|
actual == expected;
|
||||||
|
|
||||||
"returns second value when false" =
|
"returns second value when false" = let
|
||||||
let
|
expected = "bar";
|
||||||
expected = "bar";
|
actual = lib.bools.when false "foo" expected;
|
||||||
actual = lib.bools.when false "foo" expected;
|
in
|
||||||
in
|
|
||||||
actual == expected;
|
actual == expected;
|
||||||
};
|
};
|
||||||
|
|
||||||
"and" = {
|
"and" = {
|
||||||
"returns true when both are true" =
|
"returns true when both are true" = let
|
||||||
let
|
expected = true;
|
||||||
expected = true;
|
actual = lib.bools.and true true;
|
||||||
actual = lib.bools.and true true;
|
in
|
||||||
in
|
|
||||||
actual == expected;
|
actual == expected;
|
||||||
"returns false when first is false" =
|
"returns false when first is false" = let
|
||||||
let
|
expected = false;
|
||||||
expected = false;
|
actual = lib.bools.and false true;
|
||||||
actual = lib.bools.and false true;
|
in
|
||||||
in
|
|
||||||
actual == expected;
|
actual == expected;
|
||||||
"returns false when second is false" =
|
"returns false when second is false" = let
|
||||||
let
|
expected = false;
|
||||||
expected = false;
|
actual = lib.bools.and true false;
|
||||||
actual = lib.bools.and true false;
|
in
|
||||||
in
|
|
||||||
actual == expected;
|
actual == expected;
|
||||||
"returns false when both are false" =
|
"returns false when both are false" = let
|
||||||
let
|
expected = false;
|
||||||
expected = false;
|
actual = lib.bools.and false false;
|
||||||
actual = lib.bools.and false false;
|
in
|
||||||
in
|
|
||||||
actual == expected;
|
actual == expected;
|
||||||
};
|
};
|
||||||
|
|
||||||
"and'" =
|
"and'" = let
|
||||||
let
|
getTrue = _: true;
|
||||||
getTrue = _: true;
|
getFalse = _: false;
|
||||||
getFalse = _: false;
|
in {
|
||||||
|
"returns true when both are true" = let
|
||||||
|
expected = true;
|
||||||
|
actual = lib.bools.and' getTrue getTrue null;
|
||||||
in
|
in
|
||||||
{
|
actual == expected;
|
||||||
"returns true when both are true" =
|
|
||||||
let
|
|
||||||
expected = true;
|
|
||||||
actual = lib.bools.and' getTrue getTrue null;
|
|
||||||
in
|
|
||||||
actual == expected;
|
|
||||||
|
|
||||||
"returns false when first is false" =
|
"returns false when first is false" = let
|
||||||
let
|
expected = false;
|
||||||
expected = false;
|
actual = lib.bools.and' getFalse getTrue null;
|
||||||
actual = lib.bools.and' getFalse getTrue null;
|
in
|
||||||
in
|
actual == expected;
|
||||||
actual == expected;
|
|
||||||
|
|
||||||
"returns false when second is false" =
|
"returns false when second is false" = let
|
||||||
let
|
expected = false;
|
||||||
expected = false;
|
actual = lib.bools.and' getTrue getFalse null;
|
||||||
actual = lib.bools.and' getTrue getFalse null;
|
in
|
||||||
in
|
actual == expected;
|
||||||
actual == expected;
|
|
||||||
|
|
||||||
"returns false when both are false" =
|
"returns false when both are false" = let
|
||||||
let
|
expected = false;
|
||||||
expected = false;
|
actual = lib.bools.and' getFalse getFalse null;
|
||||||
actual = lib.bools.and' getFalse getFalse null;
|
in
|
||||||
in
|
actual == expected;
|
||||||
actual == expected;
|
};
|
||||||
};
|
|
||||||
|
|
||||||
"or" = {
|
"or" = {
|
||||||
"returns true when both are true" =
|
"returns true when both are true" = let
|
||||||
let
|
expected = true;
|
||||||
expected = true;
|
actual = lib.bools.or true true;
|
||||||
actual = lib.bools.or true true;
|
in
|
||||||
in
|
|
||||||
actual == expected;
|
actual == expected;
|
||||||
"returns true when first is true" =
|
"returns true when first is true" = let
|
||||||
let
|
expected = true;
|
||||||
expected = true;
|
actual = lib.bools.or true false;
|
||||||
actual = lib.bools.or true false;
|
in
|
||||||
in
|
|
||||||
actual == expected;
|
actual == expected;
|
||||||
"returns true when second is true" =
|
"returns true when second is true" = let
|
||||||
let
|
expected = true;
|
||||||
expected = true;
|
actual = lib.bools.or false true;
|
||||||
actual = lib.bools.or false true;
|
in
|
||||||
in
|
|
||||||
actual == expected;
|
actual == expected;
|
||||||
"returns false when both are false" =
|
"returns false when both are false" = let
|
||||||
let
|
expected = false;
|
||||||
expected = false;
|
actual = lib.bools.or false false;
|
||||||
actual = lib.bools.or false false;
|
in
|
||||||
in
|
|
||||||
actual == expected;
|
actual == expected;
|
||||||
};
|
};
|
||||||
|
|
||||||
"or'" =
|
"or'" = let
|
||||||
let
|
getTrue = _: true;
|
||||||
getTrue = _: true;
|
getFalse = _: false;
|
||||||
getFalse = _: false;
|
in {
|
||||||
|
"returns true when both are true" = let
|
||||||
|
expected = true;
|
||||||
|
actual = lib.bools.or' getTrue getTrue null;
|
||||||
in
|
in
|
||||||
{
|
actual == expected;
|
||||||
"returns true when both are true" =
|
"returns true when first is true" = let
|
||||||
let
|
expected = true;
|
||||||
expected = true;
|
actual = lib.bools.or' getTrue getFalse null;
|
||||||
actual = lib.bools.or' getTrue getTrue null;
|
in
|
||||||
in
|
actual == expected;
|
||||||
actual == expected;
|
"returns true when second is true" = let
|
||||||
"returns true when first is true" =
|
expected = true;
|
||||||
let
|
actual = lib.bools.or' getFalse getTrue null;
|
||||||
expected = true;
|
in
|
||||||
actual = lib.bools.or' getTrue getFalse null;
|
actual == expected;
|
||||||
in
|
"returns false when both are false" = let
|
||||||
actual == expected;
|
expected = false;
|
||||||
"returns true when second is true" =
|
actual = lib.bools.or' getFalse getFalse null;
|
||||||
let
|
in
|
||||||
expected = true;
|
actual == expected;
|
||||||
actual = lib.bools.or' getFalse getTrue null;
|
};
|
||||||
in
|
|
||||||
actual == expected;
|
|
||||||
"returns false when both are false" =
|
|
||||||
let
|
|
||||||
expected = false;
|
|
||||||
actual = lib.bools.or' getFalse getFalse null;
|
|
||||||
in
|
|
||||||
actual == expected;
|
|
||||||
};
|
|
||||||
|
|
||||||
"not" = {
|
"not" = {
|
||||||
"returns false when true" =
|
"returns false when true" = let
|
||||||
let
|
expected = false;
|
||||||
expected = false;
|
actual = lib.bools.not true;
|
||||||
actual = lib.bools.not true;
|
in
|
||||||
in
|
|
||||||
actual == expected;
|
actual == expected;
|
||||||
|
|
||||||
"returns true when false" =
|
"returns true when false" = let
|
||||||
let
|
expected = true;
|
||||||
expected = true;
|
actual = lib.bools.not false;
|
||||||
actual = lib.bools.not false;
|
in
|
||||||
in
|
|
||||||
actual == expected;
|
actual == expected;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,56 +4,58 @@ lib: {
|
||||||
## Check that a value is a DAG entry.
|
## Check that a value is a DAG entry.
|
||||||
##
|
##
|
||||||
## @type a -> Bool
|
## @type a -> Bool
|
||||||
entry = value: (value ? value) && (value ? before) && (value ? after);
|
entry = value:
|
||||||
|
(value ? value)
|
||||||
|
&& (value ? before)
|
||||||
|
&& (value ? after);
|
||||||
|
|
||||||
## Check that a value is a DAG.
|
## Check that a value is a DAG.
|
||||||
##
|
##
|
||||||
## @type a -> Bool
|
## @type a -> Bool
|
||||||
graph =
|
graph = value: let
|
||||||
value:
|
isContentsValid = builtins.all lib.dag.validate.entry (builtins.attrValues value);
|
||||||
let
|
in
|
||||||
isContentsValid = builtins.all lib.dag.validate.entry (builtins.attrValues value);
|
builtins.isAttrs value
|
||||||
in
|
&& isContentsValid;
|
||||||
builtins.isAttrs value && isContentsValid;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
sort = {
|
sort = {
|
||||||
## Apply a topological sort to a DAG.
|
## Apply a topological sort to a DAG.
|
||||||
##
|
##
|
||||||
## @type Dag a -> { result :: List a } | { cycle :: List a, loops :: List a }
|
## @type Dag a -> { result :: List a } | { cycle :: List a, loops :: List a }
|
||||||
topographic =
|
topographic = graph: let
|
||||||
graph:
|
getEntriesBefore = graph: name: let
|
||||||
let
|
before =
|
||||||
getEntriesBefore =
|
lib.attrs.filter
|
||||||
graph: name:
|
(key: value: builtins.elem name value.before)
|
||||||
let
|
graph;
|
||||||
before = lib.attrs.filter (key: value: builtins.elem name value.before) graph;
|
|
||||||
in
|
|
||||||
builtins.attrNames before;
|
|
||||||
|
|
||||||
normalize = name: value: {
|
|
||||||
inherit name;
|
|
||||||
value = value.value;
|
|
||||||
after = value.after ++ (getEntriesBefore graph name);
|
|
||||||
};
|
|
||||||
|
|
||||||
normalized = builtins.mapAttrs normalize graph;
|
|
||||||
|
|
||||||
entries = builtins.attrValues normalized;
|
|
||||||
|
|
||||||
isBefore = a: b: builtins.elem a.name b.after;
|
|
||||||
|
|
||||||
sorted = lib.lists.sort.topographic isBefore entries;
|
|
||||||
in
|
in
|
||||||
if sorted ? result then
|
builtins.attrNames before;
|
||||||
{
|
|
||||||
result = builtins.map (value: {
|
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: {
|
||||||
name = value.name;
|
name = value.name;
|
||||||
value = value.value;
|
value = value.value;
|
||||||
}) sorted.result;
|
})
|
||||||
}
|
sorted.result;
|
||||||
else
|
}
|
||||||
sorted;
|
else sorted;
|
||||||
};
|
};
|
||||||
|
|
||||||
apply = {
|
apply = {
|
||||||
|
@ -61,95 +63,107 @@ lib: {
|
||||||
## and any entries that do exist are given the appropriate `before` and `after` values.
|
## and any entries that do exist are given the appropriate `before` and `after` values.
|
||||||
##
|
##
|
||||||
## @type Dag a -> Dag a -> Dag a
|
## @type Dag a -> Dag a -> Dag a
|
||||||
defaults =
|
defaults = graph: defaults: let
|
||||||
graph: defaults:
|
result =
|
||||||
let
|
builtins.mapAttrs
|
||||||
result = builtins.mapAttrs (
|
(
|
||||||
name: entry:
|
name: entry:
|
||||||
if defaults ? ${name} then
|
if defaults ? ${name}
|
||||||
if builtins.isString entry then
|
then
|
||||||
{
|
if builtins.isString entry
|
||||||
|
then {
|
||||||
value = entry;
|
value = entry;
|
||||||
before = defaults.${name}.before or [ ];
|
before = defaults.${name}.before or [];
|
||||||
after = defaults.${name}.after or [ ];
|
after = defaults.${name}.after or [];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
entry
|
entry
|
||||||
// {
|
// {
|
||||||
before = (entry.before or [ ]) ++ (defaults.${name}.before or [ ]);
|
before = (entry.before or []) ++ (defaults.${name}.before or []);
|
||||||
after = (entry.after or [ ]) ++ (defaults.${name}.after or [ ]);
|
after = (entry.after or []) ++ (defaults.${name}.after or []);
|
||||||
}
|
}
|
||||||
else
|
else entry
|
||||||
entry
|
)
|
||||||
) graph;
|
graph;
|
||||||
in
|
in
|
||||||
defaults // result;
|
defaults // result;
|
||||||
};
|
};
|
||||||
|
|
||||||
## Map over the entries in a DAG and modify their values.
|
## Map over the entries in a DAG and modify their values.
|
||||||
##
|
##
|
||||||
## @type (String -> a -> b) -> Dag a -> Dag b
|
## @type (String -> a -> b) -> Dag a -> Dag b
|
||||||
map = f: builtins.mapAttrs (name: value: value // { value = f name value.value; });
|
map = f:
|
||||||
|
builtins.mapAttrs
|
||||||
|
(name: value:
|
||||||
|
value
|
||||||
|
// {
|
||||||
|
value = f name value.value;
|
||||||
|
});
|
||||||
|
|
||||||
entry = {
|
entry = {
|
||||||
## Create a new DAG entry.
|
## Create a new DAG entry.
|
||||||
##
|
##
|
||||||
## @type List String -> List String -> a -> { before :: List String, after :: List String, value :: a }
|
## @type List String -> List String -> a -> { before :: List String, after :: List String, value :: a }
|
||||||
between = before: after: value: { inherit before after value; };
|
between = before: after: value: {
|
||||||
|
inherit before after value;
|
||||||
|
};
|
||||||
|
|
||||||
## Create a new DAG entry with no dependencies.
|
## Create a new DAG entry with no dependencies.
|
||||||
##
|
##
|
||||||
## @type a -> { before :: List String, after :: List String, value :: a }
|
## @type a -> { before :: List String, after :: List String, value :: a }
|
||||||
anywhere = lib.dag.entry.between [ ] [ ];
|
anywhere = lib.dag.entry.between [] [];
|
||||||
|
|
||||||
## Create a new DAG entry that occurs before other entries.
|
## Create a new DAG entry that occurs before other entries.
|
||||||
##
|
##
|
||||||
## @type List String -> a -> { before :: List String, after :: List String, value :: a }
|
## @type List String -> a -> { before :: List String, after :: List String, value :: a }
|
||||||
before = before: lib.dag.entry.between before [ ];
|
before = before: lib.dag.entry.between before [];
|
||||||
|
|
||||||
## Create a new DAG entry that occurs after other entries.
|
## Create a new DAG entry that occurs after other entries.
|
||||||
##
|
##
|
||||||
## @type List String -> a -> { before :: List String, after :: List String, value :: a }
|
## @type List String -> a -> { before :: List String, after :: List String, value :: a }
|
||||||
after = lib.dag.entry.between [ ];
|
after = lib.dag.entry.between [];
|
||||||
};
|
};
|
||||||
|
|
||||||
entries = {
|
entries = {
|
||||||
## Create a DAG from a list of entries, prefixed with a tag.
|
## Create a DAG from a list of entries, prefixed with a tag.
|
||||||
##
|
##
|
||||||
## @type String -> List String -> List String -> List a -> Dag a
|
## @type String -> List String -> List String -> List a -> Dag a
|
||||||
between =
|
between = tag: let
|
||||||
tag:
|
process = i: before: after: entries: let
|
||||||
let
|
name = "${tag}-${builtins.toString i}";
|
||||||
process =
|
entry = builtins.head entries;
|
||||||
i: before: after: entries:
|
rest = builtins.tail entries;
|
||||||
let
|
|
||||||
name = "${tag}-${builtins.toString i}";
|
|
||||||
entry = builtins.head entries;
|
|
||||||
rest = builtins.tail entries;
|
|
||||||
in
|
|
||||||
if builtins.length entries == 0 then
|
|
||||||
{ }
|
|
||||||
else if builtins.length entries == 1 then
|
|
||||||
{ "${name}" = lib.dag.entry.between before after entry; }
|
|
||||||
else
|
|
||||||
{ "${name}" = lib.dag.entry.after after entry; } // (process (i + 1) before [ name ] rest);
|
|
||||||
in
|
in
|
||||||
|
if builtins.length entries == 0
|
||||||
|
then {}
|
||||||
|
else if builtins.length entries == 1
|
||||||
|
then {
|
||||||
|
"${name}" = lib.dag.entry.between before after entry;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
"${name}" = lib.dag.entry.after after entry;
|
||||||
|
}
|
||||||
|
// (
|
||||||
|
process (i + 1) before [name] rest
|
||||||
|
);
|
||||||
|
in
|
||||||
process 0;
|
process 0;
|
||||||
|
|
||||||
## Create a DAG from a list of entries, prefixed with a tag, that can occur anywhere.
|
## Create a DAG from a list of entries, prefixed with a tag, that can occur anywhere.
|
||||||
##
|
##
|
||||||
## @type String -> List a -> Dag a
|
## @type String -> List a -> Dag a
|
||||||
anywhere = tag: lib.dag.entries.between tag [ ] [ ];
|
anywhere = tag: lib.dag.entries.between tag [] [];
|
||||||
|
|
||||||
## Create a DAG from a list of entries, prefixed with a tag, that occurs before other entries.
|
## Create a DAG from a list of entries, prefixed with a tag, that occurs before other entries.
|
||||||
##
|
##
|
||||||
## @type String -> List String -> List a -> Dag a
|
## @type String -> List String -> List a -> Dag a
|
||||||
before = tag: before: lib.dag.entries.between tag before [ ];
|
before = tag: before: lib.dag.entries.between tag before [];
|
||||||
|
|
||||||
## Create a DAG from a list of entries, prefixed with a tag, that occurs after other entries.
|
## Create a DAG from a list of entries, prefixed with a tag, that occurs after other entries.
|
||||||
##
|
##
|
||||||
## @type String -> List String -> List a -> Dag a
|
## @type String -> List String -> List a -> Dag a
|
||||||
after = tag: lib.dag.entries.between tag [ ];
|
after = tag: lib.dag.entries.between tag [];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,159 +1,134 @@
|
||||||
let
|
let
|
||||||
lib = import ./../default.nix;
|
lib = import ./../default.nix;
|
||||||
in
|
in {
|
||||||
{
|
|
||||||
"validate" = {
|
"validate" = {
|
||||||
"entry" = {
|
"entry" = {
|
||||||
"invalid value" =
|
"invalid value" = let
|
||||||
let
|
expected = false;
|
||||||
expected = false;
|
actual = lib.dag.validate.entry {};
|
||||||
actual = lib.dag.validate.entry { };
|
in
|
||||||
in
|
|
||||||
actual == expected;
|
actual == expected;
|
||||||
|
|
||||||
"a manually created value" =
|
"a manually created value" = let
|
||||||
let
|
expected = true;
|
||||||
expected = true;
|
actual = lib.dag.validate.entry {
|
||||||
actual = lib.dag.validate.entry {
|
value = null;
|
||||||
value = null;
|
before = [];
|
||||||
before = [ ];
|
after = [];
|
||||||
after = [ ];
|
};
|
||||||
};
|
in
|
||||||
in
|
|
||||||
actual == expected;
|
actual == expected;
|
||||||
|
|
||||||
"entry.between" =
|
"entry.between" = let
|
||||||
let
|
expected = true;
|
||||||
expected = true;
|
actual = lib.dag.validate.entry (lib.dag.entry.between [] [] null);
|
||||||
actual = lib.dag.validate.entry (lib.dag.entry.between [ ] [ ] null);
|
in
|
||||||
in
|
|
||||||
actual == expected;
|
actual == expected;
|
||||||
|
|
||||||
"entry.anywhere" =
|
"entry.anywhere" = let
|
||||||
let
|
expected = true;
|
||||||
expected = true;
|
actual = lib.dag.validate.entry (lib.dag.entry.anywhere null);
|
||||||
actual = lib.dag.validate.entry (lib.dag.entry.anywhere null);
|
in
|
||||||
in
|
|
||||||
actual == expected;
|
actual == expected;
|
||||||
|
|
||||||
"entry.before" =
|
"entry.before" = let
|
||||||
let
|
expected = true;
|
||||||
expected = true;
|
actual = lib.dag.validate.entry (lib.dag.entry.before [] null);
|
||||||
actual = lib.dag.validate.entry (lib.dag.entry.before [ ] null);
|
in
|
||||||
in
|
|
||||||
actual == expected;
|
actual == expected;
|
||||||
|
|
||||||
"entry.after" =
|
"entry.after" = let
|
||||||
let
|
expected = true;
|
||||||
expected = true;
|
actual = lib.dag.validate.entry (lib.dag.entry.after [] null);
|
||||||
actual = lib.dag.validate.entry (lib.dag.entry.after [ ] null);
|
in
|
||||||
in
|
|
||||||
actual == expected;
|
actual == expected;
|
||||||
};
|
};
|
||||||
|
|
||||||
"graph" = {
|
"graph" = {
|
||||||
"invalid value" =
|
"invalid value" = let
|
||||||
let
|
expected = false;
|
||||||
expected = false;
|
actual = lib.dag.validate.graph {
|
||||||
actual = lib.dag.validate.graph { x = { }; };
|
x = {};
|
||||||
in
|
};
|
||||||
|
in
|
||||||
actual == expected;
|
actual == expected;
|
||||||
|
|
||||||
"a manually created value" =
|
"a manually created value" = let
|
||||||
let
|
expected = true;
|
||||||
expected = true;
|
actual = lib.dag.validate.graph {
|
||||||
actual = lib.dag.validate.graph {
|
x = {
|
||||||
x = {
|
value = null;
|
||||||
value = null;
|
before = [];
|
||||||
before = [ ];
|
after = [];
|
||||||
after = [ ];
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
in
|
};
|
||||||
|
in
|
||||||
actual == expected;
|
actual == expected;
|
||||||
|
|
||||||
"entries.between" =
|
"entries.between" = let
|
||||||
let
|
expected = true;
|
||||||
expected = true;
|
graph = lib.dag.entries.between "example" [] [] [null null];
|
||||||
graph = lib.dag.entries.between "example" [ ] [ ] [
|
actual = lib.dag.validate.graph graph;
|
||||||
null
|
in
|
||||||
null
|
|
||||||
];
|
|
||||||
actual = lib.dag.validate.graph graph;
|
|
||||||
in
|
|
||||||
actual == expected;
|
actual == expected;
|
||||||
|
|
||||||
"entries.anywhere" =
|
"entries.anywhere" = let
|
||||||
let
|
expected = true;
|
||||||
expected = true;
|
graph = lib.dag.entries.anywhere "example" [null null];
|
||||||
graph = lib.dag.entries.anywhere "example" [
|
actual = lib.dag.validate.graph graph;
|
||||||
null
|
in
|
||||||
null
|
|
||||||
];
|
|
||||||
actual = lib.dag.validate.graph graph;
|
|
||||||
in
|
|
||||||
actual == expected;
|
actual == expected;
|
||||||
|
|
||||||
"entries.before" =
|
"entries.before" = let
|
||||||
let
|
expected = true;
|
||||||
expected = true;
|
graph = lib.dag.entries.before "example" [] [null null];
|
||||||
graph = lib.dag.entries.before "example" [ ] [
|
actual = lib.dag.validate.graph graph;
|
||||||
null
|
in
|
||||||
null
|
|
||||||
];
|
|
||||||
actual = lib.dag.validate.graph graph;
|
|
||||||
in
|
|
||||||
actual == expected;
|
actual == expected;
|
||||||
|
|
||||||
"entries.after" =
|
"entries.after" = let
|
||||||
let
|
expected = true;
|
||||||
expected = true;
|
graph = lib.dag.entries.after "example" [] [null null];
|
||||||
graph = lib.dag.entries.after "example" [ ] [
|
actual = lib.dag.validate.graph graph;
|
||||||
null
|
in
|
||||||
null
|
|
||||||
];
|
|
||||||
actual = lib.dag.validate.graph graph;
|
|
||||||
in
|
|
||||||
actual == expected;
|
actual == expected;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
"sort" = {
|
"sort" = {
|
||||||
"topographic" = {
|
"topographic" = {
|
||||||
"handles an empty graph" =
|
"handles an empty graph" = let
|
||||||
let
|
expected = [];
|
||||||
expected = [ ];
|
actual = lib.dag.sort.topographic {};
|
||||||
actual = lib.dag.sort.topographic { };
|
in
|
||||||
in
|
|
||||||
actual.result == expected;
|
actual.result == expected;
|
||||||
|
|
||||||
"sorts a graph" =
|
"sorts a graph" = let
|
||||||
let
|
expected = [
|
||||||
expected = [
|
{
|
||||||
{
|
name = "a";
|
||||||
name = "a";
|
value = "a";
|
||||||
value = "a";
|
}
|
||||||
}
|
{
|
||||||
{
|
name = "b";
|
||||||
name = "b";
|
value = "b";
|
||||||
value = "b";
|
}
|
||||||
}
|
{
|
||||||
{
|
name = "c";
|
||||||
name = "c";
|
value = "c";
|
||||||
value = "c";
|
}
|
||||||
}
|
{
|
||||||
{
|
name = "d";
|
||||||
name = "d";
|
value = "d";
|
||||||
value = "d";
|
}
|
||||||
}
|
];
|
||||||
];
|
actual = lib.dag.sort.topographic {
|
||||||
actual = lib.dag.sort.topographic {
|
a = lib.dag.entry.anywhere "a";
|
||||||
a = lib.dag.entry.anywhere "a";
|
b = lib.dag.entry.between ["c"] ["a"] "b";
|
||||||
b = lib.dag.entry.between [ "c" ] [ "a" ] "b";
|
c = lib.dag.entry.before ["c"] "c";
|
||||||
c = lib.dag.entry.before [ "c" ] "c";
|
d = lib.dag.entry.after ["c"] "d";
|
||||||
d = lib.dag.entry.after [ "c" ] "d";
|
};
|
||||||
};
|
in
|
||||||
in
|
|
||||||
actual.result == expected;
|
actual.result == expected;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -29,11 +29,9 @@ let
|
||||||
## definitions.
|
## definitions.
|
||||||
##
|
##
|
||||||
## @type (a -> a) -> a
|
## @type (a -> a) -> a
|
||||||
fix =
|
fix = f: let
|
||||||
f:
|
x = f x;
|
||||||
let
|
in
|
||||||
x = f x;
|
|
||||||
in
|
|
||||||
x;
|
x;
|
||||||
|
|
||||||
## Merge two attribute sets recursively until a given predicate returns true.
|
## Merge two attribute sets recursively until a given predicate returns true.
|
||||||
|
@ -41,42 +39,40 @@ let
|
||||||
## from `y` first if it exists and then `x` otherwise.
|
## from `y` first if it exists and then `x` otherwise.
|
||||||
##
|
##
|
||||||
## @type Attrs a b c => (String -> Any -> Any -> Bool) -> a -> b -> c
|
## @type Attrs a b c => (String -> Any -> Any -> Bool) -> a -> b -> c
|
||||||
mergeAttrsRecursiveUntil =
|
mergeAttrsRecursiveUntil = predicate: x: y: let
|
||||||
predicate: x: y:
|
process = path:
|
||||||
let
|
builtins.zipAttrsWith (
|
||||||
process =
|
name: values: let
|
||||||
path:
|
currentPath = path ++ [name];
|
||||||
builtins.zipAttrsWith (
|
isSingleValue = builtins.length values == 1;
|
||||||
name: values:
|
isComplete =
|
||||||
let
|
predicate currentPath
|
||||||
currentPath = path ++ [ name ];
|
(builtins.elemAt values 1)
|
||||||
isSingleValue = builtins.length values == 1;
|
(builtins.elemAt values 0);
|
||||||
isComplete = predicate currentPath (builtins.elemAt values 1) (builtins.elemAt values 0);
|
in
|
||||||
in
|
if isSingleValue || isComplete
|
||||||
if isSingleValue || isComplete then builtins.elemAt values 0 else process currentPath values
|
then builtins.elemAt values 0
|
||||||
);
|
else process currentPath values
|
||||||
in
|
);
|
||||||
process [ ] [
|
in
|
||||||
x
|
process [] [x y];
|
||||||
y
|
|
||||||
];
|
|
||||||
|
|
||||||
## Merge two attribute sets recursively. Any values that are _not_ attribute sets
|
## Merge two attribute sets recursively. Any values that are _not_ attribute sets
|
||||||
## will be overridden with the value from `y` first if it exists and then `x`
|
## will be overridden with the value from `y` first if it exists and then `x`
|
||||||
## otherwise.
|
## otherwise.
|
||||||
##
|
##
|
||||||
## @type Attrs a b c => a -> b -> c
|
## @type Attrs a b c => a -> b -> c
|
||||||
mergeAttrsRecursive = mergeAttrsRecursiveUntil (
|
mergeAttrsRecursive =
|
||||||
path: x: y:
|
mergeAttrsRecursiveUntil
|
||||||
!(builtins.isAttrs x && builtins.isAttrs y)
|
(path: x: y:
|
||||||
);
|
!(builtins.isAttrs x && builtins.isAttrs y));
|
||||||
|
|
||||||
lib = fix (
|
lib = fix (
|
||||||
self:
|
self: let
|
||||||
let
|
merge = acc: create:
|
||||||
merge = acc: create: mergeAttrsRecursive acc (create self);
|
mergeAttrsRecursive acc (create self);
|
||||||
in
|
in
|
||||||
builtins.foldl' merge { } libs
|
builtins.foldl' merge {} libs
|
||||||
);
|
);
|
||||||
in
|
in
|
||||||
lib.points.withExtend (lib.fp.const lib)
|
lib.points.withExtend (lib.fp.const lib)
|
||||||
|
|
|
@ -1,22 +1,18 @@
|
||||||
let
|
let
|
||||||
lib = import ./../default.nix;
|
lib = import ./../default.nix;
|
||||||
in
|
in {
|
||||||
{
|
|
||||||
"extend" = {
|
"extend" = {
|
||||||
"lib is extensible" =
|
"lib is extensible" = let
|
||||||
let
|
result = lib.extend (final: prev: prev // {
|
||||||
result = lib.extend (
|
__injected__ = true;
|
||||||
final: prev:
|
|
||||||
prev
|
|
||||||
// {
|
|
||||||
__injected__ = true;
|
|
||||||
|
|
||||||
fp = prev.fp // {
|
fp = prev.fp // {
|
||||||
__injected__ = true;
|
__injected__ = true;
|
||||||
};
|
};
|
||||||
}
|
});
|
||||||
);
|
in
|
||||||
in
|
result ? __injected__
|
||||||
result ? __injected__ && result.fp ? __injected__ && result.fp ? const;
|
&& result.fp ? __injected__
|
||||||
|
&& result.fp ? const;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue