diff options
author | Guillaume Girol <symphorien@users.noreply.github.com> | 2020-12-15 19:47:43 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-15 19:47:43 +0000 |
commit | 824d2c92bd5780f6142bbb3ddff7663140deda17 (patch) | |
tree | 91600a2cd845a6c3bf8949ae0f5ecfeca5d1141d /nixos/modules | |
parent | 853bac5b2b01e32e1ae13d3acf87d6b39d1f0dbb (diff) | |
parent | 5242cec1b81701479bbec7cd878c46ad4e2faf53 (diff) |
Merge pull request #82584 from Atemu/dnscrypt-default-config
dnscrypt-proxy2: base settings on example config
Diffstat (limited to 'nixos/modules')
-rw-r--r-- | nixos/modules/services/networking/dnscrypt-proxy2.nix | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/nixos/modules/services/networking/dnscrypt-proxy2.nix b/nixos/modules/services/networking/dnscrypt-proxy2.nix index dda61212216c..ff8a2ab30774 100644 --- a/nixos/modules/services/networking/dnscrypt-proxy2.nix +++ b/nixos/modules/services/networking/dnscrypt-proxy2.nix @@ -27,6 +27,16 @@ in default = {}; }; + upstreamDefaults = mkOption { + description = '' + Whether to base the config declared in <literal>services.dnscrypt-proxy2.settings</literal> on the upstream example config (<link xlink:href="https://github.com/DNSCrypt/dnscrypt-proxy/blob/master/dnscrypt-proxy/example-dnscrypt-proxy.toml"/>) + + Disable this if you want to declare your dnscrypt config from scratch. + ''; + type = types.bool; + default = true; + }; + configFile = mkOption { description = '' Path to TOML config file. See: <link xlink:href="https://github.com/DNSCrypt/dnscrypt-proxy/blob/master/dnscrypt-proxy/example-dnscrypt-proxy.toml"/> @@ -38,7 +48,13 @@ in json = builtins.toJSON cfg.settings; passAsFile = [ "json" ]; } '' - ${pkgs.remarshal}/bin/json2toml < $jsonPath > $out + ${if cfg.upstreamDefaults then '' + ${pkgs.remarshal}/bin/toml2json ${pkgs.dnscrypt-proxy2.src}/dnscrypt-proxy/example-dnscrypt-proxy.toml > example.json + ${pkgs.jq}/bin/jq --slurp add example.json $jsonPath > config.json # merges the two + '' else '' + cp $jsonPath config.json + ''} + ${pkgs.remarshal}/bin/json2toml < config.json > $out ''; defaultText = literalExample "TOML file generated from services.dnscrypt-proxy2.settings"; }; |