mirror of
https://github.com/nix-community/home-manager.git
synced 2025-11-08 19:46:05 +01:00
services.nix-gc: improve error message when nix.gc.frequency is invalid on darwin
Previously, if an invalid value was passed, the build would fail with:
error: attribute '"00:02:03"' missing
at /nix/store/sz92b5gqi0ma61d18fwbihi8p37mkvir-source/modules/services/nix-gc.nix:69:5:
68| in
69| freq.${frequency};
| ^
70|
There was an assertion that should have prevented this from happening
but the crash would happen before the assertion gets a chance to stop
the build with a nice error message.
This commit both gives the assertion a chance to trigger and improves
the assertion's error message.
This commit is contained in:
parent
ad1e8bb782
commit
3b930bb653
3 changed files with 17 additions and 4 deletions
|
|
@ -66,7 +66,7 @@ let
|
|||
];
|
||||
};
|
||||
in
|
||||
freq.${frequency};
|
||||
freq.${frequency} or null;
|
||||
|
||||
nixPackage =
|
||||
if config.nix.enable && config.nix.package != null then config.nix.package else pkgs.nix;
|
||||
|
|
@ -95,7 +95,7 @@ in
|
|||
|
||||
On Linux this is a string as defined by {manpage}`systemd.time(7)`.
|
||||
|
||||
On Darwin it must be one of: ${toString darwinIntervals}, which are
|
||||
On Darwin it must be one of: ${lib.concatStringsSep ", " darwinIntervals}, which are
|
||||
implemented as defined in the manual page above.
|
||||
'';
|
||||
};
|
||||
|
|
@ -172,7 +172,7 @@ in
|
|||
assertions = [
|
||||
{
|
||||
assertion = lib.elem cfg.frequency darwinIntervals;
|
||||
message = "On Darwin nix.gc.frequency must be one of: ${toString darwinIntervals}.";
|
||||
message = "On Darwin nix.gc.frequency must be one of: ${lib.concatStringsSep ", " darwinIntervals}.";
|
||||
}
|
||||
];
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue