Package Deluge with NixNG

Use same group for all media images
This commit is contained in:
Pim Kunis 2025-01-05 23:08:24 +01:00
parent a22c34716e
commit abb7a131bc
15 changed files with 212 additions and 22 deletions

View file

@ -108,7 +108,7 @@
spec = { spec = {
containers.deluge = { containers.deluge = {
image = globals.images.deluge; image = utils.mkNixNGImage "deluge";
imagePullPolicy = "IfNotPresent"; imagePullPolicy = "IfNotPresent";
env = { env = {
@ -139,6 +139,12 @@
config.persistentVolumeClaim.claimName = "deluge"; config.persistentVolumeClaim.claimName = "deluge";
media.persistentVolumeClaim.claimName = "media"; media.persistentVolumeClaim.claimName = "media";
}; };
securityContext = {
fsGroup = 51;
# FIXME
fsGroupChangePolicy = "Always";
};
}; };
}; };
}; };

View file

@ -1,9 +1,23 @@
{...}: { {
lib,
nglib,
config,
...
}: {
dinit.enable = true; dinit.enable = true;
init.services.bazarr.shutdownOnExit = true;
init.services.bazarr = {
shutdownOnExit = true;
group = lib.mkForce "media";
};
services.bazarr = { services.bazarr = {
enable = true; enable = true;
configDir = "/config"; configDir = "/config";
}; };
users.groups.media = nglib.mkDefaultRec {
gid = config.ids.gids.media;
members = ["bazarr"];
};
} }

View file

