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, nixpkgs,
nix-unit, nix-unit,
}: let }: let
# TODO: implement mix.extend and mix.isolate
inherit inherit
(mix) (mix)
extend
# isolate
newMixture newMixture
; ;
@ -35,6 +32,9 @@
inputs = { inputs = {
inherit mix; inherit mix;
flake = self; 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 # XXX: TODO: implement mix.extend instead of this
deps = { deps = {
inherit nixpkgs nix-unit; inherit nixpkgs nix-unit;
@ -42,20 +42,11 @@
}; };
}; };
# flake dependencies bootstrap = import ./nt/precursor/bootstrap;
# 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;
mix = import ./nt/mix/bootstrap.nix {this = bootstrap;}; mix = import ./nt/mix/bootstrap.nix {this = bootstrap;};
in in
newMixture inputs (mixture: { newMixture inputs (mixture: {
includes.public = [ includes.public = [
# XXX: TODO: implement mix.extend
# (extend ./flake deps)
./flake ./flake
./nt ./nt
]; ];

View file

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

View file

@ -1,9 +1,12 @@
{nt, ...}: let {nt, ...}: let
inherit inherit
(builtins) (builtins)
foldl'
isAttrs isAttrs
isFunction isFunction
listToAttrs isList
isPath
mapAttrs
typeOf typeOf
; ;
@ -11,11 +14,15 @@
(nt) (nt)
enfIsPrimitive enfIsPrimitive
hasInfix hasInfix
mergeAttrsList
nameValuePair
removeSuffix removeSuffix
; ;
inherit
(nt.naive.terminal)
isTerminal
unwrapTerminal
;
modNameFromPath = path: let modNameFromPath = path: let
name = baseNameOf path |> removeSuffix ".nix"; name = baseNameOf path |> removeSuffix ".nix";
in in
@ -40,22 +47,47 @@ in rec {
# TODO: create a better version of toString that can handle sets, lists, and null # TODO: create a better version of toString that can handle sets, lists, and null
assert isFunction mod assert isFunction mod
|| throw '' || 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. Got primitive type "${typeOf mod}" instead.
''; '';
assert isAttrs modResult assert isAttrs modResult
|| throw '' || 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." Got primitive return type "${typeOf modResult} instead."
''; modResult; ''; modResult;
mkIncludes = list: inputs: mkMod = pathDelegate: target: extraInputs: let
list this = delegate target;
|> map (path: (importMod path inputs)) inputs = {inherit this;} // extraInputs;
|> mergeAttrsList;
mkSubMods = list: inputs: delegate = target:
list # PATH
|> map (path: nameValuePair (modNameFromPath path) (importMod path inputs)) if isPath target
|> listToAttrs; 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 = { includes = {
public = [ public = [
./nt ./nt
# XXX: DEBUG: make this protected
./bootstrap
]; ];
protected = [ protected = [
# XXX: WARNING: reimplement std but typesafe # XXX: WARNING: reimplement std but typesafe
./bootstrap # ./bootstrap
]; ];
}; };
}) })