nh: fixes and addition to warnings/assertions (#6470)

* 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>
This commit is contained in:
Anton Tetov
2025-02-17 15:36:35 +01:00
committed by GitHub
parent c1ea92cdfb
commit 9d0d48f4c3

View File

@@ -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 ];