mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-07-13 13:40:28 +03:00
Merge branch 'master' of github.com:NixOS/nixpkgs into staging
This commit is contained in:
commit
e3d50e5cb0
24 changed files with 293 additions and 92 deletions
|
@ -5,6 +5,7 @@ with lib;
|
|||
let
|
||||
cfg = config.services.deluge;
|
||||
cfg_web = config.services.deluge.web;
|
||||
isDeluge1 = versionOlder cfg.package.version "2.0.0";
|
||||
|
||||
openFilesLimit = 4096;
|
||||
listenPortsDefault = [ 6881 6889 ];
|
||||
|
@ -18,11 +19,11 @@ let
|
|||
preStart = if cfg.declarative then ''
|
||||
if [ -e ${declarativeLockFile} ]; then
|
||||
# Was declarative before, no need to back up anything
|
||||
ln -sf ${configFile} ${configDir}/core.conf
|
||||
${if isDeluge1 then "ln -sf" else "cp"} ${configFile} ${configDir}/core.conf
|
||||
ln -sf ${cfg.authFile} ${configDir}/auth
|
||||
else
|
||||
# Declarative for the first time, backup stateful files
|
||||
ln -sb --suffix=.stateful ${configFile} ${configDir}/core.conf
|
||||
${if isDeluge1 then "ln -s" else "cp"} -b --suffix=.stateful ${configFile} ${configDir}/core.conf
|
||||
ln -sb --suffix=.stateful ${cfg.authFile} ${configDir}/auth
|
||||
echo "Autogenerated file that signifies that this server configuration is managed declaratively by NixOS" \
|
||||
> ${declarativeLockFile}
|
||||
|
@ -144,6 +145,14 @@ in {
|
|||
This always contains unzip, gnutar, xz, p7zip and bzip2.
|
||||
'';
|
||||
};
|
||||
|
||||
package = mkOption {
|
||||
type = types.package;
|
||||
example = literalExample "pkgs.deluge-1_x";
|
||||
description = ''
|
||||
Deluge package to use.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
deluge.web = {
|
||||
|
@ -170,6 +179,13 @@ in {
|
|||
|
||||
config = mkIf cfg.enable {
|
||||
|
||||
services.deluge.package = mkDefault (
|
||||
if versionAtLeast config.system.stateVersion "20.09" then
|
||||
pkgs.deluge-2_x
|
||||
else
|
||||
pkgs.deluge-1_x
|
||||
);
|
||||
|
||||
# Provide a default set of `extraPackages`.
|
||||
services.deluge.extraPackages = with pkgs; [ unzip gnutar xz p7zip bzip2 ];
|
||||
|
||||
|
@ -189,10 +205,10 @@ in {
|
|||
after = [ "network.target" ];
|
||||
description = "Deluge BitTorrent Daemon";
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
path = [ pkgs.deluge ] ++ cfg.extraPackages;
|
||||
path = [ cfg.package ] ++ cfg.extraPackages;
|
||||
serviceConfig = {
|
||||
ExecStart = ''
|
||||
${pkgs.deluge}/bin/deluged \
|
||||
${cfg.package}/bin/deluged \
|
||||
--do-not-daemonize \
|
||||
--config ${configDir}
|
||||
'';
|
||||
|
@ -212,10 +228,11 @@ in {
|
|||
requires = [ "deluged.service" ];
|
||||
description = "Deluge BitTorrent WebUI";
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
path = [ pkgs.deluge ];
|
||||
path = [ cfg.package ];
|
||||
serviceConfig = {
|
||||
ExecStart = ''
|
||||
${pkgs.deluge}/bin/deluge-web \
|
||||
${cfg.package}/bin/deluge-web \
|
||||
${optionalString (!isDeluge1) "--do-not-daemonize"} \
|
||||
--config ${configDir} \
|
||||
--port ${toString cfg.web.port}
|
||||
'';
|
||||
|
@ -234,7 +251,7 @@ in {
|
|||
})
|
||||
];
|
||||
|
||||
environment.systemPackages = [ pkgs.deluge ];
|
||||
environment.systemPackages = [ cfg.package ];
|
||||
|
||||
users.users = mkIf (cfg.user == "deluge") {
|
||||
deluge = {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue