fix(home): forward exported hm args

Resolve exported home configurations against their parent system config so hosted and bare-name homes keep the same Home Manager specialArgs on package and homeConfiguration export paths. This restores arbitrary home-manager.extraSpecialArgs keys instead of only hardcoded aliases and adds regression coverage for the export resolver.
This commit is contained in:
anntnzrb
2026-03-07 22:51:26 -05:00
committed by mjallen18
parent 0c9d9c5919
commit 13bdc883da
2 changed files with 160 additions and 24 deletions

View File

@@ -107,6 +107,54 @@
inherit system;
};
standalone-special-args = standalone-home.specialArgs;
exported-home-name = "test@${system}";
resolved-exported-home = lib.snowfall.flake.resolve-exported-home {
home-name = exported-home-name;
home = {
modules = [ ];
inherit system;
specialArgs = {
host = "";
user = "test";
standaloneOnly = true;
};
builder = args: args.specialArgs;
};
systems = {
test-host = {
output = "nixosConfigurations";
inherit system;
};
};
flake-outputs = {
nixosConfigurations = {
test-host = {
config = {
hostName = "test-host";
home-manager = {
users.test = { };
extraSpecialArgs = {
arbitraryName = "ok";
};
};
};
};
};
homeConfigurations = {
${exported-home-name} = {
fallback = true;
};
};
};
};
bare-name-package-alias =
"homeConfigurations-"
+ (
if pkgs.lib.hasSuffix "@${system}" exported-home-name then
pkgs.lib.removeSuffix "@${system}" exported-home-name
else
exported-home-name
);
eval = builtins.tryEval {
snowfall-attrs = builtins.attrNames lib.snowfall;
has-standalone-home-placeholders =
@@ -115,13 +163,33 @@
&& (standalone-special-args ? systemConfig)
&& (standalone-special-args.systemConfig == null);
has-system-config-aliases =
(builtins.length (builtins.split "systemConfig = config;" (builtins.readFile ./modules/nixos/user/default.nix)) > 1)
&& (builtins.length (builtins.split "systemConfig = config;" (builtins.readFile ./modules/darwin/user/default.nix)) > 1);
(
builtins.length (
builtins.split "systemConfig = config;" (builtins.readFile ./modules/nixos/user/default.nix)
) > 1
)
&& (
builtins.length (
builtins.split "systemConfig = config;" (builtins.readFile ./modules/darwin/user/default.nix)
) > 1
);
resolves-exported-home-extra-special-args =
resolved-exported-home ? arbitraryName
&& (resolved-exported-home.arbitraryName == "ok")
&& (resolved-exported-home ? systemConfig)
&& (resolved-exported-home.systemConfig.hostName == "test-host")
&& (resolved-exported-home ? osConfig)
&& (resolved-exported-home.osConfig.hostName == "test-host")
&& (resolved-exported-home ? standaloneOnly)
&& resolved-exported-home.standaloneOnly;
strips-bare-home-package-alias = bare-name-package-alias == "homeConfigurations-test";
};
in
assert eval.success;
assert eval.value.has-standalone-home-placeholders;
assert eval.value.has-system-config-aliases;
assert eval.value.resolves-exported-home-extra-special-args;
assert eval.value.strips-bare-home-package-alias;
{
snowfall-lib-eval = pkgs.runCommand "snowfall-lib-eval" { } "mkdir -p $out";
}