diff --git a/modules/cross-seed.nix b/modules/cross-seed.nix index 6e71e74..e341f3b 100644 --- a/modules/cross-seed.nix +++ b/modules/cross-seed.nix @@ -26,9 +26,9 @@ let transmissionRpcUrl: process.env.CROSS_SEED_TRANSMISSION_RPC_URL || ${cfg.settings.transmissionRpcUrl}, delugeRpcUrl: process.env.CROSS_SEED_DELUGE_RPC_URL || ${cfg.settings.delugeRpcUrl}, 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}", - 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}", 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}", @@ -52,6 +52,9 @@ let ''; 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 { options.services.cross-seed = { @@ -154,6 +157,7 @@ in }; dataDirs = mkOption { + apply = v: if v != [] then "[${lib.concatMapStringsSep ", " (x: "'${x}'") v}]" else "[]"; type = types.listOf types.path; default = [ ]; example = [ "/downloads/movies" "/downloads/packs" ]; @@ -173,6 +177,7 @@ in }; linkDir = mkOption { + apply = jsStrUndefined; type = types.nullOr types.path; 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."; @@ -198,7 +203,7 @@ in }; torrentDir = mkOption { - apply = v: if v != null then "'${v}'" else "undefined"; + apply = jsStrUndefined; type = types.nullOr types.path; default = null; example = "~/.local/share/qBittorrent/BT_backup"; @@ -233,7 +238,7 @@ in }; excludeOlder = mkOption { - apply = v: if v != null then "'${v}'" else "undefined"; + apply = jsStrUndefined; type = types.nullOr types.str; default = null; example = "2 weeks"; @@ -241,7 +246,7 @@ in }; excludeRecentSearch = mkOption { - apply = v: if v != null then "'${v}'" else "undefined"; + apply = jsStrUndefined; type = types.nullOr types.str; default = null; example = "3 days"; @@ -261,7 +266,7 @@ in }; rtorrentRpcUrl = mkOption { - apply = v: if v != null then "'${v}'" else "undefined"; + apply = jsStrUndefined; type = types.nullOr types.str; default = null; example = "http://username:password@localhost:1234/RPC2"; @@ -269,7 +274,7 @@ in }; qbittorrentUrl = mkOption { - apply = v: if v != null then "'${v}'" else "undefined"; + apply = jsStrUndefined; type = types.nullOr types.str; default = null; example = "http://username:password@localhost:8080"; @@ -277,7 +282,7 @@ in }; transmissionRpcUrl = mkOption { - apply = v: if v != null then "'${v}'" else "undefined"; + apply = jsStrUndefined; type = types.nullOr types.str; default = null; example = "http://username:password@localhost:9091/transmission/rpc"; @@ -285,7 +290,7 @@ in }; delugeRpcUrl = mkOption { - apply = v: if v != null then "'${v}'" else "undefined"; + apply = jsStrUndefined; type = types.nullOr types.str; default = null; example = "http://:password@localhost:8112/json"; @@ -300,7 +305,7 @@ in }; notificationWebhookUrl = mkOption { - apply = v: if v != null then "'${v}'" else "undefined"; + apply = jsStrUndefined; type = types.nullOr types.str; default = null; description = "Webhook URL for notifications. Conforms to the caronc/apprise REST api."; @@ -313,14 +318,14 @@ in }; snatchTimeout = mkOption { - apply = v: if v != null then "'${v}'" else "null"; + apply = jsStrNull; type = types.str; default = "30 seconds"; description = "Timeout for unresponsive snatches"; }; searchTimeout = mkOption { - apply = v: if v != null then "'${v}'" else "null"; + apply = jsStrNull; type = types.str; default = "30 seconds"; description = "Timeout for unresponsive searches"; @@ -333,7 +338,7 @@ in }; blockList = mkOption { - apply = v: if v != [] then "[${lib.concatMapStringsSep ", " (x: "'${x}'") v}]" else "undefined"; + apply = jsListStrUndefined; type = types.listOf types.str; default = [ ]; example = [ @@ -347,7 +352,7 @@ in }; sonarr = mkOption { - apply = v: if v != [] then "[${lib.concatMapStringsSep ", " (x: "'${x}'") v}]" else "undefined"; + apply = jsListStrUndefined; type = types.listOf types.str; default = [ ]; example = [ "http://sonarr:8989/?apikey=12345" ]; @@ -355,7 +360,7 @@ in }; radarr = mkOption { - apply = v: if v != [] then "[${lib.concatMapStringsSep ", " (x: "'${x}'") v}]" else "undefined"; + apply = jsListStrUndefined; type = types.listOf types.str; default = [ ]; example = [ "http://radarr:7878/?apikey=12345" ]; @@ -369,7 +374,7 @@ in }; host = mkOption { - apply = v: if v != null then "'${v}'" else "undefined"; + apply = jsStrUndefined; type = types.nullOr types.str; default = "0.0.0.0"; example = "127.0.0.1"; @@ -377,7 +382,7 @@ in }; searchCadence = mkOption { - apply = v: if v != null then "'${v}'" else "undefined"; + apply = jsStrUndefined; type = types.nullOr types.str; default = null; example = "1 day"; @@ -385,7 +390,7 @@ in }; rssCadence = mkOption { - apply = v: if v != null then "'${v}'" else "undefined"; + apply = jsStrUndefined; type = types.nullOr types.str; default = null; example = "30 minutes"; @@ -393,7 +398,7 @@ in }; apiKey = mkOption { - apply = v: if v != null then "'${v}'" else "undefined"; + apply = jsStrUndefined; type = types.nullOr types.str; default = null; description = "Provide your own API key here to override the autogenerated one.";