Compare commits

..

2 commits

151 changed files with 7525 additions and 8413 deletions

View file

@ -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}

View file

@ -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

View file

@ -7,30 +7,25 @@
}; };
}; };
outputs = outputs = inputs: let
inputs:
let
inherit (inputs.lib) lib; inherit (inputs.lib) lib;
modules = import ./src; modules = import ./src;
forEachSystem = lib.attrs.generate [ forEachSystem = lib.attrs.generate [
"i686-linux" "i686-linux"
"x86-64_linux" "x86_64-linux"
]; ];
in in {
{ extras = let
extras = result = lib.modules.run {modules = builtins.attrValues modules;};
let
result = lib.modules.run { modules = builtins.attrValues modules; };
in in
result.config.exports.resolved.extras; 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

View file

@ -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,31 +17,22 @@ 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
let
package = builtins.derivation ( package = builtins.derivation (
(builtins.removeAttrs settings [ (builtins.removeAttrs settings ["meta" "extras" "executable" "env" "deps" "script"])
"meta"
"extras"
"executable"
"env"
"deps"
"script"
])
// env // env
// { // {
inherit name system script; inherit name system script;
passAsFile = [ "script" ]; passAsFile = ["script"];
builder = "${stage1.bash.boot.package}/bin/bash"; builder = "${stage1.bash.boot.package}/bin/bash";
@ -66,7 +58,7 @@ in
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
@ -76,7 +68,10 @@ in
} }
); );
in in
package // { inherit meta extras; }; package
// {
inherit meta extras;
};
}; };
}; };
} }

View file

@ -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,31 +20,22 @@ 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
let
package = builtins.derivation ( package = builtins.derivation (
(builtins.removeAttrs settings [ (builtins.removeAttrs settings ["meta" "extras" "executable" "env" "deps" "script"])
"meta"
"extras"
"executable"
"env"
"deps"
"script"
])
// env // env
// { // {
inherit name system script; inherit name system script;
passAsFile = [ "script" ]; passAsFile = ["script"];
builder = "${stage1.bash.package}/bin/bash"; builder = "${stage1.bash.package}/bin/bash";
@ -67,7 +61,7 @@ in
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
@ -76,7 +70,10 @@ in
} }
); );
in in
package // { inherit meta extras; }; package
// {
inherit meta extras;
};
}; };
}; };
} }

View file

@ -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,17 +15,15 @@ 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
let
script = script =
'' ''
target=''${out}''${destination} target=''${out}''${destination}
@ -39,22 +38,12 @@ in
chmod 555 ''${target} chmod 555 ''${target}
''; '';
package = builtins.derivation ( package = builtins.derivation (
(builtins.removeAttrs settings [ (builtins.removeAttrs settings ["meta" "extras" "executable" "isExecutable"])
"meta"
"extras"
"executable"
"isExecutable"
])
// { // {
inherit inherit name system destination contents;
name
system
destination
contents
;
destinationDir = builtins.dirOf destination; destinationDir = builtins.dirOf destination;
passAsFile = [ "contents" ]; passAsFile = ["contents"];
builder = "${stage0.kaem.package}/bin/kaem"; builder = "${stage0.kaem.package}/bin/kaem";
@ -65,11 +54,16 @@ in
(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 in
package // { inherit meta extras; }; package
// {
inherit meta extras;
};
}; };
}; };
} }

View file

@ -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,26 +16,17 @@ 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
let
package = builtins.derivation ( package = builtins.derivation (
(builtins.removeAttrs settings [ (builtins.removeAttrs settings ["meta" "extras" "executable" "env" "deps" "script"])
"meta"
"extras"
"executable"
"env"
"deps"
"script"
])
// env // env
// { // {
inherit name system; inherit name system;
@ -45,14 +37,16 @@ in
"--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
@ -62,7 +56,10 @@ in
} }
); );
in in
package // { inherit meta extras; }; package
// {
inherit meta extras;
};
}; };
}; };
} }

View file

@ -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,30 +13,19 @@ 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
let
package = builtins.derivation ( package = builtins.derivation (
(builtins.removeAttrs settings [ (builtins.removeAttrs settings ["meta" "extras" "executable"])
"meta"
"extras"
"executable"
])
// { // {
inherit inherit version pname system args;
version
pname
system
args
;
name = "${pname}-${version}"; name = "${pname}-${version}";
@ -43,7 +33,10 @@ in
} }
); );
in in
package // { inherit meta extras; }; package
// {
inherit meta extras;
};
}; };
}; };
} }

View file

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

View file

@ -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 =
builtins.mapAttrs (
name: value: name: value:
lib.attrs.filter ( lib.attrs.filter
(
name: value: name: value:
if value ? meta && value.meta ? platforms then if value ? meta && value.meta ? platforms
builtins.elem config.aux.system value.meta.platforms then builtins.elem config.aux.system value.meta.platforms
else else true
true )
) value value
) config.exports.packages; )
config.exports.packages;
extras = config.exports.extras; extras = config.exports.extras;
}; };

View file

@ -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;

View file

@ -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,7 +332,12 @@ in
}; };
config = { config = {
aux.platform = (platforms.${platform} or (builtins.throw "Unsupported platform: ${system}")) // { aux.platform =
(
platforms.${platform}
or (builtins.throw "Unsupported platform: ${system}")
)
// {
name = platform; name = platform;
# These will only ever have `linux` as the target since we # These will only ever have `linux` as the target since we

View file

@ -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;

View file

@ -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

View file

@ -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 {
@ -35,8 +36,8 @@ 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.";
default.value = [ default.value = [
"x86_64-linux"
"i686-linux" "i686-linux"
"x86-64_linux"
]; ];
}; };
}; };
@ -66,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];
} }
); );
}; };

View file

@ -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 {
@ -43,8 +44,8 @@ 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.";
default.value = [ default.value = [
"x86_64-linux"
"i686-linux" "i686-linux"
"x86-64_linux"
]; ];
}; };
}; };

View file

@ -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,21 +18,24 @@ 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:
let
script = builtins.toFile "build-${name}.kaem" '' script = builtins.toFile "build-${name}.kaem" ''
''${M2} --architecture ${architecture.m2libc} \ ''${M2} --architecture ${architecture.m2libc} \
-f ''${m2libc}/sys/types.h \ -f ''${m2libc}/sys/types.h \
@ -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 {
@ -126,8 +130,8 @@ 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.";
default.value = [ default.value = [
"x86_64-linux"
"i686-linux" "i686-linux"
"x86-64_linux"
]; ];
}; };
}; };

View file

