Skip to content

Commit

Permalink
nh: fixes and addition to warnings/assertions (#6470)
Browse files Browse the repository at this point in the history
* nh: fix auto clean

- ~Fix `PATH` variable~
- Remove flake path assertion
- Add warning when HM's `nix.gc.automatic` is enabled

* nh: simplify logic for warning related to cfg.clean

---------

Co-authored-by: Nikita Pedorich <pedorich.n@gmail.com>
  • Loading branch information
tetov and pedorich-n authored Feb 17, 2025
1 parent c1ea92c commit 9d0d48f
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 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
(osConfig != null && !(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 != null && 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.")
++ (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 Down

0 comments on commit 9d0d48f

Please sign in to comment.