mirror of
https://github.com/mjallen18/snowfall-lib.git
synced 2026-04-18 09:05:58 -05:00
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:
72
flake.nix
72
flake.nix
@@ -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";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user