@ -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 {
@ -42,8 +42,8 @@ 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.";
default.value = [ default.value = [
"x86_64-linux"
"i686-linux" "i686-linux"
"x86-64_linux"
]; ];
}; };
}; };
@ -90,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 (

View file

@ -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 {
@ -34,8 +35,8 @@ 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.";
default.value = [ default.value = [
"x86_64-linux"
"i686-linux" "i686-linux"
"x86-64_linux"
]; ];
}; };
}; };

View file

@ -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 {
@ -35,8 +36,8 @@ 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.";
default.value = [ default.value = [
"x86_64-linux"
"i686-linux" "i686-linux"
"x86-64_linux"
]; ];
}; };
}; };

View file

@ -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 {
@ -36,8 +37,8 @@ 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.";
default.value = [ default.value = [
"x86_64-linux"
"i686-linux" "i686-linux"
"x86-64_linux"
]; ];
}; };
}; };
@ -57,16 +58,18 @@ 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")
]; ];

View file

@ -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 {
@ -36,8 +37,8 @@ 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.";
default.value = [ default.value = [
"x86_64-linux"
"i686-linux" "i686-linux"
"x86-64_linux"
]; ];
}; };
}; };
@ -59,8 +60,7 @@ 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";
@ -75,8 +75,7 @@ in
"${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")
]; ];

View file

@ -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 {
@ -37,8 +38,8 @@ 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.";
default.value = [ default.value = [
"x86_64-linux"
"i686-linux" "i686-linux"
"x86-64_linux"
]; ];
}; };
}; };
@ -60,8 +61,7 @@ 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";
@ -89,8 +89,7 @@ in
cc_arch0_hex2-0 cc_arch0_hex2-0
]; ];
}; };
in in [
[
cc_arch1_hex2-0 cc_arch1_hex2-0
(builtins.placeholder "out") (builtins.placeholder "out")
]; ];

View file

@ -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 {
@ -38,8 +39,8 @@ 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.";
default.value = [ default.value = [
"x86_64-linux"
"i686-linux" "i686-linux"
"x86-64_linux"
]; ];
}; };
}; };
@ -61,8 +62,7 @@ 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";
@ -140,8 +140,7 @@ in
M2_hex2-0 M2_hex2-0
]; ];
}; };
in in [
[
M2_hex2-0' M2_hex2-0'
(builtins.placeholder "out") (builtins.placeholder "out")
]; ];

View file

@ -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 {
@ -39,8 +40,8 @@ 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.";
default.value = [ default.value = [
"x86_64-linux"
"i686-linux" "i686-linux"
"x86-64_linux"
]; ];
}; };
}; };
@ -62,8 +63,7 @@ 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";
@ -130,8 +130,7 @@ in
blood-elf_hex2-0 blood-elf_hex2-0
]; ];
}; };
in in [
[
blood-elf_hex2-0' blood-elf_hex2-0'
(builtins.placeholder "out") (builtins.placeholder "out")
]; ];

View file

@ -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 {
@ -40,8 +41,8 @@ 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.";
default.value = [ default.value = [
"x86_64-linux"
"i686-linux" "i686-linux"
"x86-64_linux"
]; ];
}; };
}; };
@ -63,8 +64,7 @@ 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";
@ -98,10 +98,16 @@ in
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-0_M1 M1-macro-0_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")
]; ];
@ -149,8 +155,7 @@ in
M1-macro-0_hex2-0 M1-macro-0_hex2-0
]; ];
}; };
in in [
[
M1-macro-0_hex2-0' M1-macro-0_hex2-0'
(builtins.placeholder "out") (builtins.placeholder "out")
]; ];

View file

@ -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 {
@ -41,8 +42,8 @@ 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.";
default.value = [ default.value = [
"x86_64-linux"
"i686-linux" "i686-linux"
"x86-64_linux"
]; ];
}; };
}; };
@ -64,8 +65,7 @@ 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";
@ -118,10 +118,16 @@ in
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")
]; ];
@ -137,7 +143,11 @@ in
args = [ args = [
"--architecture" "--architecture"
architecture.m2libc architecture.m2libc
(if config.aux.platform.endian == "little" then "--little-endian" else "--big-endian") (
if config.aux.platform.endian == "little"
then "--little-endian"
else "--big-endian"
)
"-f" "-f"
"${sources.m2libc}/${architecture.m2libc}/${architecture.m2libc}_defs.M1" "${sources.m2libc}/${architecture.m2libc}/${architecture.m2libc}_defs.M1"
"-f" "-f"
@ -164,8 +174,7 @@ in
hex2_linker_hex2 hex2_linker_hex2
]; ];
}; };
in in [
[
hex2_linker_hex2' hex2_linker_hex2'
(builtins.placeholder "out") (builtins.placeholder "out")
]; ];

View file

