Skip to content

Commit 8b0dbea

Browse files
committed
normalize organization
1 parent 01418c1 commit 8b0dbea

4 files changed

Lines changed: 160 additions & 162 deletions

File tree

modules/default.nix

Lines changed: 160 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,171 @@
11
{
2+
config,
3+
lib,
4+
pkgs,
5+
...
6+
}:
7+
with lib; let
8+
inherit (config.nixflix) globals;
9+
cfg = config.nixflix;
10+
in {
211
imports = [
312
./globals.nix
4-
./nixflix.nix
513
./lidarr
6-
./mullvad.nix
7-
./postgres.nix
14+
./mullvad
15+
./postgres
816
./prowlarr
917
./radarr
1018
./recyclarr
1119
./sabnzbd
1220
./sonarr
1321
];
22+
23+
options.nixflix = {
24+
enable = mkOption {
25+
type = types.bool;
26+
default = false;
27+
example = true;
28+
description = "Whether or not to enable the nixflix module for Jellyfin media server stack";
29+
};
30+
31+
serviceDependencies = mkOption {
32+
type = with types; listOf str;
33+
default = [];
34+
example = ["unlock-raid.service" "tailscale.service"];
35+
description = ''
36+
List of systemd services that nixflix services should wait for before starting.
37+
Useful for mounting encrypted drives, starting VPNs, or other prerequisites.
38+
'';
39+
};
40+
41+
nginx = {
42+
enable = mkOption {
43+
type = types.bool;
44+
default = false;
45+
description = "Whether to enable nginx reverse proxy for all services";
46+
};
47+
};
48+
49+
serviceNameIsUrlBase = mkOption {
50+
type = types.bool;
51+
default = false;
52+
description = ''
53+
Whether to use the service name as the URL base (e.g., /sonarr, /radarr).
54+
When false, services will use "/" as the default URL base.
55+
When true, services will use "/{serviceName}" as the default URL base.
56+
'';
57+
};
58+
59+
mediaUsers = mkOption {
60+
type = with types; listOf str;
61+
default = [];
62+
example = ["user"];
63+
description = ''
64+
Extra users to add to the media group.
65+
'';
66+
};
67+
68+
mediaDir = mkOption {
69+
type = types.path;
70+
default = "/data/media";
71+
example = "/data/media";
72+
description = ''
73+
The location of the media directory for the services.
74+
75+
> **Warning:** Setting this to any path, where the subpath is not
76+
> owned by root, will fail! For example:
77+
>
78+
> ```nix
79+
> mediaDir = /home/user/data
80+
> ```
81+
>
82+
> Is not supported, because `/home/user` is owned by `user`.
83+
'';
84+
};
85+
86+
downloadsDir = mkOption {
87+
type = types.path;
88+
default = "/data/downloads";
89+
example = "/data/downloads";
90+
description = ''
91+
The location of the downloads directory for download clients.
92+
93+
> **Warning:** Setting this to any path, where the subpath is not
94+
> owned by root, will fail! For example:
95+
>
96+
> ```nix
97+
> downloadsDir = /home/user/downloads
98+
> ```
99+
>
100+
> Is not supported, because `/home/user` is owned by `user`.
101+
'';
102+
};
103+
104+
stateDir = mkOption {
105+
type = types.path;
106+
default = "/data/.state";
107+
example = "/data/.state";
108+
description = ''
109+
The location of the state directory for the services.
110+
111+
> **Warning:** Setting this to any path, where the subpath is not
112+
> owned by root, will fail! For example:
113+
>
114+
> ```nix
115+
> stateDir = /home/user/data/.state
116+
> ```
117+
>
118+
> Is not supported, because `/home/user` is owned by `user`.
119+
'';
120+
};
121+
};
122+
123+
config = mkIf cfg.enable {
124+
users.groups.media.members = cfg.mediaUsers;
125+
126+
systemd.services.nixflix-setup-dirs = {
127+
description = "Create directories for nixflix media server services";
128+
wantedBy = ["multi-user.target"];
129+
after = cfg.serviceDependencies;
130+
requires = cfg.serviceDependencies;
131+
132+
serviceConfig = {
133+
Type = "oneshot";
134+
RemainAfterExit = true;
135+
};
136+
137+
script = ''
138+
${pkgs.coreutils}/bin/mkdir -p ${cfg.stateDir}
139+
${pkgs.coreutils}/bin/chown root:root ${cfg.stateDir}
140+
${pkgs.coreutils}/bin/chmod 0755 ${cfg.stateDir}
141+
142+
${pkgs.coreutils}/bin/mkdir -p ${cfg.mediaDir}
143+
${pkgs.coreutils}/bin/chown ${globals.libraryOwner.user}:${globals.libraryOwner.group} ${cfg.mediaDir}
144+
${pkgs.coreutils}/bin/chmod 0775 ${cfg.mediaDir}
145+
146+
${pkgs.coreutils}/bin/mkdir -p ${cfg.downloadsDir}
147+
${pkgs.coreutils}/bin/chown ${globals.libraryOwner.user}:${globals.libraryOwner.group} ${cfg.downloadsDir}
148+
${pkgs.coreutils}/bin/chmod 0775 ${cfg.downloadsDir}
149+
'';
150+
};
151+
152+
services.nginx = mkIf cfg.nginx.enable {
153+
enable = true;
154+
155+
recommendedTlsSettings = true;
156+
recommendedOptimisation = true;
157+
recommendedGzipSettings = true;
158+
159+
virtualHosts.localhost = {
160+
serverName = "localhost";
161+
default = true;
162+
listen = [
163+
{
164+
addr = "0.0.0.0";
165+
port = 80;
166+
}
167+
];
168+
};
169+
};
170+
};
14171
}

modules/nixflix.nix

Lines changed: 0 additions & 159 deletions
This file was deleted.

0 commit comments

Comments
 (0)