More clean up

This commit is contained in:
batteredbunny 2024-11-15 01:39:18 +02:00
parent 896e4d6ef7
commit c454f2d312

View file

@ -26,9 +26,9 @@ let
transmissionRpcUrl: process.env.CROSS_SEED_TRANSMISSION_RPC_URL || ${cfg.settings.transmissionRpcUrl}, transmissionRpcUrl: process.env.CROSS_SEED_TRANSMISSION_RPC_URL || ${cfg.settings.transmissionRpcUrl},
delugeRpcUrl: process.env.CROSS_SEED_DELUGE_RPC_URL || ${cfg.settings.delugeRpcUrl}, delugeRpcUrl: process.env.CROSS_SEED_DELUGE_RPC_URL || ${cfg.settings.delugeRpcUrl},
delay: parseInt(process.env.CROSS_SEED_DELAY) || ${toString cfg.settings.delay}, delay: parseInt(process.env.CROSS_SEED_DELAY) || ${toString cfg.settings.delay},
dataDirs: process.env.CROSS_SEED_DATA_DIRS ? process.env.CROSS_SEED_DATA_DIRS.split(',') : ${if cfg.settings.dataDirs != [] then "[${lib.concatMapStringsSep ", " (x: "'${x}'") cfg.settings.dataDirs}]" else "[]"}, dataDirs: process.env.CROSS_SEED_DATA_DIRS ? process.env.CROSS_SEED_DATA_DIRS.split(',') : ${cfg.settings.dataDirs},
linkCategory: process.env.CROSS_SEED_LINK_CATEGORY || "${cfg.settings.linkCategory}", linkCategory: process.env.CROSS_SEED_LINK_CATEGORY || "${cfg.settings.linkCategory}",
linkDir: process.env.CROSS_SEED_LINK_DIR || ${if cfg.settings.linkDir != null then "'${cfg.settings.linkDir}'" else "undefined"}, linkDir: process.env.CROSS_SEED_LINK_DIR || ${cfg.settings.linkDir},
linkType: process.env.CROSS_SEED_LINK_TYPE || "${cfg.settings.linkType}", linkType: process.env.CROSS_SEED_LINK_TYPE || "${cfg.settings.linkType}",
flatLinking: process.env.CROSS_SEED_FLAT_LINKING ? process.env.CROSS_SEED_FLAT_LINKING === 'true' : ${cfg.settings.flatLinking}, flatLinking: process.env.CROSS_SEED_FLAT_LINKING ? process.env.CROSS_SEED_FLAT_LINKING === 'true' : ${cfg.settings.flatLinking},
matchMode: process.env.CROSS_SEED_MATCH_MODE || "${cfg.settings.matchMode}", matchMode: process.env.CROSS_SEED_MATCH_MODE || "${cfg.settings.matchMode}",
@ -52,6 +52,9 @@ let
''; '';
jsBool = v: if v then "true" else "false"; jsBool = v: if v then "true" else "false";
jsStrUndefined = v: if v != null then "'${v}'" else "undefined";
jsStrNull = v: if v != null then "'${v}'" else "null";
jsListStrUndefined = v: if v != [] then "[${lib.concatMapStringsSep ", " (x: "'${x}'") v}]" else "undefined";
in in
{ {
options.services.cross-seed = { options.services.cross-seed = {
@ -154,6 +157,7 @@ in
}; };
dataDirs = mkOption { dataDirs = mkOption {
apply = v: if v != [] then "[${lib.concatMapStringsSep ", " (x: "'${x}'") v}]" else "[]";
type = types.listOf types.path; type = types.listOf types.path;
default = [ ]; default = [ ];
example = [ "/downloads/movies" "/downloads/packs" ]; example = [ "/downloads/movies" "/downloads/packs" ];
@ -173,6 +177,7 @@ in
}; };
linkDir = mkOption { linkDir = mkOption {
apply = jsStrUndefined;
type = types.nullOr types.path; type = types.nullOr types.path;
default = null; default = null;
description = "If this is specified, cross-seed will create links to matched files in the specified directory. It will create a different link for every changed file name or directory structure."; description = "If this is specified, cross-seed will create links to matched files in the specified directory. It will create a different link for every changed file name or directory structure.";
@ -198,7 +203,7 @@ in
}; };
torrentDir = mkOption { torrentDir = mkOption {
apply = v: if v != null then "'${v}'" else "undefined"; apply = jsStrUndefined;
type = types.nullOr types.path; type = types.nullOr types.path;
default = null; default = null;
example = "~/.local/share/qBittorrent/BT_backup"; example = "~/.local/share/qBittorrent/BT_backup";
@ -233,7 +238,7 @@ in
}; };
excludeOlder = mkOption { excludeOlder = mkOption {
apply = v: if v != null then "'${v}'" else "undefined"; apply = jsStrUndefined;
type = types.nullOr types.str; type = types.nullOr types.str;
default = null; default = null;
example = "2 weeks"; example = "2 weeks";
@ -241,7 +246,7 @@ in
}; };
excludeRecentSearch = mkOption { excludeRecentSearch = mkOption {
apply = v: if v != null then "'${v}'" else "undefined"; apply = jsStrUndefined;
type = types.nullOr types.str; type = types.nullOr types.str;
default = null; default = null;
example = "3 days"; example = "3 days";
@ -261,7 +266,7 @@ in
}; };
rtorrentRpcUrl = mkOption { rtorrentRpcUrl = mkOption {
apply = v: if v != null then "'${v}'" else "undefined"; apply = jsStrUndefined;
type = types.nullOr types.str; type = types.nullOr types.str;
default = null; default = null;
example = "http://username:password@localhost:1234/RPC2"; example = "http://username:password@localhost:1234/RPC2";
@ -269,7 +274,7 @@ in
}; };
qbittorrentUrl = mkOption { qbittorrentUrl = mkOption {
apply = v: if v != null then "'${v}'" else "undefined"; apply = jsStrUndefined;
type = types.nullOr types.str; type = types.nullOr types.str;
default = null; default = null;
example = "http://username:password@localhost:8080"; example = "http://username:password@localhost:8080";
@ -277,7 +282,7 @@ in
}; };
transmissionRpcUrl = mkOption { transmissionRpcUrl = mkOption {
apply = v: if v != null then "'${v}'" else "undefined"; apply = jsStrUndefined;
type = types.nullOr types.str; type = types.nullOr types.str;
default = null; default = null;
example = "http://username:password@localhost:9091/transmission/rpc"; example = "http://username:password@localhost:9091/transmission/rpc";
@ -285,7 +290,7 @@ in
}; };
delugeRpcUrl = mkOption { delugeRpcUrl = mkOption {
apply = v: if v != null then "'${v}'" else "undefined"; apply = jsStrUndefined;
type = types.nullOr types.str; type = types.nullOr types.str;
default = null; default = null;
example = "http://:password@localhost:8112/json"; example = "http://:password@localhost:8112/json";
@ -300,7 +305,7 @@ in
}; };
notificationWebhookUrl = mkOption { notificationWebhookUrl = mkOption {
apply = v: if v != null then "'${v}'" else "undefined"; apply = jsStrUndefined;
type = types.nullOr types.str; type = types.nullOr types.str;
default = null; default = null;
description = "Webhook URL for notifications. Conforms to the caronc/apprise REST api."; description = "Webhook URL for notifications. Conforms to the caronc/apprise REST api.";
@ -313,14 +318,14 @@ in
}; };
snatchTimeout = mkOption { snatchTimeout = mkOption {
apply = v: if v != null then "'${v}'" else "null"; apply = jsStrNull;
type = types.str; type = types.str;
default = "30 seconds"; default = "30 seconds";
description = "Timeout for unresponsive snatches"; description = "Timeout for unresponsive snatches";
}; };
searchTimeout = mkOption { searchTimeout = mkOption {
apply = v: if v != null then "'${v}'" else "null"; apply = jsStrNull;
type = types.str; type = types.str;
default = "30 seconds"; default = "30 seconds";
description = "Timeout for unresponsive searches"; description = "Timeout for unresponsive searches";
@ -333,7 +338,7 @@ in
}; };
blockList = mkOption { blockList = mkOption {
apply = v: if v != [] then "[${lib.concatMapStringsSep ", " (x: "'${x}'") v}]" else "undefined"; apply = jsListStrUndefined;
type = types.listOf types.str; type = types.listOf types.str;
default = [ ]; default = [ ];
example = [ example = [
@ -347,7 +352,7 @@ in
}; };
sonarr = mkOption { sonarr = mkOption {
apply = v: if v != [] then "[${lib.concatMapStringsSep ", " (x: "'${x}'") v}]" else "undefined"; apply = jsListStrUndefined;
type = types.listOf types.str; type = types.listOf types.str;
default = [ ]; default = [ ];
example = [ "http://sonarr:8989/?apikey=12345" ]; example = [ "http://sonarr:8989/?apikey=12345" ];
@ -355,7 +360,7 @@ in
}; };
radarr = mkOption { radarr = mkOption {
apply = v: if v != [] then "[${lib.concatMapStringsSep ", " (x: "'${x}'") v}]" else "undefined"; apply = jsListStrUndefined;
type = types.listOf types.str; type = types.listOf types.str;
default = [ ]; default = [ ];
example = [ "http://radarr:7878/?apikey=12345" ]; example = [ "http://radarr:7878/?apikey=12345" ];
@ -369,7 +374,7 @@ in
}; };
host = mkOption { host = mkOption {
apply = v: if v != null then "'${v}'" else "undefined"; apply = jsStrUndefined;
type = types.nullOr types.str; type = types.nullOr types.str;
default = "0.0.0.0"; default = "0.0.0.0";
example = "127.0.0.1"; example = "127.0.0.1";
@ -377,7 +382,7 @@ in
}; };
searchCadence = mkOption { searchCadence = mkOption {
apply = v: if v != null then "'${v}'" else "undefined"; apply = jsStrUndefined;
type = types.nullOr types.str; type = types.nullOr types.str;
default = null; default = null;
example = "1 day"; example = "1 day";
@ -385,7 +390,7 @@ in
}; };
rssCadence = mkOption { rssCadence = mkOption {
apply = v: if v != null then "'${v}'" else "undefined"; apply = jsStrUndefined;
type = types.nullOr types.str; type = types.nullOr types.str;
default = null; default = null;
example = "30 minutes"; example = "30 minutes";
@ -393,7 +398,7 @@ in
}; };
apiKey = mkOption { apiKey = mkOption {
apply = v: if v != null then "'${v}'" else "undefined"; apply = jsStrUndefined;
type = types.nullOr types.str; type = types.nullOr types.str;
default = null; default = null;
description = "Provide your own API key here to override the autogenerated one."; description = "Provide your own API key here to override the autogenerated one.";