From 101965187eb19218d061b1ab04da4d76ea8fa66f Mon Sep 17 00:00:00 2001 From: MidAutumnMoon Date: Tue, 27 May 2025 23:46:20 +0800 Subject: [PATCH] nixos/dnscrypt-proxy2: add `package` option nixos/dnscrypt-proxy2: remove `with lib;` Co-authored-by: Sizhe Zhao --- .../manual/release-notes/rl-2511.section.md | 2 ++ .../services/networking/dnscrypt-proxy2.nix | 27 ++++++++++--------- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/nixos/doc/manual/release-notes/rl-2511.section.md b/nixos/doc/manual/release-notes/rl-2511.section.md index 21994daff24e..431e30bc8737 100644 --- a/nixos/doc/manual/release-notes/rl-2511.section.md +++ b/nixos/doc/manual/release-notes/rl-2511.section.md @@ -28,5 +28,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`. diff --git a/nixos/modules/services/networking/dnscrypt-proxy2.nix b/nixos/modules/services/networking/dnscrypt-proxy2.nix index 273d0b3a6bbb..d305d8cb524b 100644 --- a/nixos/modules/services/networking/dnscrypt-proxy2.nix +++ b/nixos/modules/services/networking/dnscrypt-proxy2.nix @@ -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"; - settings = mkOption { + package = lib.mkPackageOption pkgs "dnscrypt-proxy" { }; + + settings = lib.mkOption { description = '' Attrset that is converted and passed as TOML config file. For available params, see: ''; - 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 () 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: 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;