Unverified Commit 2302f3c9 authored by Lin Jian's avatar Lin Jian Committed by GitHub
Browse files

nixos/dnscrypt-proxy2: add `package` option (#411451)

parents d75957a3 10196518
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -42,5 +42,7 @@

- `services.clamsmtp` is unmaintained and was removed from Nixpkgs.

- `services.dnscrypt-proxy2` gains a `package` option to specify dnscrypt-proxy package to use.

- `amdgpu` kernel driver overdrive mode can now be enabled by setting [hardware.amdgpu.overdrive.enable](#opt-hardware.amdgpu.overdrive.enable) and customized through [hardware.amdgpu.overdrive.ppfeaturemask](#opt-hardware.amdgpu.overdrive.ppfeaturemask).
  This allows for fine-grained control over the GPU's performance and maybe required by overclocking softwares like Corectrl and Lact. These new options replace old options such as {option}`programs.corectrl.gpuOverclock.enable` and {option}`programs.tuxclocker.enableAMD`.
+15 −12
Original line number Diff line number Diff line
@@ -4,22 +4,25 @@
  pkgs,
  ...
}:
with lib;

let

  cfg = config.services.dnscrypt-proxy2;

in

{
  options.services.dnscrypt-proxy2 = {
    enable = mkEnableOption "dnscrypt-proxy2";
    enable = lib.mkEnableOption "dnscrypt-proxy2";

    package = lib.mkPackageOption pkgs "dnscrypt-proxy" { };

    settings = mkOption {
    settings = lib.mkOption {
      description = ''
        Attrset that is converted and passed as TOML config file.
        For available params, see: <https://github.com/DNSCrypt/dnscrypt-proxy/blob/${pkgs.dnscrypt-proxy.version}/dnscrypt-proxy/example-dnscrypt-proxy.toml>
      '';
      example = literalExpression ''
      example = lib.literalExpression ''
        {
          sources.public-resolvers = {
            urls = [ "https://download.dnscrypt.info/resolvers-list/v2/public-resolvers.md" ];
@@ -29,27 +32,27 @@ in
          };
        }
      '';
      type = types.attrs;
      type = lib.types.attrs;
      default = { };
    };

    upstreamDefaults = mkOption {
    upstreamDefaults = lib.mkOption {
      description = ''
        Whether to base the config declared in {option}`services.dnscrypt-proxy2.settings` on the upstream example config (<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;
      type = lib.types.bool;
      default = true;
    };

    configFile = mkOption {
    configFile = lib.mkOption {
      description = ''
        Path to TOML config file. See: <https://github.com/DNSCrypt/dnscrypt-proxy/blob/master/dnscrypt-proxy/example-dnscrypt-proxy.toml>
        If this option is set, it will override any configuration done in options.services.dnscrypt-proxy2.settings.
      '';
      example = "/etc/dnscrypt-proxy/dnscrypt-proxy.toml";
      type = types.path;
      type = lib.types.path;
      default =
        pkgs.runCommand "dnscrypt-proxy.toml"
          {
@@ -70,11 +73,11 @@ in
            }
            ${pkgs.buildPackages.remarshal}/bin/json2toml < config.json > $out
          '';
      defaultText = literalMD "TOML file generated from {option}`services.dnscrypt-proxy2.settings`";
      defaultText = lib.literalMD "TOML file generated from {option}`services.dnscrypt-proxy2.settings`";
    };
  };

  config = mkIf cfg.enable {
  config = lib.mkIf cfg.enable {

    networking.nameservers = lib.mkDefault [ "127.0.0.1" ];

@@ -94,7 +97,7 @@ in
        AmbientCapabilities = "CAP_NET_BIND_SERVICE";
        CacheDirectory = "dnscrypt-proxy";
        DynamicUser = true;
        ExecStart = "${pkgs.dnscrypt-proxy}/bin/dnscrypt-proxy -config ${cfg.configFile}";
        ExecStart = "${lib.getExe cfg.package} -config ${cfg.configFile}";
        LockPersonality = true;
        LogsDirectory = "dnscrypt-proxy";
        MemoryDenyWriteExecute = true;