refactor: namespace builders

This commit is contained in:
Jake Hamilton 2025-09-14 09:27:13 -07:00
parent f4f1f0aea7
commit 6854e9ccac
Signed by: jakehamilton
GPG key ID: 9762169A1B35EA68
80 changed files with 191 additions and 147 deletions

View file

@ -50,5 +50,5 @@ let
in
new [
./src/packages
./src/builders/basic.nix
./src/builders/foundation/basic.nix
]

View file

@ -4,13 +4,13 @@ let
in
{
includes = [
./passthrough.nix
./foundation
];
options = {
builders = lib.options.create {
description = "A set of builders that can be used to build packages.";
type = lib.types.attrs.of lib.types.builder;
type = lib.types.attrs.of (lib.types.attrs.of lib.types.builder);
default.value = { };
};
};

View file

@ -8,7 +8,7 @@ let
pretty = lib.generators.pretty { };
in
{
config.builders.basic = {
config.builders.foundation.basic = {
build =
package:
let
@ -52,7 +52,13 @@ in
sorted = lib.dag.sort.topological phases;
script = lib.strings.concatMapSep "\n" (entry: entry.value) sorted.result;
script = lib.strings.concatMapSep "\n"
(entry: ''
# Phase: ${entry.name}
# ====================================================
${entry.value}
'')
sorted.result;
executable =
if system == "i686-linux" then
@ -74,6 +80,8 @@ in
inherit (package) name;
inherit script system;
outputs = builtins.attrNames (lib.packages.getOutputs package);
passAsFile = [ "script" ];
SHELL = executable;

View file

@ -0,0 +1,9 @@
{
includes = [
# We explicitly don't include `basic` here to let users create package sets which do not
# include anything from `packages.foundation`.
# ./basic.nix
./passthrough.nix
];
}

View file

@ -6,7 +6,7 @@ let
inherit (config.internal.packages) foundation;
in
{
config.builders.passthrough =
config.builders.foundation.passthrough =
{ config }:
{
options = {

View file

@ -209,6 +209,16 @@ in
in
builtins.head sorted;
getOutputs = alias:
let
package = lib.packages.resolve alias;
outputs = if builtins.isList package.outputs then
lib.attrs.generate package.outputs (output: package.package.${output})
else
package.outputs;
in
outputs;
resolve =
alias:
if alias ? versions then

View file

@ -796,76 +796,6 @@ in
type = lib.types.builder;
};
# builder = lib.options.create {
# description = "The builder for the package.";
# type =
# let
# initial = lib.types.withCheck lib.types.raw (
# value:
# let
# builder = global.config.builders.${value.name} or null;
# in
# if builder == null then
# builtins.throw "Builder `${
# lib.options.getIdentifier [
# "builders"
# value.name
# ]
# }` for `${
# lib.options.getIdentifier [
# "packages"
# config.namespace
# config.id
# "versions"
# config.version
# ]
# }` is used but not defined."
# else
# value ? name && value ? build
# );
#
# transform =
# value:
# if value ? settings.__type__ then
# value
# // {
# settings = { };
# }
# else
# value;
#
# final = lib.types.withCheck lib.types.raw (
# value:
# let
# builder = global.config.builders.${value.name} or null;
# results = lib.attrs.mapToList (
# name: option:
# if option.type.check value.settings.${name} then
# true
# else
# builtins.throw "The option `${
# lib.options.getIdentifier [
# "packages"
# config.namespace
# config.id
# "versions"
# config.version
# "builder"
# "settings"
# name
# ]
# }` is not of type ${option.type.description}."
# ) builder.settings;
# checked = builtins.foldl' (acc: result: builtins.seq result acc) true results;
# in
# if value ? settings.__type__ then false else checked
# );
#
# coerced = lib.types.coerce initial transform final;
# in
# coerced;
# };
src = lib.options.create {
description = "The source for the package.";
type =
@ -881,6 +811,23 @@ in
default.value = null;
};
outputs = lib.options.create {
description = "The outputs for the package.";
type = let
initial = lib.types.attrs.of lib.types.derivation;
transform = builtins.attrNames;
final = lib.types.list.of lib.types.string;
in
lib.types.coerce initial transform final;
default.value = [ "out" ];
apply = outputs:
lib.attrs.generate
outputs
(output: config.package.${output});
};
env = lib.options.create {
description = "The environment for the package.";
type = lib.types.attrs.of lib.types.string;

View file

@ -0,0 +1,61 @@
# Core Packages
The goal of Core packages is to build commonly required software in addition to a Nix
implementation (Lix).
## Lix
In order to build Lix, we first need to package its dependencies:
- `aws-sdk-cpp`
- `boehmgc`
- `boehmgc-nix`
- `boost`
- `brotli`
- `build-release-notes`
- `busybox-sandbox-shell`
- `bzip2`
- `capnproto`
- `cmake`
- `curl`
- `doxygen`
- `editline`
- `editline-lix`
- `git`
- `gtest`
- `gcc`
- `glibc`
- `binutils`
- `python` (with `python-frontmatter`, `pycapnp`)
- `jq`
- `libarchive`
- `libcpuid`
- `libseccomp`
- `libsystemtap`
- `lowdown`
- `lowdown-unsandboxed`
- `lsof`
- `mdbook`
- `mdbook-linkcheck`
- `mercurial`
- `meson`
- `ncurses`
- `ninja`
- `nlohmann_json`
- `openssl`
- `passt-lix`
- `pegtl`
- `pkg-config`
- `python3`
- `rapidcheck`
- `removeReferencesTo`
- `rustc`
- `rustPlatform`
- `sqlite`
- `systemtap-lix`
- `toml11`
- `toml11-lix`
- `util-linuxMinimal`
- `utillinuxMinimal`
- `xz`
- `yq`

View file

@ -0,0 +1,5 @@
{
includes = [
./lix
];
}

View file

@ -0,0 +1,3 @@
{
config.packages.lix.lix = { };
}

View file

@ -5,6 +5,7 @@ in
{
includes = [
./aux
./core
./foundation
];

View file

@ -34,7 +34,7 @@ in
target = "@build";
};
builder = builders.passthrough.extend {
builder = builders.foundation.passthrough.extend {
settings = {
derivation = package.package;
};

View file

@ -39,7 +39,7 @@ in
}
];
builder = builders.basic;
builder = builders.foundation.basic;
src = builtins.fetchurl {
url = "${mirrors.gnu}/bash/bash-${version}.tar.gz";

View file

@ -18,7 +18,7 @@ in
target = "i686-linux";
};
builder = builders.passthrough.extend {
builder = builders.foundation.passthrough.extend {
settings = {
derivation = foundation.stage2-binutils;
};

View file

@ -35,7 +35,7 @@ in
}
];
builder = builders.passthrough.extend {
builder = builders.foundation.passthrough.extend {
settings = {
derivation = package.package;
};

View file

@ -78,7 +78,7 @@ in
}
];
builder = builders.basic;
builder = builders.foundation.basic;
src = builtins.fetchurl {
url = "${mirrors.gnu}/binutils/binutils-${version}.tar.xz";

View file

@ -18,7 +18,7 @@ in
target = "i686-linux";
};
builder = builders.passthrough.extend {
builder = builders.foundation.passthrough.extend {
settings = {
derivation = foundation.stage1-bison;
};

View file

@ -31,7 +31,7 @@ in
target = "x86_64-linux";
};
builder = builders.passthrough.extend {
builder = builders.foundation.passthrough.extend {
settings = {
derivation = package.package;
};

View file

@ -31,7 +31,7 @@ in
target = "x86_64-linux";
};
builder = builders.basic;
builder = builders.foundation.basic;
src = builtins.fetchurl {
url = "${mirrors.gnu}/bison/bison-${version}.tar.xz";

View file

@ -1,8 +1,8 @@
{ config, global }:
let
inherit (global) lib packages builders;
inherit (global.internal.packages) foundation;
inherit (global) lib packages builders. foundation.
inherit ( global. internal. packages) foundation;
in
{
config = {
@ -18,7 +18,7 @@ in
target = "i686-linux";
};
builder = builders.passthrough.extend {
builder = builders.foundation.passthrough.extend {
settings = {
derivation = foundation.stage2-busybox;
};

View file

@ -18,7 +18,7 @@ in
target = "i686-linux";
};
builder = builders.passthrough.extend {
builder = builders.foundation.passthrough.extend {
settings = {
derivation = foundation.stage2-bzip2;
};

View file

@ -33,7 +33,7 @@ in
target = "@build";
};
builder = builders.passthrough.extend {
builder = builders.foundation.passthrough.extend {
settings = {
derivation = package.package;
};

View file

@ -43,7 +43,7 @@ in
}
];
builder = builders.basic;
builder = builders.foundation.basic;
src = builtins.fetchurl {
url = "https://sourceware.org/pub/bzip2/bzip2-${version}.tar.gz";

View file

@ -18,7 +18,7 @@ in
target = "i686-linux";
};
builder = builders.passthrough.extend {
builder = builders.foundation.passthrough.extend {
settings = {
derivation = foundation.stage2-coreutils;
};

View file

@ -33,7 +33,7 @@ in
target = "@build";
};
builder = builders.passthrough.extend {
builder = builders.foundation.passthrough.extend {
settings = {
derivation = package.package;
};

View file

@ -50,7 +50,7 @@ in
}
];
builder = builders.basic;
builder = builders.foundation.basic;
src = builtins.fetchurl {
url = "${mirrors.gnu}/coreutils/coreutils-${version}.tar.gz";

View file

@ -18,7 +18,7 @@ in
target = "i686-linux";
};
builder = builders.passthrough.extend {
builder = builders.foundation.passthrough.extend {
settings = {
derivation = foundation.stage2-diffutils;
};

View file

@ -33,7 +33,7 @@ in
target = "@build";
};
builder = builders.passthrough.extend {
builder = builders.foundation.passthrough.extend {
settings = {
derivation = package.package;
};

View file

@ -38,7 +38,7 @@ in
}
];
builder = builders.basic;
builder = builders.foundation.basic;
src = builtins.fetchurl {
url = "${mirrors.gnu}/diffutils/diffutils-${version}.tar.xz";

View file

@ -18,7 +18,7 @@ in
target = "i686-linux";
};
builder = builders.passthrough.extend {
builder = builders.foundation.passthrough.extend {
settings = {
derivation = foundation.stage2-findutils;
};

View file

@ -35,7 +35,7 @@ in
}
];
builder = builders.passthrough.extend {
builder = builders.foundation.passthrough.extend {
settings = {
derivation = package.package;
};

View file

@ -38,7 +38,7 @@ in
}
];
builder = builders.basic;
builder = builders.foundation.basic;
src = builtins.fetchurl {
url = "${mirrors.gnu}/findutils/findutils-${version}.tar.xz";

View file

@ -20,7 +20,7 @@ in
}
];
builder = builders.passthrough.extend {
builder = builders.foundation.passthrough.extend {
settings = {
derivation = foundation.stage2-gawk;
};

View file

@ -35,7 +35,7 @@ in
}
];
builder = builders.passthrough.extend {
builder = builders.foundation.passthrough.extend {
settings = {
derivation = package.package;
};

View file

@ -38,7 +38,7 @@ in
}
];
builder = builders.basic;
builder = builders.foundation.basic;
src = builtins.fetchurl {
url = "${mirrors.gnu}/gawk/gawk-${version}.tar.gz";

View file

@ -23,7 +23,7 @@ in
target = "i686-linux";
};
builder = builders.passthrough.extend {
builder = builders.foundation.passthrough.extend {
settings = {
derivation = foundation.stage2-gcc;
};

View file

@ -78,7 +78,7 @@ in
target = "i686-linux";
};
builder = builders.basic;
builder = builders.foundation.basic;
gmp.version = "6.3.0";
mpfr.version = "4.2.1";

View file

@ -98,7 +98,7 @@ in
}
];
builder = builders.basic;
builder = builders.foundation.basic;
gmp.version = "6.3.0";
mpfr.version = "4.2.1";

View file

@ -93,7 +93,7 @@ in
}
];
builder = builders.basic;
builder = builders.foundation.basic;
gmp.version = "6.3.0";
mpfr.version = "4.2.1";

View file

@ -34,7 +34,7 @@ in
target = "@build";
};
builder = builders.passthrough.extend {
builder = builders.foundation.passthrough.extend {
settings = {
derivation = package.package;
};

View file

@ -94,7 +94,7 @@ in
}
];
builder = builders.basic;
builder = builders.foundation.basic;
gmp.version = "6.3.0";
mpfr.version = "4.2.1";

View file

@ -81,7 +81,7 @@ in
target = "@build";
};
builder = builders.basic;
builder = builders.foundation.basic;
gmp.version = "6.3.0";
mpfr.version = "4.2.1";

View file

@ -52,7 +52,7 @@ in
hooks = package.hooks;
builder = builders.passthrough.extend {
builder = builders.foundation.passthrough.extend {
settings = {
derivation = package.package;
};

View file

@ -38,7 +38,7 @@ in
target = "i686-linux";
};
builder = builders.basic;
builder = builders.foundation.basic;
src = builtins.fetchurl {
url = "${mirrors.gnu}/libc/glibc-${version}.tar.xz";

View file

@ -43,7 +43,7 @@ in
dynamicLinker = package.dynamicLinker;
builder = builders.passthrough.extend {
builder = builders.foundation.passthrough.extend {
settings = {
derivation = package.package;
};

View file

@ -46,7 +46,7 @@ in
}
];
builder = builders.basic;
builder = builders.foundation.basic;
src = builtins.fetchurl {
url = "${mirrors.gnu}/libc/glibc-${version}.tar.xz";

View file

@ -18,7 +18,7 @@ in
target = "i686-linux";
};
builder = builders.passthrough.extend {
builder = builders.foundation.passthrough.extend {
settings = {
derivation = foundation.stage2-gnugrep;
};

View file

@ -33,7 +33,7 @@ in
target = "@build";
};
builder = builders.passthrough.extend {
builder = builders.foundation.passthrough.extend {
settings = {
derivation = package.package;
};

View file

@ -38,7 +38,7 @@ in
}
];
builder = builders.basic;
builder = builders.foundation.basic;
src = builtins.fetchurl {
url = "${mirrors.gnu}/grep/grep-${version}.tar.xz";

View file

@ -18,7 +18,7 @@ in
target = "i686-linux";
};
builder = builders.passthrough.extend {
builder = builders.foundation.passthrough.extend {
settings = {
derivation = foundation.stage1-gnum4;
};

View file

@ -31,7 +31,7 @@ in
target = "x86_64-linux";
};
builder = builders.passthrough.extend {
builder = builders.foundation.passthrough.extend {
settings = {
derivation = package.package;
};

View file

@ -31,7 +31,7 @@ in
target = "x86_64-linux";
};
builder = builders.basic;
builder = builders.foundation.basic;
src = builtins.fetchurl {
url = "${mirrors.gnu}/m4/m4-${version}.tar.xz";

View file

@ -18,7 +18,7 @@ in
target = "i686-linux";
};
builder = builders.passthrough.extend {
builder = builders.foundation.passthrough.extend {
settings = {
derivation = foundation.stage2-gnumake;
};

View file

@ -33,7 +33,7 @@ in
target = "@build";
};
builder = builders.passthrough.extend {
builder = builders.foundation.passthrough.extend {
settings = {
derivation = package.package;
};

View file

@ -43,7 +43,7 @@ in
}
];
builder = builders.basic;
builder = builders.foundation.basic;
src = builtins.fetchurl {
url = "${mirrors.gnu}/make/make-${version}.tar.gz";

View file

@ -18,7 +18,7 @@ in
target = "i686-linux";
};
builder = builders.passthrough.extend {
builder = builders.foundation.passthrough.extend {
settings = {
derivation = foundation.stage2-gnupatch;
};

View file

@ -33,7 +33,7 @@ in
target = "@build";
};
builder = builders.passthrough.extend {
builder = builders.foundation.passthrough.extend {
settings = {
derivation = package.package;
};

View file

@ -38,7 +38,7 @@ in
}
];
builder = builders.basic;
builder = builders.foundation.basic;
src = builtins.fetchurl {
url = "${mirrors.gnu}/patch/patch-${version}.tar.xz";

View file

@ -18,7 +18,7 @@ in
target = "i686-linux";
};
builder = builders.passthrough.extend {
builder = builders.foundation.passthrough.extend {
settings = {
derivation = foundation.stage2-gnused;
};

View file

@ -33,7 +33,7 @@ in
target = "@build";
};
builder = builders.passthrough.extend {
builder = builders.foundation.passthrough.extend {
settings = {
derivation = package.package;
};

View file

@ -38,7 +38,7 @@ in
}
];
builder = builders.basic;
builder = builders.foundation.basic;
src = builtins.fetchurl {
url = "${mirrors.gnu}/sed/sed-${version}.tar.xz";

View file

@ -18,7 +18,7 @@ in
target = "i686-linux";
};
builder = builders.passthrough.extend {
builder = builders.foundation.passthrough.extend {
settings = {
derivation = foundation.stage2-gnutar;
};

View file

@ -33,7 +33,7 @@ in
target = "@build";
};
builder = builders.passthrough.extend {
builder = builders.foundation.passthrough.extend {
settings = {
derivation = package.package;
};

View file

@ -38,7 +38,7 @@ in
}
];
builder = builders.basic;
builder = builders.foundation.basic;
src = builtins.fetchurl {
url = "${mirrors.gnu}/tar/tar-${version}.tar.gz";

View file

@ -18,7 +18,7 @@ in
target = "i686-linux";
};
builder = builders.passthrough.extend {
builder = builders.foundation.passthrough.extend {
settings = {
derivation = foundation.stage2-gzip;
};

View file

@ -33,7 +33,7 @@ in
target = "@build";
};
builder = builders.passthrough.extend {
builder = builders.foundation.passthrough.extend {
settings = {
derivation = package.package;
};

View file

@ -43,7 +43,7 @@ in
}
];
builder = builders.basic;
builder = builders.foundation.basic;
src = builtins.fetchurl {
url = "${mirrors.gnu}/gzip/gzip-${version}.tar.xz";

View file

@ -17,7 +17,7 @@ in
target = "i686-linux";
};
builder = builders.passthrough.extend {
builder = builders.foundation.passthrough.extend {
settings = {
derivation = foundation.stage1-linux-headers;
};

View file

@ -25,7 +25,7 @@ in
target = "@build";
};
builder = builders.passthrough.extend {
builder = builders.foundation.passthrough.extend {
settings = {
derivation = package.package;
};

View file

@ -25,7 +25,7 @@ in
target = "@linux";
};
builder = builders.basic;
builder = builders.foundation.basic;
src = builtins.fetchurl {
url = "https://cdn.kernel.org/pub/linux/kernel/v${lib.versions.major version}.x/linux-${version}.tar.xz";

View file

@ -18,7 +18,7 @@ in
target = "i686-linux";
};
builder = builders.passthrough.extend {
builder = builders.foundation.passthrough.extend {
settings = {
derivation = foundation.stage1-musl;
};

View file

@ -24,7 +24,7 @@ in
target = [ "i686-linux" "x86_64-linux" ];
};
builder = builders.basic;
builder = builders.foundation.basic;
src = builtins.fetchurl {
url = "https://musl.libc.org/releases/musl-${config.version}.tar.gz";

View file

@ -18,7 +18,7 @@ in
target = "i686-linux";
};
builder = builders.passthrough.extend {
builder = builders.foundation.passthrough.extend {
settings = {
derivation = foundation.stage2-patchelf;
};

View file

@ -18,7 +18,7 @@ in
target = "i686-linux";
};
builder = builders.passthrough.extend {
builder = builders.foundation.passthrough.extend {
settings = {
derivation = foundation.stage1-python;
};

View file

@ -35,7 +35,7 @@ in
target = "@build";
};
builder = builders.basic;
builder = builders.foundation.basic;
src = builtins.fetchurl {
url = "https://www.python.org/ftp/python/${version}/Python-${version}.tar.xz";

View file

@ -21,7 +21,7 @@ in
target = "i686-linux";
};
builder = builders.passthrough.extend {
builder = builders.foundation.passthrough.extend {
settings = {
derivation = foundation.stage1-xz;
};

View file

@ -36,7 +36,7 @@ in
target = "@build";
};
builder = builders.passthrough.extend {
builder = builders.foundation.passthrough.extend {
settings = {
derivation = package.package;
};

View file

@ -41,7 +41,7 @@ in
}
];
builder = builders.basic;
builder = builders.foundation.basic;
src = builtins.fetchurl {
url = "https://tukaani.org/xz/xz-${version}.tar.gz";

View file

@ -18,7 +18,7 @@ in
target = "i686-linux";
};
builder = builders.passthrough.extend {
builder = builders.foundation.passthrough.extend {
settings = {
derivation = foundation.stage1-zlib;
};

View file

@ -31,7 +31,7 @@ in
target = "@build";
};
builder = builders.basic;
builder = builders.foundation.basic;
src = builtins.fetchurl {
url = "https://github.com/madler/zlib/releases/download/v${version}/zlib-${version}.tar.xz";