Compare commits

...

3 Commits

Author SHA1 Message Date
b11b6272fb refactor(dotfiles): apply natu ordering 2026-09-26 20:41:45 -04:00
8e38099117 merge: update natu dependency extraction 2026-09-26 20:40:52 -04:00
38dff04ece fix(natu): resolve inherited attributes 2026-09-26 20:27:48 -04:00
3 changed files with 68 additions and 44 deletions

View File

@@ -5,19 +5,6 @@
root,
}:
let
registry = import ./registry.nix {
inherit lib;
hosts = self.nixosConfigurations;
root = root + "/registry";
};
modules = import ./modules.nix {
inherit util;
root = root + "/modules";
};
util = import ./util.nix { inherit lib; };
specialArgs = {
inherit
inputs
@@ -27,6 +14,14 @@ let
registry = registry.collected;
};
util = import ./util.nix { inherit lib; };
registry = import ./registry.nix {
inherit lib;
hosts = self.nixosConfigurations;
root = root + "/registry";
};
guestModules = import ./guests.nix {
inherit
inputs
@@ -38,6 +33,11 @@ let
repositoryModules = modules;
root = root + "/guests";
};
modules = import ./modules.nix {
inherit util;
root = root + "/modules";
};
in
{
nixosConfigurations = import ./hosts.nix {

View File

@@ -34,6 +34,17 @@ let
inherit (evaluated.config) type replicate checks;
};
registryLib = lib // {
registry = (lib.registry or { }) // {
inherit predicates;
};
};
predicates = {
uniqueValue =
value: entries: builtins.length (lib.unique (map value entries)) == builtins.length entries;
};
registryDefinitionModule = {
options = {
type = lib.mkOption {
@@ -79,6 +90,15 @@ let
};
};
registryOption =
registry:
lib.mkOption {
type = lib.types.attrsOf (lib.types.attrsOf registry.type);
default = { };
description = ''
Lazily collected fleet-visible registry entries, nested by host and entry name.
'';
};
withOperations =
registry:
registry
@@ -188,27 +208,6 @@ let
) data
);
predicates = {
uniqueValue =
value: entries: builtins.length (lib.unique (map value entries)) == builtins.length entries;
};
registryLib = lib // {
registry = (lib.registry or { }) // {
inherit predicates;
};
};
registryOption =
registry:
lib.mkOption {
type = lib.types.attrsOf (lib.types.attrsOf registry.type);
default = { };
description = ''
Lazily collected fleet-visible registry entries, nested by host and entry name.
'';
};
in
{
types = lib.mapAttrs (_name: definition: definition.type) definitions;

View File

@@ -51,12 +51,7 @@ fn convert_expr(expr: rnix::ast::Expr) -> ast::Expr {
let_in.body().expect("let expressions have bodies"),
)),
},
rnix::ast::Expr::AttrSet(attr_set) => ast::Expr::AttrSet(
attr_set
.attrpath_values()
.filter_map(convert_binding_ast)
.collect(),
),
rnix::ast::Expr::AttrSet(attr_set) => ast::Expr::AttrSet(convert_attr_set(attr_set)),
rnix::ast::Expr::Lambda(lambda) => ast::Expr::Lambda {
parameters: lambda_parameters(&lambda),
body: Box::new(convert_expr(lambda.body().expect("lambdas have bodies"))),
@@ -77,10 +72,6 @@ fn convert_binding_ast(binding: rnix::ast::AttrpathValue) -> Option<ast::Binding
return None;
};
if attrs.next().is_some() {
return None;
}
Some(ast::Binding {
range: binding.syntax().text_range().into(),
key: key.into(),
@@ -88,6 +79,40 @@ fn convert_binding_ast(binding: rnix::ast::AttrpathValue) -> Option<ast::Binding
})
}
fn convert_attr_set(attr_set: rnix::ast::AttrSet) -> Vec<ast::Binding> {
attr_set
.entries()
.flat_map(|entry| match entry {
rnix::ast::Entry::AttrpathValue(binding) => {
convert_binding_ast(binding).into_iter().collect()
}
rnix::ast::Entry::Inherit(inherit) => convert_inherit(inherit),
})
.collect()
}
fn convert_inherit(inherit: rnix::ast::Inherit) -> Vec<ast::Binding> {
let value = inherit
.from()
.and_then(|from| from.expr())
.map(convert_expr);
inherit
.attrs()
.filter_map(|attr| match attr {
Attr::Ident(ident) => Some(ident),
_ => None,
})
.map(|key| ast::Binding {
range: key.syntax().text_range().into(),
value: value
.clone()
.unwrap_or_else(|| ast::Expr::Ident(key.clone().into())),
key: key.into(),
})
.collect()
}
fn lambda_parameters(lambda: &rnix::ast::Lambda) -> Vec<ast::Ident> {
match lambda.param() {
Some(rnix::ast::Param::IdentParam(parameter)) => {