From 361ab4484e7b91a7b6bdedc6784e2a44d20a3dce Mon Sep 17 00:00:00 2001 From: Marien Zwart Date: Sun, 2 Mar 2025 21:09:59 +1100 Subject: [PATCH] home-environment: add `home.extraDependencies` This should have the same effect `system.extraDependencies` has in nixpkgs: adds paths to the runtime closure without installing them anywhere. This is useful for preventing garbage collection of packages that are expensive to rebuild. For example: - nixpkgs itself suggests using this for `factorio.src`, which requires a token to fetch. - we can use it to address #6157: avoid needlessly rebuilding completions for packages that do not have any. The implementation mirrors nixpkgs: add a file containing the store paths we want to keep around to the home-manager-generation derivation. --- modules/home-environment.nix | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/modules/home-environment.nix b/modules/home-environment.nix index d9816dea9..252e53e1b 100644 --- a/modules/home-environment.nix +++ b/modules/home-environment.nix @@ -383,6 +383,15 @@ in ''; }; + home.extraDependencies = mkOption { + type = types.listOf types.pathInStore; + default = [ ]; + description = '' + A list of paths that should be included in the home + closure but generally not visible. + ''; + }; + home.path = mkOption { internal = true; description = "The derivation installing the user packages."; @@ -780,6 +789,8 @@ in pkgs.runCommand "home-manager-generation" { preferLocalBuild = true; + passAsFile = [ "extraDependencies" ]; + inherit (config.home) extraDependencies; } '' mkdir -p $out @@ -797,6 +808,8 @@ in ln -s ${config.home-files} $out/home-files ln -s ${cfg.path} $out/home-path + cp "$extraDependenciesPath" "$out/extra-dependencies" + ${cfg.extraBuilderCommands} '';