Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)

nixos/nix-optimise: cleanup, remove with lib

+11 -23
+11 -23
nixos/modules/services/misc/nix-optimise.nix
··· 1 1 { config, lib, ... }: 2 2 3 - with lib; 4 - 5 3 let 6 4 cfg = config.nix.optimise; 7 5 in 8 6 9 7 { 10 - 11 - ###### interface 12 - 13 8 options = { 14 - 15 9 nix.optimise = { 16 - 17 - automatic = mkOption { 10 + automatic = lib.mkOption { 18 11 default = false; 19 - type = types.bool; 12 + type = lib.types.bool; 20 13 description = lib.mdDoc "Automatically run the nix store optimiser at a specific time."; 21 14 }; 22 15 23 - dates = mkOption { 16 + dates = lib.mkOption { 24 17 default = ["03:45"]; 25 - type = types.listOf types.str; 18 + type = with lib.types; listOf str; 26 19 description = lib.mdDoc '' 27 20 Specification (in the format described by 28 21 {manpage}`systemd.time(7)`) of the time at ··· 32 25 }; 33 26 }; 34 27 35 - 36 - ###### implementation 37 - 38 28 config = { 39 29 assertions = [ 40 30 { ··· 43 33 } 44 34 ]; 45 35 46 - systemd.services.nix-optimise = lib.mkIf config.nix.enable 47 - { description = "Nix Store Optimiser"; 48 - # No point this if the nix daemon (and thus the nix store) is outside 49 - unitConfig.ConditionPathIsReadWrite = "/nix/var/nix/daemon-socket"; 50 - serviceConfig.ExecStart = "${config.nix.package}/bin/nix-store --optimise"; 51 - startAt = optionals cfg.automatic cfg.dates; 52 - }; 53 - 36 + systemd.services.nix-optimise = lib.mkIf config.nix.enable { 37 + description = "Nix Store Optimiser"; 38 + # No point this if the nix daemon (and thus the nix store) is outside 39 + unitConfig.ConditionPathIsReadWrite = "/nix/var/nix/daemon-socket"; 40 + serviceConfig.ExecStart = "${config.nix.package}/bin/nix-store --optimise"; 41 + startAt = lib.optionals cfg.automatic cfg.dates; 42 + }; 54 43 }; 55 - 56 44 }