0
0
Fork 0
mirror of https://github.com/NixOS/nixpkgs.git synced 2025-07-13 13:40:28 +03:00

treewide: format all inactive Nix files

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-build https://github.com/infinisil/treewide-nixpkgs-reformat-script/archive/a08b3a4d199c6124ac5b36a889d9099b4383463f.tar.gz \
      --argstr baseRev b32a094368
    result/bin/apply-formatting $NIXPKGS_PATH
This commit is contained in:
Silvan Mosberger 2024-12-10 20:26:33 +01:00
parent b32a094368
commit 4f0dadbf38
21293 changed files with 701351 additions and 428307 deletions

View file

@ -1,37 +1,60 @@
{ config, lib, pkgs, ... }:
{
config,
lib,
pkgs,
...
}:
with lib;
let
cfg = config.services.pdns-recursor;
oneOrMore = type: with types; either type (listOf type);
valueType = with types; oneOf [ int str bool path ];
oneOrMore = type: with types; either type (listOf type);
valueType =
with types;
oneOf [
int
str
bool
path
];
configType = with types; attrsOf (nullOr (oneOrMore valueType));
toBool = val: if val then "yes" else "no";
serialize = val: with types;
if str.check val then val
else if int.check val then toString val
else if path.check val then toString val
else if bool.check val then toBool val
else if builtins.isList val then (concatMapStringsSep "," serialize val)
else "";
toBool = val: if val then "yes" else "no";
serialize =
val:
with types;
if str.check val then
val
else if int.check val then
toString val
else if path.check val then
toString val
else if bool.check val then
toBool val
else if builtins.isList val then
(concatMapStringsSep "," serialize val)
else
"";
configDir = pkgs.writeTextDir "recursor.conf"
(concatStringsSep "\n"
(flip mapAttrsToList cfg.settings
(name: val: "${name}=${serialize val}")));
configDir = pkgs.writeTextDir "recursor.conf" (
concatStringsSep "\n" (flip mapAttrsToList cfg.settings (name: val: "${name}=${serialize val}"))
);
mkDefaultAttrs = mapAttrs (n: v: mkDefault v);
in {
in
{
options.services.pdns-recursor = {
enable = mkEnableOption "PowerDNS Recursor, a recursive DNS server";
dns.address = mkOption {
type = oneOrMore types.str;
default = [ "::" "0.0.0.0" ];
default = [
"::"
"0.0.0.0"
];
description = ''
IP addresses Recursor DNS server will bind to.
'';
@ -48,11 +71,20 @@ in {
dns.allowFrom = mkOption {
type = types.listOf types.str;
default = [
"127.0.0.0/8" "10.0.0.0/8" "100.64.0.0/10"
"169.254.0.0/16" "192.168.0.0/16" "172.16.0.0/12"
"::1/128" "fc00::/7" "fe80::/10"
"127.0.0.0/8"
"10.0.0.0/8"
"100.64.0.0/10"
"169.254.0.0/16"
"192.168.0.0/16"
"172.16.0.0/12"
"::1/128"
"fc00::/7"
"fe80::/10"
];
example = [
"0.0.0.0/0"
"::/0"
];
example = [ "0.0.0.0/0" "::/0" ];
description = ''
IP address ranges of clients allowed to make DNS queries.
'';
@ -76,8 +108,14 @@ in {
api.allowFrom = mkOption {
type = types.listOf types.str;
default = [ "127.0.0.1" "::1" ];
example = [ "0.0.0.0/0" "::/0" ];
default = [
"127.0.0.1"
"::1"
];
example = [
"0.0.0.0/0"
"::/0"
];
description = ''
IP address ranges of clients allowed to make API requests.
'';
@ -87,13 +125,13 @@ in {
type = types.bool;
default = false;
description = ''
Whether to export names and IP addresses defined in /etc/hosts.
Whether to export names and IP addresses defined in /etc/hosts.
'';
};
forwardZones = mkOption {
type = types.attrs;
default = {};
default = { };
description = ''
DNS zones to be forwarded to other authoritative servers.
'';
@ -101,15 +139,23 @@ in {
forwardZonesRecurse = mkOption {
type = types.attrs;
example = { eth = "[::1]:5353"; };
default = {};
example = {
eth = "[::1]:5353";
};
default = { };
description = ''
DNS zones to be forwarded to other recursive servers.
'';
};
dnssecValidation = mkOption {
type = types.enum ["off" "process-no-validate" "process" "log-fail" "validate"];
type = types.enum [
"off"
"process-no-validate"
"process"
"log-fail"
"validate"
];
default = "validate";
description = ''
Controls the level of DNSSEC processing done by the PowerDNS Recursor.
@ -163,23 +209,23 @@ in {
services.pdns-recursor.settings = mkDefaultAttrs {
local-address = cfg.dns.address;
local-port = cfg.dns.port;
allow-from = cfg.dns.allowFrom;
local-port = cfg.dns.port;
allow-from = cfg.dns.allowFrom;
webserver-address = cfg.api.address;
webserver-port = cfg.api.port;
webserver-address = cfg.api.address;
webserver-port = cfg.api.port;
webserver-allow-from = cfg.api.allowFrom;
forward-zones = mapAttrsToList (zone: uri: "${zone}.=${uri}") cfg.forwardZones;
forward-zones = mapAttrsToList (zone: uri: "${zone}.=${uri}") cfg.forwardZones;
forward-zones-recurse = mapAttrsToList (zone: uri: "${zone}.=${uri}") cfg.forwardZonesRecurse;
export-etc-hosts = cfg.exportHosts;
dnssec = cfg.dnssecValidation;
serve-rfc1918 = cfg.serveRFC1918;
lua-config-file = pkgs.writeText "recursor.lua" cfg.luaConfig;
dnssec = cfg.dnssecValidation;
serve-rfc1918 = cfg.serveRFC1918;
lua-config-file = pkgs.writeText "recursor.lua" cfg.luaConfig;
daemon = false;
write-pid = false;
log-timestamp = false;
daemon = false;
write-pid = false;
log-timestamp = false;
disable-syslog = true;
};
@ -189,7 +235,10 @@ in {
wantedBy = [ "multi-user.target" ];
serviceConfig = {
ExecStart = [ "" "${pkgs.pdns-recursor}/bin/pdns_recursor --config-dir=${configDir}" ];
ExecStart = [
""
"${pkgs.pdns-recursor}/bin/pdns_recursor --config-dir=${configDir}"
];
};
};
@ -199,13 +248,16 @@ in {
description = "PowerDNS Recursor daemon user";
};
users.groups.pdns-recursor = {};
users.groups.pdns-recursor = { };
};
imports = [
(mkRemovedOptionModule [ "services" "pdns-recursor" "extraConfig" ]
"To change extra Recursor settings use services.pdns-recursor.settings instead.")
(mkRemovedOptionModule [
"services"
"pdns-recursor"
"extraConfig"
] "To change extra Recursor settings use services.pdns-recursor.settings instead.")
];
meta.maintainers = with lib.maintainers; [ rnhmjoj ];