-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodule.nix
57 lines (52 loc) · 1.43 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
53
54
55
56
57
self: {
config,
lib,
pkgs,
...
}: let
cfg = config.services.gist-musicbox;
in {
options.services.gist-musicbox = let
inherit (lib) mkEnableOption mkOption mkPackageOption types;
inherit (pkgs.stdenv.hostPlatform) system;
in {
enable = mkEnableOption "Gist-Musicbox";
package = mkPackageOption self.packages.${system} "default" {};
envFile = mkOption {
type = types.path;
description = "The environment file with credentials.";
};
user = mkOption {
type = types.str;
default = "gist-musicbox";
description = "The user to run gist-musicbox under.";
};
group = mkOption {
type = types.str;
default = "gist-musicbox";
description = "The group to run gist-musicbox under.";
};
};
config = lib.mkIf cfg.enable {
systemd.services.gist-musicbox = {
description = "gist-musicbox";
wantedBy = ["multi-user.target"];
wants = ["network-online.target"];
after = ["network-online.target"];
serviceConfig = {
Restart = "on-failure";
ExecStart = "${lib.getExe cfg.package}";
EnvironmentFile = cfg.envFile;
User = cfg.user;
Group = cfg.group;
};
};
users = {
users.gist-musicbox = lib.mkIf (cfg.user == "gist-musicbox") {
isSystemUser = true;
group = cfg.group;
};
groups.gist-musicbox = lib.mkIf (cfg.group == "gist-musicbox") {};
};
};
}