mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-09 19:13:26 +03:00
nixos/dnscrypt-proxy2: add package
option
nixos/dnscrypt-proxy2: remove `with lib;` Co-authored-by: Sizhe Zhao <prc.zhao@outlook.com>
This commit is contained in:
parent
050bbae7be
commit
101965187e
2 changed files with 17 additions and 12 deletions
|
@ -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`.
|
||||
|
|
|
@ -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: <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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue