debugging mix bootstrapping hurts my brain

This commit is contained in:
Emile Clark-Boman 2026-02-09 13:36:35 +10:00
parent f1d4d7f3d6
commit fdc85fb3ff
4 changed files with 55 additions and 27 deletions

View file

@ -23,11 +23,8 @@
nixpkgs,
nix-unit,
}: let
# TODO: implement mix.extend and mix.isolate
inherit
(mix)
extend
# isolate
newMixture
;
@ -35,6 +32,9 @@
inputs = {
inherit mix;
flake = self;
# flake dependencies
# NOTE: the NixTypes library has no dependencies
# NOTE: but the developer tooling (for me) does
# XXX: TODO: implement mix.extend instead of this
deps = {
inherit nixpkgs nix-unit;
@ -42,20 +42,11 @@
};
};
# flake dependencies
# NOTE: the NixTypes library has no dependencies
# NOTE: but the developer tooling (for me) does
deps = {
inherit systems nixpkgs nix-unit;
};
bootstrap = import ./nt/primitives/std;
bootstrap = import ./nt/precursor/bootstrap;
mix = import ./nt/mix/bootstrap.nix {this = bootstrap;};
in
newMixture inputs (mixture: {
includes.public = [
# XXX: TODO: implement mix.extend
# (extend ./flake deps)
./flake
./nt
];

View file

@ -1,7 +1,10 @@
{mix, ...} @ inputs:
mix.newMixture inputs (mixture: {
isolated = true;
includes.public = [
./precursor
# (mix.isolate mix)
];
submods.public = [
./mix

View file

@ -1,9 +1,12 @@
{nt, ...}: let
inherit
(builtins)
foldl'
isAttrs
isFunction
listToAttrs
isList
isPath
mapAttrs
typeOf
;
@ -11,11 +14,15 @@
(nt)
enfIsPrimitive
hasInfix
mergeAttrsList
nameValuePair
removeSuffix
;
inherit
(nt.naive.terminal)
isTerminal
unwrapTerminal
;
modNameFromPath = path: let
name = baseNameOf path |> removeSuffix ".nix";
in
@ -40,22 +47,47 @@ in rec {
# TODO: create a better version of toString that can handle sets, lists, and null
assert isFunction mod
|| throw ''
Mix modules expect primitive type "set" or "lambda" (returning "set").
Imported Mix modules must be provided as primitive types "set" or "lambda" (returning "set").
Got primitive type "${typeOf mod}" instead.
'';
assert isAttrs modResult
|| throw ''
Mix module provided as primitive type "lambda" must return primitive type "set"!
Imported Mix module provided as primitive type "lambda" must return primitive type "set"!
Got primitive return type "${typeOf modResult} instead."
''; modResult;
mkIncludes = list: inputs:
list
|> map (path: (importMod path inputs))
|> mergeAttrsList;
mkMod = pathDelegate: target: extraInputs: let
this = delegate target;
inputs = {inherit this;} // extraInputs;
mkSubMods = list: inputs:
list
|> map (path: nameValuePair (modNameFromPath path) (importMod path inputs))
|> listToAttrs;
delegate = target:
# PATH
if isPath target
then pathDelegate target inputs
# LIST
else if isList target
then target |> foldl' (acc: el: acc // delegate el) {}
# TERMINAL
else if isTerminal target
then unwrapTerminal target
# ATTRS
else if isAttrs target
then target |> mapAttrs (_: value: delegate value)
# FUNCTION (OR FAIL)
else
assert isFunction target
|| throw ''
Mix module provided as invalid primitive type "${typeOf target}".
'';
target inputs;
in
this;
mkIncludes = target: inputs: mkMod importMod target inputs;
mkSubMods = target: inputs:
mkMod (path: inputs': {
${modNameFromPath path} = importMod path inputs';
})
target
inputs;
}

View file

@ -4,10 +4,12 @@ mix.newMixture inputs (mixture: {
includes = {
public = [
./nt
# XXX: DEBUG: make this protected
./bootstrap
];
protected = [
# XXX: WARNING: reimplement std but typesafe
./bootstrap
# ./bootstrap
];
};
})