@ -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 {
@ -42,8 +43,8 @@ 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.";
default.value = [ default.value = [
"x86_64-linux"
"i686-linux" "i686-linux"
"x86-64_linux"
]; ];
}; };
}; };
@ -65,8 +66,7 @@ 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";
@ -117,10 +117,16 @@ in
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")
]; ];
@ -136,7 +142,11 @@ in
args = [ args = [
"--architecture" "--architecture"
architecture.m2libc architecture.m2libc
(if config.aux.platform.endian == "little" then "--little-endian" else "--big-endian") (
if config.aux.platform.endian == "little"
then "--little-endian"
else "--big-endian"
)
"-f" "-f"
"${sources.m2libc}/${architecture.m2libc}/${architecture.m2libc}_defs.M1" "${sources.m2libc}/${architecture.m2libc}/${architecture.m2libc}_defs.M1"
"-f" "-f"
@ -149,21 +159,23 @@ in
(builtins.placeholder "out") (builtins.placeholder "out")
]; ];
}; };
in in [
[
"--architecture" "--architecture"
architecture.m2libc architecture.m2libc
(if config.aux.platform.endian == "little" then "--little-endian" else "--big-endian") (
if config.aux.platform.endian == "little"
then "--little-endian"
else "--big-endian"
)
"--base-address" "--base-address"
( (
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}"
) )
"-f" "-f"
"${sources.m2libc}/${architecture.m2libc}/ELF-${architecture.m2libc}-debug.hex2" "${sources.m2libc}/${architecture.m2libc}/ELF-${architecture.m2libc}-debug.hex2"

View file

@ -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 {
@ -41,8 +42,8 @@ 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.";
default.value = [ default.value = [
"x86_64-linux"
"i686-linux" "i686-linux"
"x86-64_linux"
]; ];
}; };
}; };
@ -64,8 +65,7 @@ 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";
@ -118,10 +118,16 @@ in
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")
]; ];
@ -137,7 +143,11 @@ in
args = [ args = [
"--architecture" "--architecture"
architecture.m2libc architecture.m2libc
(if config.aux.platform.endian == "little" then "--little-endian" else "--big-endian") (
if config.aux.platform.endian == "little"
then "--little-endian"
else "--big-endian"
)
"-f" "-f"
"${sources.m2libc}/${architecture.m2libc}/${architecture.m2libc}_defs.M1" "${sources.m2libc}/${architecture.m2libc}/${architecture.m2libc}_defs.M1"
"-f" "-f"
@ -150,21 +160,23 @@ in
(builtins.placeholder "out") (builtins.placeholder "out")
]; ];
}; };
in in [
[
"--architecture" "--architecture"
architecture.m2libc architecture.m2libc
(if config.aux.platform.endian == "little" then "--little-endian" else "--big-endian") (
if config.aux.platform.endian == "little"
then "--little-endian"
else "--big-endian"
)
"--base-address" "--base-address"
( (
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}"
) )
"-f" "-f"
"${sources.m2libc}/${architecture.m2libc}/ELF-${architecture.m2libc}-debug.hex2" "${sources.m2libc}/${architecture.m2libc}/ELF-${architecture.m2libc}-debug.hex2"

View file

@ -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 {
@ -41,8 +42,8 @@ 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.";
default.value = [ default.value = [
"x86_64-linux"
"i686-linux" "i686-linux"
"x86-64_linux"
]; ];
}; };
}; };
@ -64,8 +65,7 @@ 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";
@ -120,10 +120,16 @@ in
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")
]; ];
@ -139,7 +145,11 @@ in
args = [ args = [
"--architecture" "--architecture"
architecture.m2libc architecture.m2libc
(if config.aux.platform.endian == "little" then "--little-endian" else "--big-endian") (
if config.aux.platform.endian == "little"
then "--little-endian"
else "--big-endian"
)
"-f" "-f"
"${sources.m2libc}/${architecture.m2libc}/${architecture.m2libc}_defs.M1" "${sources.m2libc}/${architecture.m2libc}/${architecture.m2libc}_defs.M1"
"-f" "-f"
@ -152,21 +162,23 @@ in
(builtins.placeholder "out") (builtins.placeholder "out")
]; ];
}; };
in in [
[
"--architecture" "--architecture"
architecture.m2libc architecture.m2libc
(if config.aux.platform.endian == "little" then "--little-endian" else "--big-endian") (
if config.aux.platform.endian == "little"
then "--little-endian"
else "--big-endian"
)
"--base-address" "--base-address"
( (
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}"
) )
"-f" "-f"
"${sources.m2libc}/${architecture.m2libc}/ELF-${architecture.m2libc}-debug.hex2" "${sources.m2libc}/${architecture.m2libc}/ELF-${architecture.m2libc}-debug.hex2"

View file

@ -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";

View file

@ -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 {
@ -33,7 +34,7 @@ in
description = "Platforms the package supports."; description = "Platforms the package supports.";
default.value = [ default.value = [
"i686-linux" "i686-linux"
"x86-64_linux" "x86_64-linux"
]; ];
}; };
}; };
@ -63,8 +64,7 @@ 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";

View file

@ -36,7 +36,7 @@ in
description = "Platforms the package supports."; description = "Platforms the package supports.";
default.value = [ default.value = [
"i686-linux" "i686-linux"
"x86-64_linux" "x86_64-linux"
]; ];
}; };

View file

@ -34,7 +34,7 @@ in
description = "Platforms the package supports."; description = "Platforms the package supports.";
default.value = [ default.value = [
"i686-linux" "i686-linux"
"x86-64_linux" "x86_64-linux"
]; ];
}; };
}; };

View file

@ -34,7 +34,7 @@ in
description = "Platforms the package supports."; description = "Platforms the package supports.";
default.value = [ default.value = [
"i686-linux" "i686-linux"
"x86-64_linux" "x86_64-linux"
]; ];
}; };
}; };

View file

@ -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 {
@ -35,7 +36,7 @@ in
# TODO: Support more platforms. # TODO: Support more platforms.
default.value = [ default.value = [
"i686-linux" "i686-linux"
"x86-64_linux" "x86_64-linux"
]; ];
}; };
}; };

View file

@ -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,8 +34,7 @@ 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";

View file

@ -36,7 +36,7 @@ in
description = "Platforms the package supports."; description = "Platforms the package supports.";
default.value = [ default.value = [
"i686-linux" "i686-linux"
"x86-64_linux" "x86_64-linux"
]; ];
}; };
}; };

View file

@ -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

View file

@ -34,7 +34,7 @@ in
description = "Platforms the package supports."; description = "Platforms the package supports.";
default.value = [ default.value = [
"i686-linux" "i686-linux"
"x86-64_linux" "x86_64-linux"
]; ];
}; };
}; };

View file

@ -34,7 +34,7 @@ in
description = "Platforms the package supports."; description = "Platforms the package supports.";
default.value = [ default.value = [
"i686-linux" "i686-linux"
"x86-64_linux" "x86_64-linux"
]; ];
}; };
}; };

View file

@ -36,7 +36,7 @@ in
description = "Platforms the package supports."; description = "Platforms the package supports.";
default.value = [ default.value = [
"i686-linux" "i686-linux"
"x86-64_linux" "x86_64-linux"
]; ];
}; };

View file

@ -40,7 +40,7 @@ in
description = "Platforms the package supports."; description = "Platforms the package supports.";
default.value = [ default.value = [
"i686-linux" "i686-linux"
"x86-64_linux" "x86_64-linux"
]; ];
}; };
}; };

View file

@ -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 {
@ -33,7 +34,7 @@ in
description = "Platforms the package supports."; description = "Platforms the package supports.";
default.value = [ default.value = [
"i686-linux" "i686-linux"
"x86-64_linux" "x86_64-linux"
]; ];
}; };
@ -69,8 +70,7 @@ 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 {

View file

@ -34,7 +34,7 @@ in
description = "Platforms the package supports."; description = "Platforms the package supports.";
default.value = [ default.value = [
"i686-linux" "i686-linux"
"x86-64_linux" "x86_64-linux"
]; ];
}; };
}; };

View file

@ -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,8 +34,7 @@ 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
@ -114,7 +114,8 @@ in
"-Dvfork=fork" "-Dvfork=fork"
]; ];
cflags = [ cflags =
[
"-I./src" "-I./src"
"-I./lib" "-I./lib"
"-DHAVE_CONFIG_H" "-DHAVE_CONFIG_H"
@ -126,7 +127,8 @@ 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
@ -164,14 +166,27 @@ in
"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; (
value:
builtins.replaceStrings [".c"] [".o"]
(builtins.baseNameOf value)
)
files;
in in
builders.kaem.build { builders.kaem.build {
name = "gnumake-${cfg.version}"; name = "gnumake-${cfg.version}";

View file

@ -36,7 +36,7 @@ in
description = "Platforms the package supports."; description = "Platforms the package supports.";
default.value = [ default.value = [
"i686-linux" "i686-linux"
"x86-64_linux" "x86_64-linux"
]; ];
}; };
}; };

