1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2025-11-08 11:36:05 +01:00

home-environment: add home.checks (#7407)

This should have the same effect `system.checks` has in nixpkgs:
adds paths to the build closure without being becoming part of the
generated configuration.

This is useful for built-time checks as these should not leave a
trace in the built home configuration.

The implementation mirrors nixpkgs: add an unused argument to the
home-manager-generation derivation.
This commit is contained in:
fabiancholewinski1234 2025-07-25 18:01:12 +00:00 committed by GitHub
parent 70c79ca6f4
commit 308b8570ec
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -389,6 +389,22 @@ in
description = '' description = ''
A list of paths that should be included in the home A list of paths that should be included in the home
closure but generally not visible. closure but generally not visible.
For built-time checks the `home.checks` option is more appropriate
for that purpose as checks should not leave a trace in the built
home configuration.
'';
};
home.checks = mkOption {
type = types.listOf types.package;
default = [ ];
description = ''
Packages that are added as dependencies of the home's build, usually
for the purpose of validating some part of the configuration.
Unlike `home.extraDependencies`, these store paths do not
become part of the built home configuration.
''; '';
}; };
@ -840,6 +856,15 @@ in
preferLocalBuild = true; preferLocalBuild = true;
passAsFile = [ "extraDependencies" ]; passAsFile = [ "extraDependencies" ];
inherit (config.home) extraDependencies; inherit (config.home) extraDependencies;
# Not actually used in the builder. `passedChecks` is just here to create
# the build dependencies. Checks are similar to build dependencies in the
# sense that if they fail, the home build fails. However, checks do not
# produce any output of value, so they are not used by the system builder.
# In fact, using them runs the risk of accidentally adding unneeded paths
# to the system closure, which defeats the purpose of the `home.checks`
# option, as opposed to `home.extraDependencies`.
passedChecks = lib.concatStringsSep " " config.home.checks;
} }
'' ''
mkdir -p $out mkdir -p $out