tangled
alpha
login
or
join now
tjh.dev
/
nixpkgs
Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
0
fork
atom
overview
issues
pulls
pipelines
nixos/nix-optimise: cleanup, remove with lib
Sandro Jäckel
2 years ago
879c2dd5
9cdd9edc
+11
-23
1 changed file
expand all
collapse all
unified
split
nixos
modules
services
misc
nix-optimise.nix
+11
-23
nixos/modules/services/misc/nix-optimise.nix
···
1
1
{ config, lib, ... }:
2
2
3
3
-
with lib;
4
4
-
5
3
let
6
4
cfg = config.nix.optimise;
7
5
in
8
6
9
7
{
10
10
-
11
11
-
###### interface
12
12
-
13
8
options = {
14
14
-
15
9
nix.optimise = {
16
16
-
17
17
-
automatic = mkOption {
10
10
+
automatic = lib.mkOption {
18
11
default = false;
19
19
-
type = types.bool;
12
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
23
-
dates = mkOption {
16
16
+
dates = lib.mkOption {
24
17
default = ["03:45"];
25
25
-
type = types.listOf types.str;
18
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
35
-
36
36
-
###### implementation
37
37
-
38
28
config = {
39
29
assertions = [
40
30
{
···
43
33
}
44
34
];
45
35
46
46
-
systemd.services.nix-optimise = lib.mkIf config.nix.enable
47
47
-
{ description = "Nix Store Optimiser";
48
48
-
# No point this if the nix daemon (and thus the nix store) is outside
49
49
-
unitConfig.ConditionPathIsReadWrite = "/nix/var/nix/daemon-socket";
50
50
-
serviceConfig.ExecStart = "${config.nix.package}/bin/nix-store --optimise";
51
51
-
startAt = optionals cfg.automatic cfg.dates;
52
52
-
};
53
53
-
36
36
+
systemd.services.nix-optimise = lib.mkIf config.nix.enable {
37
37
+
description = "Nix Store Optimiser";
38
38
+
# No point this if the nix daemon (and thus the nix store) is outside
39
39
+
unitConfig.ConditionPathIsReadWrite = "/nix/var/nix/daemon-socket";
40
40
+
serviceConfig.ExecStart = "${config.nix.package}/bin/nix-store --optimise";
41
41
+
startAt = lib.optionals cfg.automatic cfg.dates;
42
42
+
};
54
43
};
55
55
-
56
44
}