View file

@ -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 {
@ -33,7 +34,7 @@ in
description = "Platforms the package supports."; description = "Platforms the package supports.";
default.value = [ default.value = [
"i686-linux" "i686-linux"
"x86-64_linux" "x86_64-linux"
]; ];
}; };
}; };
@ -63,8 +64,7 @@ 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 = [
@ -113,14 +113,18 @@ in
"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)
)
sources;
in in
builders.kaem.build { builders.kaem.build {
name = "gnupatch-${cfg.version}"; name = "gnupatch-${cfg.version}";
@ -128,7 +132,7 @@ in
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

View file

@ -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,8 +34,7 @@ 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 {

View file

@ -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 = {
@ -36,7 +37,7 @@ in
description = "Platforms the package supports."; description = "Platforms the package supports.";
default.value = [ default.value = [
"i686-linux" "i686-linux"
"x86-64_linux" "x86_64-linux"
]; ];
}; };

View file

@ -39,7 +39,7 @@ in
description = "Platforms the package supports."; description = "Platforms the package supports.";
default.value = [ default.value = [
"i686-linux" "i686-linux"
"x86-64_linux" "x86_64-linux"
]; ];
}; };

View file

@ -33,7 +33,7 @@ in
description = "Platforms the package supports."; description = "Platforms the package supports.";
default.value = [ default.value = [
"i686-linux" "i686-linux"
"x86-64_linux" "x86_64-linux"
]; ];
}; };
}; };

View file

@ -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 = {
@ -47,7 +48,7 @@ in
description = "Platforms the package supports."; description = "Platforms the package supports.";
default.value = [ default.value = [
"i686-linux" "i686-linux"
"x86-64_linux" "x86_64-linux"
]; ];
}; };
}; };
@ -77,8 +78,7 @@ 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)

View file

@ -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;
@ -55,7 +56,7 @@ in
description = "Platforms the package supports."; description = "Platforms the package supports.";
default.value = [ default.value = [
"i686-linux" "i686-linux"
"x86-64_linux" "x86_64-linux"
]; ];
}; };
}; };
@ -70,8 +71,7 @@ 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";

View file

@ -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 {
@ -28,7 +29,7 @@ in
description = "Platforms the package supports."; description = "Platforms the package supports.";
default.value = [ default.value = [
"i686-linux" "i686-linux"
"x86-64_linux" "x86_64-linux"
]; ];
}; };
}; };

View file

@ -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 {
@ -34,7 +35,7 @@ in
description = "Platforms the package supports."; description = "Platforms the package supports.";
default.value = [ default.value = [
"i686-linux" "i686-linux"
"x86-64_linux" "x86_64-linux"
]; ];
}; };
}; };

View file

@ -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 {
@ -35,7 +36,7 @@ in
description = "Platforms the package supports."; description = "Platforms the package supports.";
default.value = [ default.value = [
"i686-linux" "i686-linux"
"x86-64_linux" "x86_64-linux"
]; ];
}; };
}; };
@ -48,13 +49,10 @@ in
config = { config = {
aux.foundation.stages.stage1.mes.compiler = { aux.foundation.stages.stage1.mes.compiler = {
package = package = let
let compile = path: let
compile =
path:
let
file = builtins.baseNameOf path; file = builtins.baseNameOf path;
fileWithoutExtension = builtins.replaceStrings [ ".c" ] [ "" ] file; 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"

View file

@ -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

View file

@ -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 {
@ -33,7 +34,7 @@ in
description = "Platforms the package supports."; description = "Platforms the package supports.";
default.value = [ default.value = [
"i686-linux" "i686-linux"
"x86-64_linux" "x86_64-linux"
]; ];
}; };
}; };
@ -46,8 +47,7 @@ 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;
@ -60,7 +60,7 @@ in
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}

View file

@ -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 {
@ -35,7 +36,7 @@ in
description = "Platforms the package supports."; description = "Platforms the package supports.";
default.value = [ default.value = [
"i686-linux" "i686-linux"
"x86-64_linux" "x86_64-linux"
]; ];
}; };
}; };
@ -60,8 +61,7 @@ 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}"
@ -143,13 +143,10 @@ in
''; '';
}; };
package = package = let
let compile = path: let
compile =
path:
let
file = builtins.baseNameOf path; file = builtins.baseNameOf path;
fileWithoutExtension = builtins.replaceStrings [ ".c" ] [ "" ] file; fileWithoutExtension = builtins.replaceStrings [".c"] [""] file;
cc = builtins.concatStringsSep " " [ cc = builtins.concatStringsSep " " [
"${cfg.src.bin}/bin/mes-m2" "${cfg.src.bin}/bin/mes-m2"
@ -177,16 +174,10 @@ in
getSourcePath = suffix: source: "${source}/${source.name}${suffix}"; getSourcePath = suffix: source: "${source}/${source.name}${suffix}";
archive = archive = destination: sources: "catm ${destination} ${lib.strings.concatMapSep " " (getSourcePath ".o") sources}";
destination: sources: source = destination: sources: "catm ${destination} ${lib.strings.concatMapSep " " (getSourcePath ".s") sources}";
"catm ${destination} ${lib.strings.concatMapSep " " (getSourcePath ".o") sources}";
source =
destination: sources:
"catm ${destination} ${lib.strings.concatMapSep " " (getSourcePath ".s") sources}";
createLib = createLib = name: sources: let
name: sources:
let
compiled = builtins.map compile sources; compiled = builtins.map compile sources;
in in
builders.kaem.build { builders.kaem.build {

View file

@ -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"

View file

@ -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 {
@ -36,7 +37,7 @@ in
description = "Platforms the package supports."; description = "Platforms the package supports.";
default.value = [ default.value = [
"i686-linux" "i686-linux"
"x86-64_linux" "x86_64-linux"
]; ];
}; };
}; };

View file

@ -34,7 +34,7 @@ in
description = "Platforms the package supports."; description = "Platforms the package supports.";
default.value = [ default.value = [
"i686-linux" "i686-linux"
"x86-64_linux" "x86_64-linux"
]; ];
}; };
}; };

View file

