0
0
Fork 0
mirror of https://github.com/NixOS/nixpkgs.git synced 2025-07-13 21:50:33 +03:00

nixos/services.nzbget: remove with lib;

This commit is contained in:
Felix Buehler 2024-08-24 22:05:51 +02:00
parent 457b7563d4
commit 2da17447da

View file

@ -1,46 +1,43 @@
{ config, pkgs, lib, ... }: { config, pkgs, lib, ... }:
with lib;
let let
cfg = config.services.nzbget; cfg = config.services.nzbget;
pkg = pkgs.nzbget; pkg = pkgs.nzbget;
stateDir = "/var/lib/nzbget"; stateDir = "/var/lib/nzbget";
configFile = "${stateDir}/nzbget.conf"; configFile = "${stateDir}/nzbget.conf";
configOpts = concatStringsSep " " (mapAttrsToList (name: value: "-o ${name}=${escapeShellArg (toStr value)}") cfg.settings); configOpts = lib.concatStringsSep " " (lib.mapAttrsToList (name: value: "-o ${name}=${lib.escapeShellArg (toStr value)}") cfg.settings);
toStr = v: toStr = v:
if v == true then "yes" if v == true then "yes"
else if v == false then "no" else if v == false then "no"
else if isInt v then toString v else if lib.isInt v then toString v
else v; else v;
in in
{ {
imports = [ imports = [
(mkRemovedOptionModule [ "services" "misc" "nzbget" "configFile" ] "The configuration of nzbget is now managed by users through the web interface.") (lib.mkRemovedOptionModule [ "services" "misc" "nzbget" "configFile" ] "The configuration of nzbget is now managed by users through the web interface.")
(mkRemovedOptionModule [ "services" "misc" "nzbget" "dataDir" ] "The data directory for nzbget is now /var/lib/nzbget.") (lib.mkRemovedOptionModule [ "services" "misc" "nzbget" "dataDir" ] "The data directory for nzbget is now /var/lib/nzbget.")
(mkRemovedOptionModule [ "services" "misc" "nzbget" "openFirewall" ] "The port used by nzbget is managed through the web interface so you should adjust your firewall rules accordingly.") (lib.mkRemovedOptionModule [ "services" "misc" "nzbget" "openFirewall" ] "The port used by nzbget is managed through the web interface so you should adjust your firewall rules accordingly.")
]; ];
# interface # interface
options = { options = {
services.nzbget = { services.nzbget = {
enable = mkEnableOption "NZBGet, for downloading files from news servers"; enable = lib.mkEnableOption "NZBGet, for downloading files from news servers";
user = mkOption { user = lib.mkOption {
type = types.str; type = lib.types.str;
default = "nzbget"; default = "nzbget";
description = "User account under which NZBGet runs"; description = "User account under which NZBGet runs";
}; };
group = mkOption { group = lib.mkOption {
type = types.str; type = lib.types.str;
default = "nzbget"; default = "nzbget";
description = "Group under which NZBGet runs"; description = "Group under which NZBGet runs";
}; };
settings = mkOption { settings = lib.mkOption {
type = with types; attrsOf (oneOf [ bool int str ]); type = with lib.types; attrsOf (oneOf [ bool int str ]);
default = {}; default = {};
description = '' description = ''
NZBGet configuration, passed via command line using switch -o. Refer to NZBGet configuration, passed via command line using switch -o. Refer to
@ -56,7 +53,7 @@ in
# implementation # implementation
config = mkIf cfg.enable { config = lib.mkIf cfg.enable {
services.nzbget.settings = { services.nzbget.settings = {
# allows nzbget to run as a "simple" service # allows nzbget to run as a "simple" service
OutputMode = "loggable"; OutputMode = "loggable";
@ -100,7 +97,7 @@ in
}; };
}; };
users.users = mkIf (cfg.user == "nzbget") { users.users = lib.mkIf (cfg.user == "nzbget") {
nzbget = { nzbget = {
home = stateDir; home = stateDir;
group = cfg.group; group = cfg.group;
@ -108,7 +105,7 @@ in
}; };
}; };
users.groups = mkIf (cfg.group == "nzbget") { users.groups = lib.mkIf (cfg.group == "nzbget") {
nzbget = { nzbget = {
gid = config.ids.gids.nzbget; gid = config.ids.gids.nzbget;
}; };