@ -22,6 +22,7 @@ flake-utils.lib.eachDefaultSystem (system: let
bazarr = ./bazarr.nix; bazarr = ./bazarr.nix;
prowlarr = ./prowlarr.nix; prowlarr = ./prowlarr.nix;
blog = ./blog.nix; blog = ./blog.nix;
deluge = ./deluge.nix;
}; };
in { in {
nixngConfigurations = builtins.mapAttrs (name: configFile: nixngConfigurations = builtins.mapAttrs (name: configFile:
@ -43,6 +44,7 @@ in {
self.nixngModules.radarr self.nixngModules.radarr
self.nixngModules.sonarr self.nixngModules.sonarr
self.nixngModules.prowlarr self.nixngModules.prowlarr
self.nixngModules.deluge
{ {
nixpkgs.overlays = [ nixpkgs.overlays = [
(final: _prev: { (final: _prev: {

View file

@ -0,0 +1,30 @@
{
config,
nglib,
lib,
...
}: {
dinit.enable = true;
init.services = {
deluged = {
shutdownOnExit = true;
group = lib.mkForce "media";
};
deluge-web = {
shutdownOnExit = true;
group = lib.mkForce "media";
};
};
services.deluge = {
enable = true;
configDir = "/config";
web.enable = true;
};
users.groups.media = nglib.mkDefaultRec {
gid = config.ids.gids.media;
members = ["deluge"];
};
}

View file

@ -1,4 +1,8 @@
{...}: { {
config,
nglib,
...
}: {
dinit.enable = true; dinit.enable = true;
init.services.jellyseerr.shutdownOnExit = true; init.services.jellyseerr.shutdownOnExit = true;
@ -6,4 +10,10 @@
enable = true; enable = true;
configDir = "/app/config"; configDir = "/app/config";
}; };
# TODO: should actually make this the main GID I think
users.groups.media = nglib.mkDefaultRec {
gid = config.ids.gids.media;
members = ["jellyseerr"];
};
} }

View file

@ -1,9 +1,22 @@
{...}: { {
lib,
nglib,
config,
...
}: {
dinit.enable = true; dinit.enable = true;
init.services.prowlarr.shutdownOnExit = true; init.services.prowlarr = {
shutdownOnExit = true;
group = lib.mkForce "media";
};
services.prowlarr = { services.prowlarr = {
enable = true; enable = true;
dataDir = "/config"; dataDir = "/config";
}; };
users.groups.media = nglib.mkDefaultRec {
gid = config.ids.gids.media;
members = ["prowlarr"];
};
} }

View file

@ -1,9 +1,22 @@
{...}: { {
lib,
nglib,
config,
...
}: {
dinit.enable = true; dinit.enable = true;
init.services.radarr.shutdownOnExit = true; init.services.radarr = {
shutdownOnExit = true;
group = lib.mkForce "media";
};
services.radarr = { services.radarr = {
enable = true; enable = true;
dataDir = "/config"; dataDir = "/config";
}; };
users.groups.media = nglib.mkDefaultRec {
gid = config.ids.gids.media;
members = ["radarr"];
};
} }

View file

@ -1,9 +1,22 @@
{...}: { {
lib,
config,
nglib,
...
}: {
dinit.enable = true; dinit.enable = true;
init.services.sonarr.shutdownOnExit = true; init.services.sonarr = {
shutdownOnExit = true;
group = lib.mkForce "media";
};
services.sonarr = { services.sonarr = {
enable = true; enable = true;
dataDir = "/config"; dataDir = "/config";
}; };
users.groups.media = nglib.mkDefaultRec {
gid = config.ids.gids.media;
members = ["sonarr"];
};
} }

View file

@ -34,15 +34,15 @@ in {
environment.systemPackages = [cfg.package]; environment.systemPackages = [cfg.package];
users.users.${cfgInit.user} = nglib.mkDefaultRec { users.users.${cfgInit.user} = lib.mkIf (cfgInit.user == "bazarr") (nglib.mkDefaultRec {
description = "bazarr"; description = "bazarr";
group = cfgInit.group; group = cfgInit.group;
createHome = false; createHome = false;
home = "/var/empty"; home = "/var/empty";
useDefaultShell = true; useDefaultShell = true;
uid = config.ids.uids.bazarr; uid = config.ids.uids.bazarr;
}; });
users.groups.${cfgInit.group} = nglib.mkDefaultRec {gid = config.ids.gids.bazarr;}; users.groups.${cfgInit.group} = lib.mkIf (cfgInit.group == "bazarr") (nglib.mkDefaultRec {gid = config.ids.gids.bazarr;});
}; };
} }

View file

@ -7,5 +7,6 @@
sonarr = import ./sonarr.nix; sonarr = import ./sonarr.nix;
prowlarr = import ./prowlarr.nix; prowlarr = import ./prowlarr.nix;
ids = import ./ids.nix; ids = import ./ids.nix;
deluge = import ./deluge.nix;
}; };
} }

85
nixng-modules/deluge.nix Normal file
View file

@ -0,0 +1,85 @@
{
lib,
nglib,
config,
pkgs,
...
}: let
cfg = config.services.deluge;
cfgInit = config.init.services.deluged;
in {
options.services.deluge = {
enable = lib.mkEnableOption "deluge";
package = lib.mkPackageOption pkgs "deluge-2_x" {};
configDir = lib.mkOption {
type = lib.types.path;
default = "/var/lib/deluge";
description = ''
Directory for Deluge's run-time configuration
'';
};
web = {
enable = lib.mkEnableOption "Deluge web daemon";
port = lib.mkOption {
type = lib.types.port;
default = 8112;
description = ''
Deluge web UI port
'';
};
};
};
config = lib.mkIf cfg.enable {
init.services = {
deluged = {
enabled = true;
user = lib.mkDefault "deluge";
group = lib.mkDefault "deluge";
tmpfiles = with nglib.nottmpfiles.dsl; [(d cfg.configDir "-" cfgInit.user cfgInit.group _ _)];
script = pkgs.writeShellScript "deluged-run" ''
# TODO: make init-level option?
umask 0002
${cfg.package}/bin/deluged \
--do-not-daemonize \
--config ${cfg.configDir}
'';
};
deluge-web = {
enabled = cfg.web.enable;
dependencies = ["deluged"];
user = lib.mkDefault "deluge";
group = lib.mkDefault "deluge";
script = pkgs.writeShellScript "deluge-web-run" ''
${cfg.package}/bin/deluge-web \
--do-not-daemonize \
--port ${toString cfg.web.port} \
--config ${cfg.configDir}
'';
};
};
environment = {
systemPackages = [cfg.package];
variables.PYTHON_EGG_CACHE = "${config.users.users.${cfgInit.user}.home}/.cache";
};
users.users.${cfgInit.user} = lib.mkIf (cfgInit.user == "deluge") (nglib.mkDefaultRec {
description = "deluge";
group = cfgInit.group;
createHome = true;
home = "/home/deluge";
useDefaultShell = true;
uid = config.ids.uids.deluge;
});
users.groups.${cfgInit.group} = lib.mkIf (cfgInit.group == "deluge") (nglib.mkDefaultRec {gid = config.ids.gids.deluge;});
};
}

View file

@ -7,15 +7,18 @@
sonarr = 411; sonarr = 411;
bazarr = 412; bazarr = 412;
prowlarr = 413; prowlarr = 413;
deluge = 414;
}; };
gids = { gids = {
media = 51;
radicale = 408; radicale = 408;
jellyseerr = 409; jellyseerr = 409;
radarr = 410; radarr = 410;
sonarr = 411; sonarr = 411;
bazarr = 412; bazarr = 412;
prowlarr = 413; prowlarr = 413;
deluge = 414;
}; };
}; };
} }