@ -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,11 +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"
"x86-64_linux"
];
}; };
}; };
@ -69,10 +66,8 @@ in
}; };
config = { config = {
aux.foundation.stages.stage1.tinycc.boot = aux.foundation.stages.stage1.tinycc.boot = let
let tinycc-boot = let
tinycc-boot =
let
tinycc-mes-bootstrappable = helpers.createBoot { tinycc-mes-bootstrappable = helpers.createBoot {
pname = "tinycc-mes-bootstrappable"; pname = "tinycc-mes-bootstrappable";
version = stage1.tinycc.version; version = stage1.tinycc.version;
@ -87,7 +82,9 @@ in
"-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 = [
"-D HAVE_LONG_LONG_STUB=1"
];
boot = tinycc-mes-bootstrappable; boot = tinycc-mes-bootstrappable;
meta = cfg.meta; meta = cfg.meta;
}; };
@ -101,7 +98,9 @@ in
"-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 = [
"-D HAVE_LONG_LONG=1"
];
boot = tinycc-boot0; boot = tinycc-boot0;
meta = cfg.meta; meta = cfg.meta;
}; };
@ -159,15 +158,13 @@ in
boot = tinycc-boot3; boot = tinycc-boot3;
meta = cfg.meta; meta = cfg.meta;
}; };
in in {
{
revision = "80114c4da6b17fbaabb399cc29f427e368309bc8"; 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";
@ -191,8 +188,7 @@ in
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}";
}; };
}; };
} }

View file

@ -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
@ -38,8 +39,8 @@ 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.";
default.value = [ default.value = [
"x86_64-linux"
"i686-linux" "i686-linux"
"x86-64_linux"
]; ];
}; };
}; };

View file

@ -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,13 +9,11 @@ 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
let
compiler = builders.kaem.build { compiler = builders.kaem.build {
name = "${pname}-${version}"; name = "${pname}-${version}";
@ -57,22 +57,17 @@ let
args = cflags; args = cflags;
tinycc = compiler; tinycc = compiler;
}; };
in in {inherit compiler libs;};
{
inherit compiler libs;
};
createTinyccMes = createTinyccMes = {
{
pname, pname,
version, version,
src, src,
args, args,
boot, boot,
lib ? { }, lib ? {},
meta, meta,
}: }: let
let
compiler = builders.kaem.build { compiler = builders.kaem.build {
name = "${pname}-${version}"; name = "${pname}-${version}";
@ -113,33 +108,28 @@ let
libs = createLibc { libs = createLibc {
inherit pname version src; inherit pname version src;
args = builtins.concatStringsSep " " ( args =
[ builtins.concatStringsSep
"-c" " "
"-D" (
"TCC_TARGET_I386=1" ["-c" "-D" "TCC_TARGET_I386=1"]
] ++ (lib.args or [])
++ (lib.args or [ ])
); );
tinycc = compiler; tinycc = compiler;
}; };
in in {
{
inherit compiler libs boot; inherit compiler libs boot;
}; };
createLibc = createLibc = {
{
pname, pname,
version, version,
src, src,
args, args,
tinycc, tinycc,
}: }: let
let createLibrary = name: args: source:
createLibrary =
name: args: source:
builders.kaem.build { builders.kaem.build {
name = "${name}.a"; name = "${name}.a";
@ -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
;
} }

View file

@ -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,10 +39,8 @@ in
}; };
config = { config = {
aux.foundation.stages.stage1.tinycc.mes = aux.foundation.stages.stage1.tinycc.mes = let
let tinycc-mes = let
tinycc-mes =
let
tccdefs = builders.kaem.build { tccdefs = builders.kaem.build {
name = "tccdefs-${stage1.tinycc.version}"; name = "tccdefs-${stage1.tinycc.version}";
@ -107,15 +106,13 @@ in
boot = tinycc-mes-boot; boot = tinycc-mes-boot;
meta = stage1.tinycc.meta; meta = stage1.tinycc.meta;
}; };
in in {
{
revision = "86f3d8e33105435946383aee52487b5ddf918140"; 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";
@ -139,8 +136,7 @@ in
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}";
}; };
}; };
} }

View file

@ -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,8 +39,7 @@ 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
@ -141,8 +141,7 @@ in
install -Dm444 libtcc1.a $out/lib/libtcc1.a install -Dm444 libtcc1.a $out/lib/libtcc1.a
''; '';
}; };
in in {
{
revision = "fd6d2180c5c801bb0b4c5dde27d61503059fc97d"; revision = "fd6d2180c5c801bb0b4c5dde27d61503059fc97d";
src = builtins.fetchurl { src = builtins.fetchurl {

View file

@ -36,8 +36,8 @@ 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.";
default.value = [ default.value = [
"x86_64-linux"
"i686-linux" "i686-linux"
"x86-64_linux"
]; ];
}; };
}; };

View file

@ -33,8 +33,8 @@ 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.";
default.value = [ default.value = [
"x86_64-linux"
"i686-linux" "i686-linux"
"x86-64_linux"
]; ];
}; };
}; };

View file

@ -33,8 +33,8 @@ 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.";
default.value = [ default.value = [
"x86_64-linux"
"i686-linux" "i686-linux"
"x86-64_linux"
]; ];
}; };

View file

@ -33,8 +33,8 @@ 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.";
default.value = [ default.value = [
"x86_64-linux"
"i686-linux" "i686-linux"
"x86-64_linux"
]; ];
}; };
}; };

View file

@ -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 {
@ -34,8 +35,8 @@ 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.";
default.value = [ default.value = [
"x86_64-linux"
"i686-linux" "i686-linux"
"x86-64_linux"
]; ];
}; };
}; };
@ -65,9 +66,8 @@ 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"

View file

@ -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 {
@ -34,8 +35,8 @@ in
description = "Platforms the package supports."; description = "Platforms the package supports.";
# TODO: Support more platforms. # TODO: Support more platforms.
default.value = [ default.value = [
"x86_64-linux"
"i686-linux" "i686-linux"
"x86-64_linux"
]; ];
}; };
}; };

View file

@ -33,8 +33,8 @@ 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.";
default.value = [ default.value = [
"x86_64-linux"
"i686-linux" "i686-linux"
"x86-64_linux"
]; ];
}; };
}; };

View file

@ -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

View file

@ -33,8 +33,8 @@ 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.";
default.value = [ default.value = [
"x86_64-linux"
"i686-linux" "i686-linux"
"x86-64_linux"
]; ];
}; };
}; };

View file

@ -33,8 +33,8 @@ 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.";
default.value = [ default.value = [
"x86_64-linux"
"i686-linux" "i686-linux"
"x86-64_linux"
]; ];
}; };
}; };

View file

@ -33,8 +33,8 @@ 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.";
default.value = [ default.value = [
"x86_64-linux"
"i686-linux" "i686-linux"
"x86-64_linux"
]; ];
}; };

View file

