Skip to content

Commit b7e3465

Browse files
committed
add theming, nginx always assumes path-based routing
1 parent b5a725a commit b7e3465

6 files changed

Lines changed: 48 additions & 33 deletions

File tree

README.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,6 @@ Add nixflix to your flake inputs:
6565
# Add service dependencies (e.g., wait for encrypted drive to mount)
6666
serviceDependencies = ["unlock-raid.service"];
6767
68-
# Configure URL base for all services (affects service internal config)
69-
serviceNameIsUrlBase = true; # Services use /sonarr, /radarr, etc. as urlBase
70-
7168
# Enable nginx reverse proxy
7269
nginx.enable = true;
7370

modules/arr-common/hostConfigType.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ with lib;
5252
urlBase = mkOption {
5353
type = types.str;
5454
default = "";
55-
defaultText = literalExpression ''if config.nixflix.serviceNameIsUrlBase then "/<serviceName>" else ""'';
55+
defaultText = "/<service-name>";
5656
description = "URL base path";
5757
};
5858

modules/arr-common/mkArrServiceModule.nix

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -221,11 +221,13 @@ in {
221221
username = mkDefault serviceName;
222222
passwordPath = mkDefault null;
223223
instanceName = mkDefault capitalizedName;
224-
urlBase = mkDefault (
225-
if nixflix.serviceNameIsUrlBase
226-
then "/${serviceName}"
227-
else ""
228-
);
224+
urlBase =
225+
mkDefault
226+
(
227+
if nixflix.nginx.enable
228+
then "/${serviceName}"
229+
else "/"
230+
);
229231
};
230232
downloadClients = mkDefault (
231233
optionals (nixflix.sabnzbd.enable or false) [
@@ -258,14 +260,23 @@ in {
258260
if cfg.config.hostConfig.urlBase == ""
259261
then "/"
260262
else cfg.config.hostConfig.urlBase
261-
}" = {
263+
}" = let
264+
themeParkUrl = "https://theme-park.dev/css/base/${serviceName}/${nixflix.theme.name}.css";
265+
in {
262266
proxyPass = "http://127.0.0.1:${builtins.toString cfg.config.hostConfig.port}";
263267
recommendedProxySettings = true;
264268
extraConfig = ''
265-
proxy_set_header X-Forwarded-Host $host;
266-
proxy_set_header X-Forwarded-Server $host;
267-
proxy_set_header X-Forwarded-Proto $scheme;
268269
proxy_redirect off;
270+
271+
${
272+
if nixflix.theme.enable
273+
then ''
274+
proxy_set_header Accept-Encoding "";
275+
sub_filter '</body>' '<link rel="stylesheet" type="text/css" href="${themeParkUrl}"></body>';
276+
sub_filter_once on;
277+
''
278+
else ""
279+
}
269280
'';
270281
};
271282
};

modules/default.nix

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,7 @@ in {
2020
];
2121

2222
options.nixflix = {
23-
enable = mkOption {
24-
type = types.bool;
25-
default = false;
26-
example = true;
27-
description = "Whether or not to enable the nixflix module for Jellyfin media server stack";
28-
};
23+
enable = mkEnableOption "Nixflix";
2924

3025
serviceDependencies = mkOption {
3126
type = with types; listOf str;
@@ -37,6 +32,22 @@ in {
3732
'';
3833
};
3934

35+
theme = {
36+
enable = mkEnableOption "Theme";
37+
name = mkOption {
38+
type = types.str;
39+
default = "plex";
40+
description = ''
41+
This is powered theme.park
42+
https://docs.theme-park.dev/
43+
44+
The name of any official theme or community theme supported by theme.park.
45+
https://docs.theme-park.dev/theme-options/
46+
https://docs.theme-park.dev/community-themes/
47+
'';
48+
};
49+
};
50+
4051
nginx = {
4152
enable = mkOption {
4253
type = types.bool;
@@ -45,16 +56,6 @@ in {
4556
};
4657
};
4758

48-
serviceNameIsUrlBase = mkOption {
49-
type = types.bool;
50-
default = false;
51-
description = ''
52-
Whether to use the service name as the URL base (e.g., /sonarr, /radarr).
53-
When false, services will use "/" as the default URL base.
54-
When true, services will use "/{serviceName}" as the default URL base.
55-
'';
56-
};
57-
5859
mediaUsers = mkOption {
5960
type = with types; listOf str;
6061
default = [];

modules/sabnzbd/default.nix

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,10 +158,17 @@ in {
158158
proxyPass = "http://127.0.0.1:${toString cfg.settings.port}";
159159
recommendedProxySettings = true;
160160
extraConfig = ''
161-
proxy_set_header X-Forwarded-Host $host;
162-
proxy_set_header X-Forwarded-Server $host;
163-
proxy_set_header X-Forwarded-Proto $scheme;
164161
proxy_redirect off;
162+
163+
${
164+
if nixflix.theme.enable
165+
then ''
166+
proxy_set_header Accept-Encoding "";
167+
sub_filter '</head>' '<link rel="stylesheet" type="text/css" href="https://theme-park.dev/css/base/sabnzbd/${nixflix.theme.name}.css"></head>';
168+
sub_filter_once on;
169+
''
170+
else ""
171+
}
165172
'';
166173
};
167174
};

tests/vm-tests/nginx-integration.nix

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ in
1717
nixflix = {
1818
enable = true;
1919
nginx.enable = true;
20-
serviceNameIsUrlBase = true;
2120

2221
prowlarr = {
2322
enable = true;

0 commit comments

Comments
 (0)