View file

@ -34,15 +34,15 @@ in {
environment.systemPackages = [cfg.package]; environment.systemPackages = [cfg.package];
users.users.${cfgInit.user} = nglib.mkDefaultRec { users.users.${cfgInit.user} = lib.mkIf (cfgInit.user == "prowlarr") (nglib.mkDefaultRec {
description = "prowlarr"; description = "prowlarr";
group = cfgInit.group; group = cfgInit.group;
createHome = false; createHome = false;
home = "/var/empty"; home = "/var/empty";
useDefaultShell = true; useDefaultShell = true;
uid = config.ids.uids.prowlarr; uid = config.ids.uids.prowlarr;
}; });
users.groups.${cfgInit.group} = nglib.mkDefaultRec {gid = config.ids.gids.prowlarr;}; users.groups.${cfgInit.group} = lib.mkIf (cfgInit.group == "prowlarr") (nglib.mkDefaultRec {gid = config.ids.gids.prowlarr;});
}; };
} }

View file

@ -32,15 +32,15 @@ in {
environment.systemPackages = [cfg.package]; environment.systemPackages = [cfg.package];
users.users.${cfgInit.user} = nglib.mkDefaultRec { users.users.${cfgInit.user} = lib.mkIf (cfgInit.user == "radarr") (nglib.mkDefaultRec {
description = "radarr"; description = "radarr";
group = cfgInit.group; group = cfgInit.group;
createHome = false; createHome = false;
home = "/var/empty"; home = "/var/empty";
useDefaultShell = true; useDefaultShell = true;
uid = config.ids.uids.radarr; uid = config.ids.uids.radarr;
}; });
users.groups.${cfgInit.group} = nglib.mkDefaultRec {gid = config.ids.gids.radarr;}; users.groups.${cfgInit.group} = lib.mkIf (cfgInit.group == "radarr") (nglib.mkDefaultRec {gid = config.ids.gids.radarr;});
}; };
} }

View file

@ -32,15 +32,15 @@ in {
environment.systemPackages = [cfg.package]; environment.systemPackages = [cfg.package];
users.users.${cfgInit.user} = nglib.mkDefaultRec { users.users.${cfgInit.user} = lib.mkIf (cfgInit.user == "sonarr") (nglib.mkDefaultRec {
description = "sonarr"; description = "sonarr";
group = cfgInit.group; group = cfgInit.group;
createHome = false; createHome = false;
home = "/var/empty"; home = "/var/empty";
useDefaultShell = true; useDefaultShell = true;
uid = config.ids.uids.sonarr; uid = config.ids.uids.sonarr;
}; });
users.groups.${cfgInit.group} = nglib.mkDefaultRec {gid = config.ids.gids.sonarr;}; users.groups.${cfgInit.group} = lib.mkIf (cfgInit.group == "sonarr") (nglib.mkDefaultRec {gid = config.ids.gids.sonarr;});
}; };
} }