mirror of
https://github.com/ilyakooo0/nixpkgs.git
synced 2024-12-27 05:43:50 +03:00
nixos/deluge: support 2.x
This commit is contained in:
parent
fee776aae4
commit
16a4332d60
@ -203,6 +203,15 @@ environment.systemPackages = [
|
||||
<link xlink:href="https://github.com/gollum/gollum/wiki/5.0-release-notes#migrating-your-wiki">here</link>.
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
Deluge 2.x was added and is used as default for new NixOS
|
||||
installations where stateVersion is >= 20.09. If you are upgrading from a previous
|
||||
NixOS version, you can set <literal>service.deluge.package = pkgs.deluge-2_x</literal>
|
||||
to upgrade to Deluge 2.x and migrate the state to the new format.
|
||||
Be aware that backwards state migrations are not supported by Deluge.
|
||||
</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para>
|
||||
@ -246,7 +255,6 @@ environment.systemPackages = [
|
||||
# sudo /run/current-system/fine-tune/child-1/bin/switch-to-configuration test
|
||||
</programlisting>
|
||||
</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</section>
|
||||
|
||||
|
@ -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 = {
|
||||
|
@ -5,9 +5,10 @@ import ./make-test-python.nix ({ pkgs, ...} : {
|
||||
};
|
||||
|
||||
nodes = {
|
||||
simple = {
|
||||
simple1 = {
|
||||
services.deluge = {
|
||||
enable = true;
|
||||
package = pkgs.deluge-1_x;
|
||||
web = {
|
||||
enable = true;
|
||||
openFirewall = true;
|
||||
@ -15,50 +16,92 @@ import ./make-test-python.nix ({ pkgs, ...} : {
|
||||
};
|
||||
};
|
||||
|
||||
declarative =
|
||||
{ ... }:
|
||||
declarative1 = {
|
||||
services.deluge = {
|
||||
enable = true;
|
||||
package = pkgs.deluge-1_x;
|
||||
openFirewall = true;
|
||||
declarative = true;
|
||||
config = {
|
||||
allow_remote = true;
|
||||
download_location = "/var/lib/deluge/my-download";
|
||||
daemon_port = 58846;
|
||||
listen_ports = [ 6881 6889 ];
|
||||
};
|
||||
web = {
|
||||
enable = true;
|
||||
port = 3142;
|
||||
};
|
||||
authFile = pkgs.writeText "deluge-auth" ''
|
||||
localclient:a7bef72a890:10
|
||||
andrew:password:10
|
||||
user3:anotherpass:5
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
{
|
||||
services.deluge = {
|
||||
simple2 = {
|
||||
services.deluge = {
|
||||
enable = true;
|
||||
package = pkgs.deluge-2_x;
|
||||
web = {
|
||||
enable = true;
|
||||
openFirewall = true;
|
||||
declarative = true;
|
||||
config = {
|
||||
allow_remote = true;
|
||||
download_location = "/var/lib/deluge/my-download";
|
||||
daemon_port = 58846;
|
||||
listen_ports = [ 6881 6889 ];
|
||||
};
|
||||
web = {
|
||||
enable = true;
|
||||
port = 3142;
|
||||
};
|
||||
authFile = pkgs.writeText "deluge-auth" ''
|
||||
localclient:a7bef72a890:10
|
||||
andrew:password:10
|
||||
user3:anotherpass:5
|
||||
'';
|
||||
};
|
||||
environment.systemPackages = [ pkgs.deluge ];
|
||||
};
|
||||
};
|
||||
|
||||
declarative2 = {
|
||||
services.deluge = {
|
||||
enable = true;
|
||||
package = pkgs.deluge-2_x;
|
||||
openFirewall = true;
|
||||
declarative = true;
|
||||
config = {
|
||||
allow_remote = true;
|
||||
download_location = "/var/lib/deluge/my-download";
|
||||
daemon_port = 58846;
|
||||
listen_ports = [ 6881 6889 ];
|
||||
};
|
||||
web = {
|
||||
enable = true;
|
||||
port = 3142;
|
||||
};
|
||||
authFile = pkgs.writeText "deluge-auth" ''
|
||||
localclient:a7bef72a890:10
|
||||
andrew:password:10
|
||||
user3:anotherpass:5
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
testScript = ''
|
||||
start_all()
|
||||
|
||||
simple.wait_for_unit("deluged")
|
||||
simple.wait_for_unit("delugeweb")
|
||||
simple.wait_for_open_port("8112")
|
||||
declarative.wait_for_unit("network.target")
|
||||
declarative.wait_until_succeeds("curl --fail http://simple:8112")
|
||||
simple1.wait_for_unit("deluged")
|
||||
simple2.wait_for_unit("deluged")
|
||||
simple1.wait_for_unit("delugeweb")
|
||||
simple2.wait_for_unit("delugeweb")
|
||||
simple1.wait_for_open_port("8112")
|
||||
simple2.wait_for_open_port("8112")
|
||||
declarative1.wait_for_unit("network.target")
|
||||
declarative2.wait_for_unit("network.target")
|
||||
declarative1.wait_until_succeeds("curl --fail http://simple1:8112")
|
||||
declarative2.wait_until_succeeds("curl --fail http://simple2:8112")
|
||||
|
||||
declarative.wait_for_unit("deluged")
|
||||
declarative.wait_for_unit("delugeweb")
|
||||
declarative.wait_until_succeeds("curl --fail http://declarative:3142")
|
||||
declarative.succeed("deluge-console 'help' | grep -q 'rm - Remove a torrent'")
|
||||
declarative.succeed(
|
||||
"deluge-console 'connect 127.0.0.1:58846 andrew password; help' | grep -q 'rm - Remove a torrent'"
|
||||
declarative1.wait_for_unit("deluged")
|
||||
declarative2.wait_for_unit("deluged")
|
||||
declarative1.wait_for_unit("delugeweb")
|
||||
declarative2.wait_for_unit("delugeweb")
|
||||
declarative1.wait_until_succeeds("curl --fail http://declarative1:3142")
|
||||
declarative2.wait_until_succeeds("curl --fail http://declarative2:3142")
|
||||
declarative1.succeed(
|
||||
"deluge-console 'connect 127.0.0.1:58846 andrew password; help' | grep -q 'rm.*Remove a torrent'"
|
||||
)
|
||||
declarative2.succeed(
|
||||
"deluge-console 'connect 127.0.0.1:58846 andrew password; help' | grep -q 'rm.*Remove a torrent'"
|
||||
)
|
||||
'';
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user