Skip to content

Commit

Permalink
nh: fix auto clean
Browse files Browse the repository at this point in the history
- Fix `PATH` variable
- Remove flake path assertion
- Add warning when HM's `nix.gc.automatic` is enabled
  • Loading branch information
pedorich-n committed Jan 16, 2025
1 parent fc52a21 commit 5038e45
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions modules/programs/nh.nix
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,11 @@ in {
};

config = {
warnings = lib.optionals (!(cfg.clean.enable -> !osConfig.nix.gc.automatic))
[
"programs.nh.clean.enable and nix.gc.automatic (system-wide in configuration.nix) are both enabled. Please use one or the other to avoid conflict."
];

assertions = [{
assertion = (cfg.flake != null) -> !(lib.hasSuffix ".nix" cfg.flake);
message = "nh.flake must be a directory, not a nix file";
}];
warnings =
(lib.optional (cfg.clean.enable && (osConfig.nix.gc.automatic or false))
"programs.nh.clean.enable and nix.gc.automatic (system-wide in configuration.nix) are both enabled. Please use one or the other to avoid conflict.")
++ (lib.optional (cfg.clean.enable && config.nix.gc.automatic)
"programs.nh.clean.enable and nix.gc.automatic (Home-Manager) are both enabled. Please use one or the other to avoid conflict.");

home = lib.mkIf cfg.enable {
packages = [ cfg.package ];
Expand All @@ -75,7 +71,8 @@ in {
Type = "oneshot";
ExecStart =
"exec ${lib.getExe cfg.package} clean user ${cfg.clean.extraArgs}";
Environment = "PATH=$PATH:${config.nix.package}";
Environment =
[ "PATH=$PATH:${lib.makeBinPath [ config.nix.package ]}" ];
};
};

Expand Down

0 comments on commit 5038e45

Please sign in to comment.