mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-02-18 01:54:34 +00:00
![Silvan Mosberger](/assets/img/avatar_default.png)
After final improvements to the official formatter implementation, this commit now performs the first treewide reformat of Nix files using it. This is part of the implementation of RFC 166. Only "inactive" files are reformatted, meaning only files that aren't being touched by any PR with activity in the past 2 months. This is to avoid conflicts for PRs that might soon be merged. Later we can do a full treewide reformat to get the rest, which should not cause as many conflicts. A CI check has already been running for some time to ensure that new and already-formatted files are formatted, so the files being reformatted here should also stay formatted. This commit was automatically created and can be verified using nix-builda08b3a4d19
.tar.gz \ --argstr baseRev0128fbb0a5
result/bin/apply-formatting $NIXPKGS_PATH
121 lines
2.8 KiB
Nix
121 lines
2.8 KiB
Nix
{
|
|
config,
|
|
lib,
|
|
pkgs,
|
|
...
|
|
}:
|
|
|
|
let
|
|
inherit (lib)
|
|
escapeShellArgs
|
|
getExe
|
|
lists
|
|
literalExpression
|
|
maintainers
|
|
mkEnableOption
|
|
mkIf
|
|
mkOption
|
|
mkPackageOption
|
|
types
|
|
;
|
|
|
|
cfg = config.services.dnsproxy;
|
|
|
|
yaml = pkgs.formats.yaml { };
|
|
configFile = yaml.generate "config.yaml" cfg.settings;
|
|
|
|
finalFlags = (lists.optional (cfg.settings != { }) "--config-path=${configFile}") ++ cfg.flags;
|
|
in
|
|
{
|
|
|
|
options.services.dnsproxy = {
|
|
|
|
enable = mkEnableOption "dnsproxy";
|
|
|
|
package = mkPackageOption pkgs "dnsproxy" { };
|
|
|
|
settings = mkOption {
|
|
type = yaml.type;
|
|
default = { };
|
|
example = literalExpression ''
|
|
{
|
|
bootstrap = [
|
|
"8.8.8.8:53"
|
|
];
|
|
listen-addrs = [
|
|
"0.0.0.0"
|
|
];
|
|
listen-ports = [
|
|
53
|
|
];
|
|
upstream = [
|
|
"1.1.1.1:53"
|
|
];
|
|
}
|
|
'';
|
|
description = ''
|
|
Contents of the `config.yaml` config file.
|
|
The `--config-path` argument will only be passed if this set is not empty.
|
|
|
|
See <https://github.com/AdguardTeam/dnsproxy/blob/master/config.yaml.dist>.
|
|
'';
|
|
};
|
|
|
|
flags = mkOption {
|
|
type = types.listOf types.str;
|
|
default = [ ];
|
|
example = [ "--upstream=1.1.1.1:53" ];
|
|
description = ''
|
|
A list of extra command-line flags to pass to dnsproxy. For details on the
|
|
available options, see <https://github.com/AdguardTeam/dnsproxy#usage>.
|
|
Keep in mind that options passed through command-line flags override
|
|
config options.
|
|
'';
|
|
};
|
|
|
|
};
|
|
|
|
config = mkIf cfg.enable {
|
|
systemd.services.dnsproxy = {
|
|
description = "Simple DNS proxy with DoH, DoT, DoQ and DNSCrypt support";
|
|
after = [
|
|
"network.target"
|
|
"nss-lookup.target"
|
|
];
|
|
wantedBy = [ "multi-user.target" ];
|
|
serviceConfig = {
|
|
ExecStart = "${getExe cfg.package} ${escapeShellArgs finalFlags}";
|
|
Restart = "always";
|
|
RestartSec = 10;
|
|
DynamicUser = true;
|
|
|
|
AmbientCapabilities = "CAP_NET_BIND_SERVICE";
|
|
LockPersonality = true;
|
|
MemoryDenyWriteExecute = true;
|
|
NoNewPrivileges = true;
|
|
ProtectClock = true;
|
|
ProtectHome = true;
|
|
ProtectHostname = true;
|
|
ProtectKernelLogs = true;
|
|
RemoveIPC = true;
|
|
RestrictAddressFamilies = [
|
|
"AF_INET"
|
|
"AF_INET6"
|
|
];
|
|
RestrictNamespaces = true;
|
|
RestrictRealtime = true;
|
|
RestrictSUIDSGID = true;
|
|
SystemCallArchitectures = "native";
|
|
SystemCallErrorNumber = "EPERM";
|
|
SystemCallFilter = [
|
|
"@system-service"
|
|
"~@privileged @resources"
|
|
];
|
|
};
|
|
};
|
|
};
|
|
|
|
meta.maintainers = with maintainers; [ diogotcorreia ];
|
|
|
|
}
|