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
{ config, lib, ... }:
2
3
-
with lib;
4
-
5
let
6
cfg = config.nix.optimise;
7
in
8
9
{
10
-
11
-
###### interface
12
-
13
options = {
14
-
15
nix.optimise = {
16
-
17
-
automatic = mkOption {
18
default = false;
19
-
type = types.bool;
20
description = lib.mdDoc "Automatically run the nix store optimiser at a specific time.";
21
};
22
23
-
dates = mkOption {
24
default = ["03:45"];
25
-
type = types.listOf types.str;
26
description = lib.mdDoc ''
27
Specification (in the format described by
28
{manpage}`systemd.time(7)`) of the time at
···
32
};
33
};
34
35
-
36
-
###### implementation
37
-
38
config = {
39
assertions = [
40
{
···
43
}
44
];
45
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
-
54
};
55
-
56
}
···
1
{ config, lib, ... }:
2
0
0
3
let
4
cfg = config.nix.optimise;
5
in
6
7
{
0
0
0
8
options = {
0
9
nix.optimise = {
10
+
automatic = lib.mkOption {
0
11
default = false;
12
+
type = lib.types.bool;
13
description = lib.mdDoc "Automatically run the nix store optimiser at a specific time.";
14
};
15
16
+
dates = lib.mkOption {
17
default = ["03:45"];
18
+
type = with lib.types; listOf str;
19
description = lib.mdDoc ''
20
Specification (in the format described by
21
{manpage}`systemd.time(7)`) of the time at
···
25
};
26
};
27
0
0
0
28
config = {
29
assertions = [
30
{
···
33
}
34
];
35
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
+
};
0
43
};
0
44
}