blob: 0f1907a552d08881eb6d7905aefc256a7d32910e (
plain)
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
|
{inputs, ...}: {
flake.nixosModules.gonic = {
config,
lib,
pkgs,
...
}:
with lib; let
cfg = config.gonic;
in {
options = {
gonic = {
enable = mkEnableOption "enable gonic configuration";
listenAddr = mkOption {
type = types.str;
default = "127.0.0.1:4747";
description = ''
Address that gonic will listen on.
'';
};
extraGroups = mkOption {
type = types.listOf (types.str);
default = [];
description = ''
Additional groups for gonic.
'';
};
musicPaths = mkOption {
type = types.listOf (types.str);
description = ''
Directories with music in it.
'';
};
podcastsPath = mkOption {
type = types.str;
default = "${cfg.stateDir}/podcasts";
description = ''
Directory for podcasts.
'';
};
playlistsPath = mkOption {
type = types.str;
default = "${cfg.stateDir}/playlists";
description = ''
Directory for playlists.
'';
};
stateDir = mkOption {
type = types.str;
default = "/var/lib/gonic";
description = ''
A directory where gonic will keep their files.
'';
};
settings = mkOption {
default = {};
description = ''
Additional gonic settings
'';
};
};
};
config = mkIf cfg.enable {
systemd.services.gonic.serviceConfig = {
DynamicUser = lib.mkForce false;
User = "gonic";
Group = "gonic";
SupplementaryGroups = cfg.extraGroups;
ReadWritePaths = [
cfg.podcastsPath
cfg.playlistsPath
];
};
users = {
groups = {
gonic = {};
};
users.gonic = {
isSystemUser = true;
group = "gonic";
};
};
systemd.tmpfiles.rules = [
"d ${cfg.stateDir} 0755 gonic gonic"
"d ${cfg.podcastsPath} 0755 gonic gonic"
"d ${cfg.playlistsPath} 0755 gonic gonic"
];
services.gonic = {
enable = true;
settings =
{
listen-addr = cfg.listenAddr;
music-path = cfg.musicPaths;
playlists-path = [cfg.playlistsPath];
podcast-path = [cfg.podcastsPath];
db-path = ["${cfg.stateDir}/gonic.db"];
}
// cfg.settings;
};
};
};
}
|