@ -33,8 +33,8 @@ 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.";
default.value = [ default.value = [
"x86_64-linux"
"i686-linux" "i686-linux"
"x86-64_linux"
]; ];
}; };
}; };

View file

@ -34,8 +34,8 @@ 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.";
default.value = [ default.value = [
"x86_64-linux"
"i686-linux" "i686-linux"
"x86-64_linux"
]; ];
}; };
}; };

View file

@ -33,8 +33,8 @@ 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.";
default.value = [ default.value = [
"x86_64-linux"
"i686-linux" "i686-linux"
"x86-64_linux"
]; ];
}; };

View file

@ -34,8 +34,8 @@ 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.";
default.value = [ default.value = [
"x86_64-linux"
"i686-linux" "i686-linux"
"x86-64_linux"
]; ];
}; };
}; };

View file

@ -33,8 +33,8 @@ 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.";
default.value = [ default.value = [
"x86_64-linux"
"i686-linux" "i686-linux"
"x86-64_linux"
]; ];
}; };
}; };

View file

@ -33,8 +33,8 @@ 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.";
default.value = [ default.value = [
"x86_64-linux"
"i686-linux" "i686-linux"
"x86-64_linux"
]; ];
}; };

View file

@ -33,8 +33,8 @@ 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.";
default.value = [ default.value = [
"x86_64-linux"
"i686-linux" "i686-linux"
"x86-64_linux"
]; ];
}; };

View file

@ -33,8 +33,8 @@ 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.";
default.value = [ default.value = [
"x86_64-linux"
"i686-linux" "i686-linux"
"x86-64_linux"
]; ];
}; };
}; };

View file

@ -34,8 +34,8 @@ 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.";
default.value = [ default.value = [
"x86_64-linux"
"i686-linux" "i686-linux"
"x86-64_linux"
]; ];
}; };
}; };

View file

@ -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;

View file

@ -25,50 +25,53 @@ let
./src/versions/default.test.nix ./src/versions/default.test.nix
]; ];
resolve = resolve = file: let
file:
let
imported = import file; imported = import file;
value = if builtins.isFunction imported then imported { inherit lib; } else imported; value =
if builtins.isFunction imported
then imported {inherit lib;}
else imported;
relative = lib.strings.removePrefix (builtins.toString root) (builtins.toString file); relative = lib.strings.removePrefix (builtins.toString root) (builtins.toString file);
in in {
{
inherit file value; inherit file value;
relative = if lib.strings.hasPrefix "/" relative then "." + relative else relative; relative =
if lib.strings.hasPrefix "/" relative
then "." + relative
else relative;
namespace = getNamespace file; namespace = getNamespace file;
}; };
resolved = builtins.map resolve files; resolved = builtins.map resolve files;
getNamespace = getNamespace = path: let
path:
let
relative = lib.strings.removePrefix (builtins.toString root) (builtins.toString path); relative = lib.strings.removePrefix (builtins.toString root) (builtins.toString path);
parts = lib.strings.split "/" relative; parts = lib.strings.split "/" relative;
in in
if builtins.length parts > 2 then builtins.elemAt parts 2 else relative; if builtins.length parts > 2
then builtins.elemAt parts 2
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:
let
nested = lib.attrs.mapToList (name: value: getTests file (prefix ++ [ name ]) value) suite;
relative = lib.strings.removePrefix (builtins.toString root) (builtins.toString file); relative = lib.strings.removePrefix (builtins.toString root) (builtins.toString file);
in in
if builtins.isAttrs suite then if builtins.isAttrs suite
builtins.concatLists nested then builtins.concatLists nested
else else [
[
{ {
inherit prefix file; inherit prefix file;
name = builtins.concatStringsSep " > " prefix; name = builtins.concatStringsSep " > " prefix;
value = suite; value = suite;
relative = if lib.strings.hasPrefix "/" relative then "." + relative else relative; relative =
if lib.strings.hasPrefix "/" relative
then "." + relative
else relative;
} }
]; ];
base = builtins.map (entry: getTests entry.file [ entry.namespace ] entry.value) resolved; base =
builtins.map (entry: getTests entry.file [entry.namespace] entry.value) resolved;
in in
builtins.concatLists base; builtins.concatLists base;
@ -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}

View file

@ -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;
};
} }

View file

