-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
nixos-module.nix
55 lines (53 loc) · 1.34 KB
/
nixos-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
53
54
55
{ pkgs, config, lib, ... }: let
cfg = config.services.ifdyndnsd;
in {
options.services.ifdyndnsd = with lib; {
enable = mkOption {
default = false;
type = types.bool;
};
config = mkOption {
type = types.lines;
};
configFile = mkOption {
type = types.path;
default = builtins.toFile "ifdyndnsd.toml" cfg.config;
defaultText = ''builtins.toFile "ifdyndnsd.toml" cfg.config;'';
};
package = mkOption {
type = types.package;
default = pkgs.ifdyndnsd;
};
user = mkOption {
type = types.str;
default = "ifdyndnsd";
};
group = mkOption {
type = types.str;
default = "ifdyndnsd";
};
logLevel = mkOption {
type = types.enum [ "trace" "debug" "info" "warn" "error" ];
default = "info";
};
};
config = lib.mkIf cfg.enable {
users.users.${cfg.user} = {
isSystemUser = true;
inherit (cfg) group;
};
users.groups.${cfg.group} = { };
systemd.services.ifdyndnsd = {
wantedBy = [ "multi-user.target" ];
environment.RUST_LOG = "ifdyndnsd=${cfg.logLevel}";
serviceConfig = {
Type = "simple";
ExecStart = "${cfg.package}/bin/ifdyndnsd ${cfg.configFile}";
User = cfg.user;
Group = cfg.group;
Restart = "always";
RestartSec = "1s";
};
};
};
}