mirror of
https://github.com/ilyakooo0/nixpkgs.git
synced 2024-12-29 06:45:54 +03:00
29027fd1e1
Using pkgs.lib on the spine of module evaluation is problematic because the pkgs argument depends on the result of module evaluation. To prevent an infinite recursion, pkgs and some of the modules are evaluated twice, which is inefficient. Using ‘with lib’ prevents this problem.
66 lines
1.6 KiB
Nix
66 lines
1.6 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";
|
|
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;
|
|
};
|
|
}
|