From 308b8570eced0ca6ddc4c8b291af6a17b2f257a6 Mon Sep 17 00:00:00 2001 From: fabiancholewinski1234 <219463492+fabiancholewinski1234@users.noreply.github.com> Date: Fri, 25 Jul 2025 18:01:12 +0000 Subject: [PATCH] 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. --- modules/home-environment.nix | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/modules/home-environment.nix b/modules/home-environment.nix index 151c103d9..a562047b0 100644 --- a/modules/home-environment.nix +++ b/modules/home-environment.nix @@ -389,6 +389,22 @@ in description = '' A list of paths that should be included in the home 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; passAsFile = [ "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