2014-04-14 16:26:48 +02:00
|
|
|
{ config, lib, pkgs, ... }:
|
2013-02-24 17:33:48 +01:00
|
|
|
|
2014-04-14 16:26:48 +02:00
|
|
|
with lib;
|
2013-02-24 17:33:48 +01:00
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.services.deluge;
|
|
|
|
cfg_web = config.services.deluge.web;
|
2016-05-23 16:12:52 +02:00
|
|
|
openFilesLimit = 4096;
|
|
|
|
|
2013-02-24 17:33:48 +01:00
|
|
|
in {
|
|
|
|
options = {
|
2016-05-23 16:12:52 +02:00
|
|
|
services = {
|
|
|
|
deluge = {
|
|
|
|
enable = mkOption {
|
|
|
|
default = false;
|
|
|
|
description = "Start the Deluge daemon";
|
|
|
|
};
|
|
|
|
|
|
|
|
openFilesLimit = mkOption {
|
|
|
|
default = openFilesLimit;
|
|
|
|
example = 8192;
|
|
|
|
description = ''
|
|
|
|
Number of files to allow deluged to open.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
2013-02-24 17:33:48 +01:00
|
|
|
|
2016-05-23 16:12:52 +02:00
|
|
|
deluge.web = {
|
|
|
|
enable = mkOption {
|
|
|
|
default = false;
|
|
|
|
description = ''
|
|
|
|
Start Deluge Web daemon.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
2013-02-24 17:33:48 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
|
|
|
|
systemd.services.deluged = {
|
|
|
|
after = [ "network.target" ];
|
2013-02-26 22:53:52 +01:00
|
|
|
description = "Deluge BitTorrent Daemon";
|
2013-02-24 17:33:48 +01:00
|
|
|
wantedBy = [ "multi-user.target" ];
|
2017-09-01 18:04:59 +02:00
|
|
|
path = [ pkgs.deluge ];
|
2016-05-23 16:12:52 +02:00
|
|
|
serviceConfig = {
|
2017-09-01 18:04:59 +02:00
|
|
|
ExecStart = "${pkgs.deluge}/bin/deluged -d";
|
2016-05-23 16:12:52 +02:00
|
|
|
# To prevent "Quit & shutdown daemon" from working; we want systemd to manage it!
|
|
|
|
Restart = "on-success";
|
|
|
|
User = "deluge";
|
|
|
|
Group = "deluge";
|
|
|
|
LimitNOFILE = cfg.openFilesLimit;
|
|
|
|
};
|
2013-02-24 17:33:48 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
systemd.services.delugeweb = mkIf cfg_web.enable {
|
2013-02-27 20:06:10 +01:00
|
|
|
after = [ "network.target" ];
|
2013-02-26 22:53:52 +01:00
|
|
|
description = "Deluge BitTorrent WebUI";
|
2013-02-24 17:33:48 +01:00
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
path = [ pkgs.pythonPackages.deluge ];
|
2017-09-01 18:04:59 +02:00
|
|
|
serviceConfig.ExecStart = "${pkgs.deluge}/bin/deluge --ui web";
|
2013-02-26 22:53:52 +01:00
|
|
|
serviceConfig.User = "deluge";
|
|
|
|
serviceConfig.Group = "deluge";
|
2013-02-24 17:33:48 +01:00
|
|
|
};
|
|
|
|
|
2017-09-01 18:04:59 +02:00
|
|
|
environment.systemPackages = [ pkgs.deluge ];
|
2013-02-24 17:33:48 +01:00
|
|
|
|
|
|
|
users.extraUsers.deluge = {
|
|
|
|
group = "deluge";
|
2013-08-23 11:33:24 +02:00
|
|
|
uid = config.ids.uids.deluge;
|
2013-02-26 22:53:52 +01:00
|
|
|
home = "/var/lib/deluge/";
|
|
|
|
createHome = true;
|
2013-02-24 17:33:48 +01:00
|
|
|
description = "Deluge Daemon user";
|
|
|
|
};
|
|
|
|
|
2013-08-23 11:33:24 +02:00
|
|
|
users.extraGroups.deluge.gid = config.ids.gids.deluge;
|
2013-02-24 17:33:48 +01:00
|
|
|
};
|
|
|
|
}
|