Add environment file option
This commit is contained in:
parent
5d07311353
commit
22a879890e
1 changed files with 101 additions and 35 deletions
|
@ -12,42 +12,42 @@ let
|
|||
mkIf
|
||||
types;
|
||||
|
||||
configFile = pkgs.writeText "cross-seed-config.js" ''
|
||||
configFile = pkgs.writeText "config.js" ''
|
||||
module.exports = {
|
||||
apiKey: ${if cfg.settings.apiKey != null then "'${cfg.settings.apiKey}'" else "undefined"},
|
||||
torznab: ${if cfg.settings.torznab != [] then "[${lib.concatMapStringsSep ", " (x: "'${x}'") cfg.settings.torznab}]" else "[]"},
|
||||
sonarr: ${if cfg.settings.sonarr != [] then "[${lib.concatMapStringsSep ", " (x: "'${x}'") cfg.settings.sonarr}]" else "undefined"},
|
||||
radarr: ${if cfg.settings.radarr != [] then "[${lib.concatMapStringsSep ", " (x: "'${x}'") cfg.settings.radarr}]" else "undefined"},
|
||||
host: ${if cfg.settings.host != null then "'${cfg.settings.host}'" else "undefined"},
|
||||
port: ${toString cfg.settings.port},
|
||||
notificationWebhookUrl: ${if cfg.settings.notificationWebhookUrl != null then "'${cfg.settings.notificationWebhookUrl}'" else "undefined"},
|
||||
rtorrentRpcUrl: ${if cfg.settings.rtorrentRpcUrl != null then "'${cfg.settings.rtorrentRpcUrl}'" else "undefined"},
|
||||
qbittorrentUrl: ${if cfg.settings.qbittorrentUrl != null then "'${cfg.settings.qbittorrentUrl}'" else "undefined"},
|
||||
transmissionRpcUrl: ${if cfg.settings.transmissionRpcUrl != null then "'${cfg.settings.transmissionRpcUrl}'" else "undefined"},
|
||||
delugeRpcUrl: ${if cfg.settings.delugeRpcUrl != null then "'${cfg.settings.delugeRpcUrl}'" else "undefined"},
|
||||
delay: ${toString cfg.settings.delay},
|
||||
dataDirs: ${if cfg.settings.dataDirs != [] then "[${lib.concatMapStringsSep ", " (x: "'${x}'") cfg.settings.dataDirs}]" else "[]"},
|
||||
linkCategory: "${cfg.settings.linkCategory}",
|
||||
linkDir: ${if cfg.settings.linkDir != null then "'${cfg.settings.linkDir}'" else "undefined"},
|
||||
linkType: "${cfg.settings.linkType}",
|
||||
flatLinking: ${if cfg.settings.flatLinking then "true" else "false"},
|
||||
matchMode: "${cfg.settings.matchMode}",
|
||||
maxDataDepth: ${toString cfg.settings.maxDataDepth},
|
||||
torrentDir: "${cfg.settings.torrentDir}",
|
||||
outputDir: "${cfg.settings.outputDir}",
|
||||
includeSingleEpisodes: ${if cfg.settings.includeSingleEpisodes then "true" else "false"},
|
||||
includeNonVideos: ${if cfg.settings.includeNonVideos then "true" else "false"},
|
||||
fuzzySizeThreshold: ${toString cfg.settings.fuzzySizeThreshold},
|
||||
excludeOlder: ${if cfg.settings.excludeOlder != null then "'${cfg.settings.excludeOlder}'" else "undefined"},
|
||||
excludeRecentSearch: ${if cfg.settings.excludeRecentSearch != null then "'${cfg.settings.excludeRecentSearch}'" else "undefined"},
|
||||
action: "${cfg.settings.action}",
|
||||
duplicateCategories: ${if cfg.settings.duplicateCategories then "true" else "false"},
|
||||
rssCadence: ${if cfg.settings.rssCadence != null then "'${cfg.settings.rssCadence}'" else "undefined"},
|
||||
searchCadence: ${if cfg.settings.searchCadence != null then "'${cfg.settings.searchCadence}'" else "undefined"},
|
||||
snatchTimeout: ${if cfg.settings.snatchTimeout != null then "'${cfg.settings.snatchTimeout}'" else "null"},
|
||||
searchTimeout: ${if cfg.settings.searchTimeout != null then "'${cfg.settings.searchTimeout}'" else "null"},
|
||||
searchLimit: ${toString cfg.settings.searchLimit},
|
||||
blockList: ${if cfg.settings.blockList != [] then "[${lib.concatMapStringsSep ", " (x: "'${x}'") cfg.settings.blockList}]" else "undefined"},
|
||||
apiKey: process.env.CROSS_SEED_API_KEY || ${if cfg.settings.apiKey != null then "'${cfg.settings.apiKey}'" else "undefined"},
|
||||
torznab: process.env.CROSS_SEED_TORZNAB ? process.env.CROSS_SEED_TORZNAB.split(',') : ${if cfg.settings.torznab != [] then "[${lib.concatMapStringsSep ", " (x: "'${x}'") cfg.settings.torznab}]" else "[]"},
|
||||
sonarr: process.env.CROSS_SEED_SONARR ? process.env.CROSS_SEED_SONARR.split(',') : ${if cfg.settings.sonarr != [] then "[${lib.concatMapStringsSep ", " (x: "'${x}'") cfg.settings.sonarr}]" else "undefined"},
|
||||
radarr: process.env.CROSS_SEED_RADARR ? process.env.CROSS_SEED_RADARR.split(',') : ${if cfg.settings.radarr != [] then "[${lib.concatMapStringsSep ", " (x: "'${x}'") cfg.settings.radarr}]" else "undefined"},
|
||||
host: process.env.CROSS_SEED_HOST || ${if cfg.settings.host != null then "'${cfg.settings.host}'" else "undefined"},
|
||||
port: parseInt(process.env.CROSS_SEED_PORT) || ${toString cfg.settings.port},
|
||||
notificationWebhookUrl: process.env.CROSS_SEED_NOTIFICATION_WEBHOOK_URL || ${if cfg.settings.notificationWebhookUrl != null then "'${cfg.settings.notificationWebhookUrl}'" else "undefined"},
|
||||
rtorrentRpcUrl: process.env.CROSS_SEED_RTORRENT_RPC_URL || ${if cfg.settings.rtorrentRpcUrl != null then "'${cfg.settings.rtorrentRpcUrl}'" else "undefined"},
|
||||
qbittorrentUrl: process.env.CROSS_SEED_QBITTORRENT_URL || ${if cfg.settings.qbittorrentUrl != null then "'${cfg.settings.qbittorrentUrl}'" else "undefined"},
|
||||
transmissionRpcUrl: process.env.CROSS_SEED_TRANSMISSION_RPC_URL || ${if cfg.settings.transmissionRpcUrl != null then "'${cfg.settings.transmissionRpcUrl}'" else "undefined"},
|
||||
delugeRpcUrl: process.env.CROSS_SEED_DELUGE_RPC_URL || ${if cfg.settings.delugeRpcUrl != null then "'${cfg.settings.delugeRpcUrl}'" else "undefined"},
|
||||
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 "[]"},
|
||||
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"},
|
||||
linkType: process.env.CROSS_SEED_LINK_TYPE || "${cfg.settings.linkType}",
|
||||
flatLinking: process.env.CROSS_SEED_FLAT_LINKING ? process.env.CROSS_SEED_FLAT_LINKING === 'true' : ${if cfg.settings.flatLinking then "true" else "false"},
|
||||
matchMode: process.env.CROSS_SEED_MATCH_MODE || "${cfg.settings.matchMode}",
|
||||
maxDataDepth: parseInt(process.env.CROSS_SEED_MAX_DATA_DEPTH) || ${toString cfg.settings.maxDataDepth},
|
||||
torrentDir: process.env.CROSS_SEED_TORRENT_DIR || "${cfg.settings.torrentDir}",
|
||||
outputDir: process.env.CROSS_SEED_OUTPUT_DIR || "${cfg.settings.outputDir}",
|
||||
includeSingleEpisodes: process.env.CROSS_SEED_INCLUDE_SINGLE_EPISODES ? process.env.CROSS_SEED_INCLUDE_SINGLE_EPISODES === 'true' : ${if cfg.settings.includeSingleEpisodes then "true" else "false"},
|
||||
includeNonVideos: process.env.CROSS_SEED_INCLUDE_NON_VIDEOS ? process.env.CROSS_SEED_INCLUDE_NON_VIDEOS === 'true' : ${if cfg.settings.includeNonVideos then "true" else "false"},
|
||||
fuzzySizeThreshold: parseFloat(process.env.CROSS_SEED_FUZZY_SIZE_THRESHOLD) || ${toString cfg.settings.fuzzySizeThreshold},
|
||||
excludeOlder: process.env.CROSS_SEED_EXCLUDE_OLDER || ${if cfg.settings.excludeOlder != null then "'${cfg.settings.excludeOlder}'" else "undefined"},
|
||||
excludeRecentSearch: process.env.CROSS_SEED_EXCLUDE_RECENT_SEARCH || ${if cfg.settings.excludeRecentSearch != null then "'${cfg.settings.excludeRecentSearch}'" else "undefined"},
|
||||
action: process.env.CROSS_SEED_ACTION || "${cfg.settings.action}",
|
||||
duplicateCategories: process.env.CROSS_SEED_DUPLICATE_CATEGORIES ? process.env.CROSS_SEED_DUPLICATE_CATEGORIES === 'true' : ${if cfg.settings.duplicateCategories then "true" else "false"},
|
||||
rssCadence: process.env.CROSS_SEED_RSS_CADENCE || ${if cfg.settings.rssCadence != null then "'${cfg.settings.rssCadence}'" else "undefined"},
|
||||
searchCadence: process.env.CROSS_SEED_SEARCH_CADENCE || ${if cfg.settings.searchCadence != null then "'${cfg.settings.searchCadence}'" else "undefined"},
|
||||
snatchTimeout: process.env.CROSS_SEED_SNATCH_TIMEOUT || ${if cfg.settings.snatchTimeout != null then "'${cfg.settings.snatchTimeout}'" else "null"},
|
||||
searchTimeout: process.env.CROSS_SEED_SEARCH_TIMEOUT || ${if cfg.settings.searchTimeout != null then "'${cfg.settings.searchTimeout}'" else "null"},
|
||||
searchLimit: parseInt(process.env.CROSS_SEED_SEARCH_LIMIT) || ${toString cfg.settings.searchLimit},
|
||||
blockList: process.env.CROSS_SEED_BLOCK_LIST ? process.env.CROSS_SEED_BLOCK_LIST.split(',') : ${if cfg.settings.blockList != [] then "[${lib.concatMapStringsSep ", " (x: "'${x}'") cfg.settings.blockList}]" else "undefined"},
|
||||
};
|
||||
'';
|
||||
in
|
||||
|
@ -77,6 +77,71 @@ in
|
|||
description = lib.mdDoc "Group under which cross-seed runs.";
|
||||
};
|
||||
|
||||
environmentFile = mkOption {
|
||||
type = types.nullOr types.path;
|
||||
default = null;
|
||||
description = ''
|
||||
Path to an environment file containing configuration values.
|
||||
This file can contain the following variables:
|
||||
|
||||
Sensitive Information:
|
||||
* `CROSS_SEED_API_KEY`: Override the autogenerated API key
|
||||
* `CROSS_SEED_TORZNAB`: Comma-separated Torznab URLs with apikey included
|
||||
* `CROSS_SEED_SONARR`: Comma-separated Sonarr API URLs with apikey
|
||||
* `CROSS_SEED_RADARR`: Comma-separated Radarr API URLs with apikey
|
||||
* `CROSS_SEED_NOTIFICATION_WEBHOOK_URL`: Webhook URL for notifications
|
||||
* `CROSS_SEED_RTORRENT_RPC_URL`: rTorrent XMLRPC URL (with credentials)
|
||||
* `CROSS_SEED_QBITTORRENT_URL`: qBittorrent WebUI URL (with credentials)
|
||||
* `CROSS_SEED_TRANSMISSION_RPC_URL`: Transmission RPC URL (with credentials)
|
||||
* `CROSS_SEED_DELUGE_RPC_URL`: Deluge JSON-RPC URL (with credentials)
|
||||
|
||||
Network Configuration:
|
||||
* `CROSS_SEED_HOST`: Bind address (e.g., "127.0.0.1")
|
||||
* `CROSS_SEED_PORT`: Listen port (default: 2468)
|
||||
|
||||
Directory Settings:
|
||||
* `CROSS_SEED_DATA_DIRS`: Comma-separated paths to content directories
|
||||
* `CROSS_SEED_LINK_DIR`: Directory for creating matched file links
|
||||
* `CROSS_SEED_TORRENT_DIR`: Directory containing .torrent files
|
||||
* `CROSS_SEED_OUTPUT_DIR`: Directory to save found torrents
|
||||
|
||||
Linking Configuration:
|
||||
* `CROSS_SEED_LINK_CATEGORY`: Category for linked torrents (default: "cross-seed-link")
|
||||
* `CROSS_SEED_LINK_TYPE`: Type of links to create ("symlink" or "hardlink")
|
||||
* `CROSS_SEED_FLAT_LINKING`: Use flat linking structure ("true" or "false")
|
||||
|
||||
Matching Behavior:
|
||||
* `CROSS_SEED_MATCH_MODE`: Matching strictness ("safe", "risky", or "partial")
|
||||
* `CROSS_SEED_MAX_DATA_DEPTH`: Max directory depth for searching
|
||||
* `CROSS_SEED_INCLUDE_SINGLE_EPISODES`: Include single episodes ("true" or "false")
|
||||
* `CROSS_SEED_INCLUDE_NON_VIDEOS`: Include non-video content ("true" or "false")
|
||||
* `CROSS_SEED_FUZZY_SIZE_THRESHOLD`: Size difference threshold (e.g., "0.02")
|
||||
* `CROSS_SEED_BLOCK_LIST`: Comma-separated list of excluded terms or infohashes
|
||||
|
||||
Timing and Limits:
|
||||
* `CROSS_SEED_DELAY`: Minimum seconds between searches
|
||||
* `CROSS_SEED_EXCLUDE_OLDER`: Exclude torrents older than (e.g., "2 weeks")
|
||||
* `CROSS_SEED_EXCLUDE_RECENT_SEARCH`: Exclude recently searched (e.g., "3 days")
|
||||
* `CROSS_SEED_RSS_CADENCE`: RSS scan schedule (e.g., "30 minutes")
|
||||
* `CROSS_SEED_SEARCH_CADENCE`: Search schedule (e.g., "1 day")
|
||||
* `CROSS_SEED_SNATCH_TIMEOUT`: Snatch request timeout (e.g., "30 seconds")
|
||||
* `CROSS_SEED_SEARCH_TIMEOUT`: Search request timeout (e.g., "2 minutes")
|
||||
* `CROSS_SEED_SEARCH_LIMIT`: Maximum searches per batch
|
||||
|
||||
Client Integration:
|
||||
* `CROSS_SEED_ACTION`: Action on match ("save" or "inject")
|
||||
* `CROSS_SEED_DUPLICATE_CATEGORIES`: Use original categories ("true" or "false")
|
||||
|
||||
Example:
|
||||
```
|
||||
CROSS_SEED_API_KEY=your-api-key
|
||||
CROSS_SEED_TORZNAB=http://indexer1/api?apikey=key1,http://indexer2/api?apikey=key2
|
||||
CROSS_SEED_QBITTORRENT_URL=http://username:password@localhost:8080
|
||||
CROSS_SEED_DATA_DIRS=/downloads/movies,/downloads/tv
|
||||
```
|
||||
'';
|
||||
};
|
||||
|
||||
settings = {
|
||||
torznab = mkOption {
|
||||
type = types.listOf types.str;
|
||||
|
@ -341,6 +406,7 @@ in
|
|||
Environment = [
|
||||
"CONFIG_DIR=${cfg.dataDir}"
|
||||
];
|
||||
EnvironmentFile = lib.mkIf (cfg.environmentFile != null) cfg.environmentFile;
|
||||
WorkingDirectory = cfg.dataDir;
|
||||
ExecStart = "${lib.getExe cfg.package} daemon";
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue