nixpkgs/nixos/modules/services/networking/sabnzbd.nix
Eelco Dolstra 29027fd1e1 Rewrite ‘with pkgs.lib’ -> ‘with lib’
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.
2014-04-14 16:26:48 +02:00

53 lines
968 B
Nix

{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.services.sabnzbd;
inherit (pkgs) sabnzbd;
in
{
###### interface
options = {
services.sabnzbd = {
enable = mkOption {
default = false;
description = "Whether to enable the sabnzbd FTP server.";
};
configFile = mkOption {
default = "/var/sabnzbd/sabnzbd.ini";
description = "Path to config file. (You need to create this file yourself!)";
};
};
};
###### implementation
config = mkIf cfg.enable {
users.extraUsers =
[ { name = "sabnzbd";
uid = config.ids.uids.sabnzbd;
description = "sabnzbd user";
home = "/homeless-shelter";
}
];
jobs.sabnzbd =
{ description = "sabnzbd server";
startOn = "started network-interfaces";
stopOn = "stopping network-interfaces";
exec = "${sabnzbd}/bin/sabnzbd -d -f ${cfg.configFile}";
};
};
}