Loading nixos/modules/services/torrent/cross-seed.nix +35 −1 Original line number Diff line number Diff line Loading @@ -14,6 +14,15 @@ let types ; settingsFormat = pkgs.formats.json { }; generatedConfig = pkgs.runCommand "cross-seed-gen-config" { nativeBuildInputs = [ pkgs.cross-seed ]; } '' export HOME=$(mktemp -d) cross-seed gen-config mkdir $out cp -r $HOME/.cross-seed/config.js $out/ ''; in { options.services.cross-seed = { Loading @@ -40,6 +49,22 @@ in description = "Cross-seed config directory"; }; useGenConfigDefaults = mkOption { type = types.bool; default = false; description = '' Whether to use the option defaults from the configuration generated by {command}`cross-seed gen-config`. Those are the settings recommended by the project, and can be inspected from their [template file](https://github.com/cross-seed/cross-seed/blob/master/src/config.template.cjs). Settings set in {option}`services.cross-seed.settings` and {option}`services.cross-seed.settingsFile` will override the ones from this option. ''; }; settings = mkOption { default = { }; type = types.submodule { Loading Loading @@ -120,6 +145,13 @@ in let jsonSettingsFile = settingsFormat.generate "settings.json" cfg.settings; genConfigSegment = lib.optionalString cfg.useGenConfigDefaults # js '' const gen_config_js = "${generatedConfig}/config.js"; Object.assign(loaded_settings, require(gen_config_js)); ''; # Since cross-seed uses a javascript config file, we can use node's # ability to parse JSON directly to avoid having to do any conversion. # This also means we don't need to use any external programs to merge the Loading @@ -138,7 +170,9 @@ in "use strict"; const fs = require("fs"); const settings_json = "${jsonSettingsFile}"; let loaded_settings = JSON.parse(fs.readFileSync(settings_json, "utf8")); let loaded_settings = {}; ${genConfigSegment} Object.assign(loaded_settings, JSON.parse(fs.readFileSync(settings_json, "utf8"))); ${secretSettingsSegment} module.exports = loaded_settings; ''; Loading Loading
nixos/modules/services/torrent/cross-seed.nix +35 −1 Original line number Diff line number Diff line Loading @@ -14,6 +14,15 @@ let types ; settingsFormat = pkgs.formats.json { }; generatedConfig = pkgs.runCommand "cross-seed-gen-config" { nativeBuildInputs = [ pkgs.cross-seed ]; } '' export HOME=$(mktemp -d) cross-seed gen-config mkdir $out cp -r $HOME/.cross-seed/config.js $out/ ''; in { options.services.cross-seed = { Loading @@ -40,6 +49,22 @@ in description = "Cross-seed config directory"; }; useGenConfigDefaults = mkOption { type = types.bool; default = false; description = '' Whether to use the option defaults from the configuration generated by {command}`cross-seed gen-config`. Those are the settings recommended by the project, and can be inspected from their [template file](https://github.com/cross-seed/cross-seed/blob/master/src/config.template.cjs). Settings set in {option}`services.cross-seed.settings` and {option}`services.cross-seed.settingsFile` will override the ones from this option. ''; }; settings = mkOption { default = { }; type = types.submodule { Loading Loading @@ -120,6 +145,13 @@ in let jsonSettingsFile = settingsFormat.generate "settings.json" cfg.settings; genConfigSegment = lib.optionalString cfg.useGenConfigDefaults # js '' const gen_config_js = "${generatedConfig}/config.js"; Object.assign(loaded_settings, require(gen_config_js)); ''; # Since cross-seed uses a javascript config file, we can use node's # ability to parse JSON directly to avoid having to do any conversion. # This also means we don't need to use any external programs to merge the Loading @@ -138,7 +170,9 @@ in "use strict"; const fs = require("fs"); const settings_json = "${jsonSettingsFile}"; let loaded_settings = JSON.parse(fs.readFileSync(settings_json, "utf8")); let loaded_settings = {}; ${genConfigSegment} Object.assign(loaded_settings, JSON.parse(fs.readFileSync(settings_json, "utf8"))); ${secretSettingsSegment} module.exports = loaded_settings; ''; Loading