nixpkgs-suyu/nixos/modules/services/torrent/deluge.nix
2015-09-11 01:32:21 +03:00

67 lines
1.7 KiB
Nix

{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.services.deluge;
cfg_web = config.services.deluge.web;
in {
options = {
services.deluge = {
enable = mkOption {
default = false;
example = true;
description = ''
Start Deluge daemon.
'';
};
};
services.deluge.web = {
enable = mkOption {
default = false;
example = true;
description = ''
Start Deluge Web daemon.
'';
};
};
};
config = mkIf cfg.enable {
systemd.services.deluged = {
after = [ "network.target" ];
description = "Deluge BitTorrent Daemon";
wantedBy = [ "multi-user.target" ];
path = [ pkgs.pythonPackages.deluge ];
serviceConfig.ExecStart = "${pkgs.pythonPackages.deluge}/bin/deluged -d";
# To prevent "Quit & shutdown daemon" from working; we want systemd to manage it!
serviceConfig.Restart = "on-success";
serviceConfig.User = "deluge";
serviceConfig.Group = "deluge";
};
systemd.services.delugeweb = mkIf cfg_web.enable {
after = [ "network.target" ];
description = "Deluge BitTorrent WebUI";
wantedBy = [ "multi-user.target" ];
path = [ pkgs.pythonPackages.deluge ];
serviceConfig.ExecStart = "${pkgs.pythonPackages.deluge}/bin/deluge --ui web";
serviceConfig.User = "deluge";
serviceConfig.Group = "deluge";
};
environment.systemPackages = [ pkgs.pythonPackages.deluge ];
users.extraUsers.deluge = {
group = "deluge";
uid = config.ids.uids.deluge;
home = "/var/lib/deluge/";
createHome = true;
description = "Deluge Daemon user";
};
users.extraGroups.deluge.gid = config.ids.gids.deluge;
};
}