-
Notifications
You must be signed in to change notification settings - Fork 0
/
module.nix
52 lines (51 loc) · 1.42 KB
/
module.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
{
config,
lib,
pkgs,
...
}:
{
options = {
services.nixpkgs-update-notifier = {
enable = lib.mkEnableOption "nixpkgs-update-notifier";
username = lib.mkOption { type = lib.types.str; };
passwordFile = lib.mkOption { type = lib.types.path; };
dataDir = lib.mkOption {
type = lib.types.path;
default = "/var/lib/nixpkgs-update-notifier";
};
ticker = lib.mkOption {
type = lib.types.nullOr lib.types.str;
default = null;
};
debug = lib.mkOption {
type = lib.types.nullOr lib.types.bool;
default = null;
};
};
};
config =
let
cfg = config.services.nixpkgs-update-notifier;
in
lib.mkIf cfg.enable {
systemd.services.nixpkgs-update-notifier = {
wantedBy = [ "multi-user.target" ];
after = [ "network.target" ];
startLimitIntervalSec = 0;
serviceConfig = {
Restart = "on-failure";
RestartPreventExitStatus = [ 100 ];
EnvironmentFile = cfg.passwordFile;
ExecStart = toString [
(lib.getExe pkgs.nixpkgs-update-notifier)
"-matrix.username ${cfg.username}"
"-db ${cfg.dataDir}/data.db"
(lib.optionalString (cfg.ticker != null) "-ticker ${cfg.ticker}")
(lib.optionalString cfg.debug "-debug")
];
StateDirectory = "nixpkgs-update-notifier";
};
};
};
}