@ -10,76 +10,66 @@ 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
process =
path:
builtins.zipAttrsWith ( builtins.zipAttrsWith (
name: values: name: values: let
let currentPath = path ++ [name];
currentPath = path ++ [ name ];
isSingleValue = builtins.length values == 1; isSingleValue = builtins.length values == 1;
isComplete = predicate currentPath (builtins.elemAt values 1) (builtins.elemAt values 0); isComplete =
predicate currentPath
(builtins.elemAt values 1)
(builtins.elemAt values 0);
in in
if isSingleValue then if isSingleValue
builtins.elemAt values 0 then builtins.elemAt values 0
else if isComplete then else if isComplete
builtins.elemAt values 1 then builtins.elemAt values 1
else else process currentPath values
process currentPath values
); );
in in
process [ ] [ process [] [x y];
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:
let
name = builtins.head path; name = builtins.head path;
rest = builtins.tail path; rest = builtins.tail path;
in in
if path == [ ] then if path == []
target then target
else if target ? ${name} then else if target ? ${name}
lib.attrs.select rest fallback target.${name} then lib.attrs.select rest fallback target.${name}
else else fallback;
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:
let
pathAsString = builtins.concatStringsSep "." path; pathAsString = builtins.concatStringsSep "." path;
error = builtins.throw "Path not found in attribute set: ${pathAsString}"; error = builtins.throw "Path not found in attribute set: ${pathAsString}";
in in
if lib.attrs.has path target then lib.attrs.select path null target else error; if lib.attrs.has path target
then lib.attrs.select path null target
else error;
## Zip specific attributes from a list of attribute sets. ## Zip specific attributes from a list of attribute sets.
## ##
## @type List String -> (List Any -> Any) -> List Attrs -> Attrs ## @type List String -> (List Any -> Any) -> List Attrs -> Attrs
zipWithNames = zipWithNames = names: f: list: let
names: f: list:
let
transform = name: { transform = name: {
inherit name; inherit name;
value = f name (builtins.catAttrs name list); value = f name (builtins.catAttrs name list);
@ -91,26 +81,18 @@ lib: {
## 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
process =
name: values:
let
first = builtins.elemAt values 0; first = builtins.elemAt values 0;
second = builtins.elemAt values 1; second = builtins.elemAt values 1;
in in
if builtins.length values == 1 then if builtins.length values == 1
false then false
else if builtins.isAttrs first then else if builtins.isAttrs first
builtins.isAttrs second && lib.attrs.match first second then builtins.isAttrs second && lib.attrs.match first second
else else first == second;
first == second;
result = lib.attrs.zipWithNames (builtins.attrNames pattern) process [ result = lib.attrs.zipWithNames (builtins.attrNames pattern) process [pattern value];
pattern
value
];
in 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";
@ -119,80 +101,78 @@ lib: {
## 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:
let
length = builtins.length path; length = builtins.length path;
process = process = depth:
depth: if depth == length then value else { ${builtins.elemAt path depth} = process (depth + 1); }; if depth == length
then value
else {
${builtins.elemAt path depth} = process (depth + 1);
};
in in
process 0; process 0;
## Check if a path exists in an attribute set. ## Check if a path exists in an attribute set.
## ##
## @type (List String) -> Attrs -> Bool ## @type (List String) -> Attrs -> Bool
has = has = path: target: let
path: target:
let
name = builtins.head path; name = builtins.head path;
rest = builtins.tail path; rest = builtins.tail path;
in in
if path == [ ] then if path == []
true then true
else if target ? ${name} then else if target ? ${name}
lib.attrs.has rest target.${name} then lib.attrs.has rest target.${name}
else else false;
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
process =
path:
builtins.mapAttrs ( builtins.mapAttrs (
name: value: name: value:
if builtins.isAttrs value && predicate value then if builtins.isAttrs value && predicate value
process (path ++ [ name ]) value then process (path ++ [name]) value
else else f (path ++ [name]) value
f (path ++ [ name ]) value
); );
in in
process [ ] target; 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:
let
names = builtins.attrNames target; names = builtins.attrNames target;
process = process = name: let
name:
let
value = target.${name}; value = target.${name};
in in
if predicate name value then [ { inherit name value; } ] else [ ]; if predicate name value
then [{inherit name value;}]
else [];
valid = builtins.concatMap process names; valid = builtins.concatMap process names;
in in
builtins.listToAttrs valid; builtins.listToAttrs valid;
@ -201,13 +181,13 @@ lib: {
## 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; })
names;
in in
builtins.listToAttrs pairs; builtins.listToAttrs pairs;
}; };

View file

@ -1,62 +1,54 @@
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 = {
x.y.z = 1;
};
actual = lib.attrs.mergeRecursiveUntil (
path: x: y:
lib.lists.last path == "z"
) { x.y.z = 2; } { x.y.z = 1; };
in
actual == expected;
"handles shallow merges" =
let
expected = { expected = {
x.y.z = 1; x.y.z = 1;
}; };
actual = actual =
lib.attrs.mergeRecursiveUntil lib.attrs.mergeRecursiveUntil
( (path: x: y: lib.lists.last path == "z")
path: x: y: {x.y.z = 2;}
true {x.y.z = 1;};
) in
actual == expected;
"handles shallow merges" = let
expected = {
x.y.z = 1;
};
actual =
lib.attrs.mergeRecursiveUntil
(path: x: y: true)
{ {
x = { x = {
y.z = 2; y.z = 2;
@ -64,36 +56,38 @@ in
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 = lib.attrs.mergeRecursive { x.y.z = 2; } { x.y.z = 1; }; actual =
lib.attrs.mergeRecursive
{x.y.z = 2;}
{x.y.z = 1;};
in in
actual == expected; actual == expected;
}; };
"select" = { "select" = {
"selects a nested value" = "selects a nested value" = let
let
expected = "value"; expected = "value";
actual = lib.attrs.select [ actual =
"x" lib.attrs.select
"y" ["x" "y" "z"]
"z" null
] 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 = { x = {
y = { y = {
@ -101,7 +95,11 @@ in
}; };
}; };
}; };
actual = lib.attrs.select [ ] null { actual =
lib.attrs.select
[]
null
{
x = { x = {
y = { y = {
z = 1; z = 1;
@ -111,32 +109,30 @@ in
in in
actual == expected; actual == expected;
"handles fallback value" = "handles fallback value" = let
let
expected = "fallback"; expected = "fallback";
actual = lib.attrs.select [ actual =
"x" lib.attrs.select
"y" ["x" "y" "z"]
"z" expected
] expected { }; {};
in in
actual == expected; actual == expected;
}; };
"selectOrThrow" = { "selectOrThrow" = {
"selects a nested value" = "selects a nested value" = let
let
expected = "value"; expected = "value";
actual = lib.attrs.selectOrThrow [ actual =
"x" lib.attrs.selectOrThrow
"y" ["x" "y" "z"]
"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 = { x = {
y = { y = {
@ -144,7 +140,10 @@ in
}; };
}; };
}; };
actual = lib.attrs.selectOrThrow [ ] { actual =
lib.attrs.selectOrThrow
[]
{
x = { x = {
y = { y = {
z = 1; z = 1;
@ -154,13 +153,11 @@ in
in 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
@ -168,8 +165,7 @@ in
}; };
"set" = { "set" = {
"creates a nested set" = "creates a nested set" = let
let
expected = { expected = {
x = { x = {
y = { y = {
@ -177,69 +173,50 @@ in
}; };
}; };
}; };
actual = lib.attrs.set [ actual = lib.attrs.set ["x" "y" "z"] 1;
"x"
"y"
"z"
] 1;
in 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 [
"x"
"y"
"z"
] { x.y.z = 1; };
in 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 [
"x"
"y"
"z"
] { };
in 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";
@ -250,7 +227,10 @@ in
value = 2; value = 2;
} }
]; ];
actual = lib.attrs.mapToList (name: value: { inherit name value; }) { actual =
lib.attrs.mapToList
(name: value: {inherit name value;})
{
x = 1; x = 1;
y = 2; y = 2;
}; };
@ -259,8 +239,7 @@ in
}; };
"mapRecursiveWhen" = { "mapRecursiveWhen" = {
"maps a set recursively" = "maps a set recursively" = let
let
expected = { expected = {
x = { x = {
y = { y = {
@ -268,7 +247,11 @@ in
}; };
}; };
}; };
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;
@ -278,8 +261,7 @@ in
in in
actual == expected; actual == expected;
"maps a set given a condition" = "maps a set given a condition" = let
let
expected = { expected = {
x = { x = {
y = { y = {
@ -288,12 +270,13 @@ in
}; };
}; };
actual = actual =
lib.attrs.mapRecursiveWhen (value: !(value ? z)) lib.attrs.mapRecursiveWhen
( (value: !(value ? z))
path: value: (path: value:
# We map before we get to a non-set value # We map before we get to a non-set value
if builtins.isAttrs value then value else value + 1 if builtins.isAttrs value
) then value
else value + 1)
{ {
x = { x = {
y = { y = {
@ -306,8 +289,7 @@ in
}; };
"mapRecursive" = { "mapRecursive" = {
"maps a set recursively" = "maps a set recursively" = let
let
expected = { expected = {
x = { x = {
y = { y = {
@ -315,7 +297,10 @@ in
}; };
}; };
}; };
actual = lib.attrs.mapRecursive (path: value: value + 1) { actual =
lib.attrs.mapRecursive
(path: value: value + 1)
{
x = { x = {
y = { y = {
z = 1; z = 1;
@ -327,12 +312,14 @@ in
}; };
"filter" = { "filter" = {
"filters a set" = "filters a set" = let
let
expected = { expected = {
y = 2; y = 2;
}; };
actual = lib.attrs.filter (name: value: name == "y") { actual =
lib.attrs.filter
(name: value: name == "y")
{
x = 1; x = 1;
y = 2; y = 2;
}; };

View file

@ -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.
## ##

View file

@ -1,18 +1,15 @@
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
@ -20,14 +17,12 @@ in
}; };
"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
@ -36,15 +31,13 @@ in
}; };
"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
@ -52,61 +45,51 @@ in
}; };
"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 in {
{ "returns true when both are true" = let
"returns true when both are true" =
let
expected = true; expected = true;
actual = lib.bools.and' getTrue getTrue null; actual = lib.bools.and' getTrue getTrue null;
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' 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
@ -114,58 +97,48 @@ in
}; };
"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 in {
{ "returns true when both are true" = let
"returns true when both are true" =
let
expected = true; expected = true;
actual = lib.bools.or' getTrue getTrue null; actual = lib.bools.or' getTrue getTrue null;
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' getTrue getFalse null; actual = lib.bools.or' getTrue getFalse null;
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' getFalse getTrue null; actual = lib.bools.or' getFalse getTrue 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.or' getFalse getFalse null; actual = lib.bools.or' getFalse getFalse null;
in in
@ -173,15 +146,13 @@ in
}; };
"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

View file

@ -4,30 +4,31 @@ 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:
let
isContentsValid = builtins.all lib.dag.validate.entry (builtins.attrValues value); isContentsValid = builtins.all lib.dag.validate.entry (builtins.attrValues value);
in in
builtins.isAttrs value && 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 in
builtins.attrNames before; builtins.attrNames before;
@ -45,15 +46,16 @@ lib: {
sorted = lib.lists.sort.topographic isBefore entries; sorted = lib.lists.sort.topographic isBefore entries;
in in
if sorted ? result then if sorted ? result
{ then {
result = builtins.map (value: { result =
builtins.map (value: {
name = value.name; name = value.name;
value = value.value; value = value.value;
}) sorted.result; })
sorted.result;
} }
else else sorted;
sorted;
}; };
apply = { apply = {
@ -61,27 +63,28 @@ 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;
}; };
@ -89,67 +92,78 @@ lib: {
## 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
process =
i: before: after: entries:
let
name = "${tag}-${builtins.toString i}"; name = "${tag}-${builtins.toString i}";
entry = builtins.head entries; entry = builtins.head entries;
rest = builtins.tail entries; rest = builtins.tail entries;
in in
if builtins.length entries == 0 then if builtins.length entries == 0
{ } then {}
else if builtins.length entries == 1 then else if builtins.length entries == 1
{ "${name}" = lib.dag.entry.between before after entry; } then {
"${name}" = lib.dag.entry.between before after entry;
}
else else
{ "${name}" = lib.dag.entry.after after entry; } // (process (i + 1) before [ name ] rest); {
"${name}" = lib.dag.entry.after after entry;
}
// (
process (i + 1) before [name] rest
);
in in
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 [];
}; };
}; };
} }

View file

@ -1,117 +1,94 @@
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 { x = { }; }; actual = lib.dag.validate.graph {
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" [ ] [ ] [ graph = lib.dag.entries.between "example" [] [] [null null];
null
null
];
actual = lib.dag.validate.graph graph; actual = lib.dag.validate.graph graph;
in in
actual == expected; actual == expected;
"entries.anywhere" = "entries.anywhere" = let
let
expected = true; expected = true;
graph = lib.dag.entries.anywhere "example" [ graph = lib.dag.entries.anywhere "example" [null null];
null
null
];
actual = lib.dag.validate.graph graph; actual = lib.dag.validate.graph graph;
in in
actual == expected; actual == expected;
"entries.before" = "entries.before" = let
let
expected = true; expected = true;
graph = lib.dag.entries.before "example" [ ] [ graph = lib.dag.entries.before "example" [] [null null];
null
null
];
actual = lib.dag.validate.graph graph; actual = lib.dag.validate.graph graph;
in in
actual == expected; actual == expected;
"entries.after" = "entries.after" = let
let
expected = true; expected = true;
graph = lib.dag.entries.after "example" [ ] [ graph = lib.dag.entries.after "example" [] [null null];
null
null
];
actual = lib.dag.validate.graph graph; actual = lib.dag.validate.graph graph;
in in
actual == expected; actual == expected;
@ -120,15 +97,13 @@ in
"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";
@ -149,9 +124,9 @@ in
]; ];
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;

View file

@ -29,9 +29,7 @@ let
## definitions. ## definitions.
## ##
## @type (a -> a) -> a ## @type (a -> a) -> a
fix = fix = f: let
f:
let
x = f x; x = f x;
in in
x; x;
@ -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
process =
path:
builtins.zipAttrsWith ( builtins.zipAttrsWith (
name: values: name: values: let
let currentPath = path ++ [name];
currentPath = path ++ [ name ];
isSingleValue = builtins.length values == 1; isSingleValue = builtins.length values == 1;
isComplete = predicate currentPath (builtins.elemAt values 1) (builtins.elemAt values 0); isComplete =
predicate currentPath
(builtins.elemAt values 1)
(builtins.elemAt values 0);
in in
if isSingleValue || isComplete then builtins.elemAt values 0 else process currentPath values if isSingleValue || isComplete
then builtins.elemAt values 0
else process currentPath values
); );
in in
process [ ] [ process [] [x y];
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
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)

View file

@ -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 (
final: prev:
prev
// {
__injected__ = true; __injected__ = true;
fp = prev.fp // { fp = prev.fp // {
__injected__ = true; __injected__ = true;
}; };
} });
);
in in
result ? __injected__ && result.fp ? __injected__ && result.fp ? const; result ? __injected__
&& result.fp ? __injected__
&& result.fp ? const;
}; };
} }

View file

@ -5,6 +5,9 @@ lib: {
## ##
## @notest ## @notest
## @type Bool -> String -> Bool ## @type Bool -> String -> Bool
trace = condition: message: if condition then true else builtins.trace message false; trace = condition: message:
if condition
then true
else builtins.trace message false;
}; };
} }

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