diff options
author | aszlig <aszlig@nix.build> | 2018-05-07 03:59:38 +0200 |
---|---|---|
committer | aszlig <aszlig@nix.build> | 2018-05-07 04:05:41 +0200 |
commit | 1eeeceb9c7e52734536a4e10323634d4ada2f27e (patch) | |
tree | f0f7f4f28b51b08d235cdd1f56a5eb793833a764 /nixos/modules/services/networking | |
parent | 2b499afa63f01473a19c7166c1f3750fa45a1bab (diff) | |
download | nixlib-1eeeceb9c7e52734536a4e10323634d4ada2f27e.tar nixlib-1eeeceb9c7e52734536a4e10323634d4ada2f27e.tar.gz nixlib-1eeeceb9c7e52734536a4e10323634d4ada2f27e.tar.bz2 nixlib-1eeeceb9c7e52734536a4e10323634d4ada2f27e.tar.lz nixlib-1eeeceb9c7e52734536a4e10323634d4ada2f27e.tar.xz nixlib-1eeeceb9c7e52734536a4e10323634d4ada2f27e.tar.zst nixlib-1eeeceb9c7e52734536a4e10323634d4ada2f27e.zip |
nixos/nsd: Allow to configure root zone
When trying to run NSD to serve the root zone, one gets the following error message: error: illegal name: '.' This is because the name of the zone is used as the derivation name for building the zone file. However, Nix doesn't allow derivation names starting with a period. So whenever the zone is "." now, the file name generated is "root" instead of ".". I also added an assertion that makes sure the user sets services.nsd.rootServer, otherwise NSD will fail at runtime because it prevents serving the root zone without an explicit compile-time option. Tested this by adding a root zone to the "nsd" NixOS VM test. Signed-off-by: aszlig <aszlig@nix.build> Cc: @hrdinka, @qknight
Diffstat (limited to 'nixos/modules/services/networking')
-rw-r--r-- | nixos/modules/services/networking/nsd.nix | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/nixos/modules/services/networking/nsd.nix b/nixos/modules/services/networking/nsd.nix index 0b52b1d3e302..fc910e59c323 100644 --- a/nixos/modules/services/networking/nsd.nix +++ b/nixos/modules/services/networking/nsd.nix @@ -20,6 +20,7 @@ let zoneStats = length (collect (x: (x.zoneStats or null) != null) cfg.zones) > 0; }; + mkZoneFileName = name: if name == "." then "root" else name; nsdEnv = pkgs.buildEnv { name = "nsd-env"; @@ -50,8 +51,9 @@ let }; writeZoneData = name: text: pkgs.writeTextFile { - inherit name text; - destination = "/zones/${name}"; + name = "nsd-zone-${mkZoneFileName name}"; + inherit text; + destination = "/zones/${mkZoneFileName name}"; }; @@ -146,7 +148,7 @@ let zoneConfigFile = name: zone: '' zone: name: "${name}" - zonefile: "${stateDir}/zones/${name}" + zonefile: "${stateDir}/zones/${mkZoneFileName name}" ${maybeString "outgoing-interface: " zone.outgoingInterface} ${forEach " rrl-whitelist: " zone.rrlWhitelist} ${maybeString "zonestats: " zone.zoneStats} @@ -887,6 +889,12 @@ in config = mkIf cfg.enable { + assertions = singleton { + assertion = zoneConfigs ? "." -> cfg.rootServer; + message = "You have a root zone configured. If this is really what you " + + "want, please enable 'services.nsd.rootServer'."; + }; + environment.systemPackages = [ nsdPkg ]; users.extraGroups = singleton { |