summary refs log tree commit diff
diff options
context:
space:
mode:
authorNikolay Amiantov <ab@fmap.me>2016-02-16 20:35:01 +0300
committerNikolay Amiantov <ab@fmap.me>2016-02-16 20:35:01 +0300
commit1c8a21dfad61b52dce047551b05daf7434428f20 (patch)
treec77ae148769c77ddb7936971d5c82127535abeda
parent957ed2c08cb5857eeedcb5e22325ac2432c8cc78 (diff)
parent73b9a9662df21ad7c1a372edfda403a8f4b529aa (diff)
downloadnixlib-1c8a21dfad61b52dce047551b05daf7434428f20.tar
nixlib-1c8a21dfad61b52dce047551b05daf7434428f20.tar.gz
nixlib-1c8a21dfad61b52dce047551b05daf7434428f20.tar.bz2
nixlib-1c8a21dfad61b52dce047551b05daf7434428f20.tar.lz
nixlib-1c8a21dfad61b52dce047551b05daf7434428f20.tar.xz
nixlib-1c8a21dfad61b52dce047551b05daf7434428f20.tar.zst
nixlib-1c8a21dfad61b52dce047551b05daf7434428f20.zip
Merge branch 'pdnsd-service' of https://github.com/nfjinjing/nixpkgs
Closes #12932
-rw-r--r--lib/maintainers.nix1
-rw-r--r--nixos/doc/manual/release-notes/rl-unstable.xml1
-rw-r--r--nixos/modules/misc/ids.nix2
-rw-r--r--nixos/modules/module-list.nix1
-rw-r--r--nixos/modules/services/networking/pdnsd.nix93
-rw-r--r--pkgs/tools/networking/pdnsd/default.nix2
6 files changed, 100 insertions, 0 deletions
diff --git a/lib/maintainers.nix b/lib/maintainers.nix
index e69e6df04aca..e7d9085900ac 100644
--- a/lib/maintainers.nix
+++ b/lib/maintainers.nix
@@ -224,6 +224,7 @@
   nathan-gs = "Nathan Bijnens <nathan@nathan.gs>";
   nckx = "Tobias Geerinckx-Rice <tobias.geerinckx.rice@gmail.com>";
   nequissimus = "Tim Steinbach <tim@nequissimus.com>";
+  nfjinjing = "Jinjing Wang <nfjinjing@gmail.com>";
   nico202 = "Nicolò Balzarotti <anothersms@gmail.com>";
   notthemessiah = "Brian Cohen <brian.cohen.88@gmail.com>";
   np = "Nicolas Pouillard <np.nix@nicolaspouillard.fr>";
diff --git a/nixos/doc/manual/release-notes/rl-unstable.xml b/nixos/doc/manual/release-notes/rl-unstable.xml
index c814d61bcf4c..a4f25cdc51f5 100644
--- a/nixos/doc/manual/release-notes/rl-unstable.xml
+++ b/nixos/doc/manual/release-notes/rl-unstable.xml
@@ -41,6 +41,7 @@ nixos.path = ./nixpkgs-unstable-2015-12-06/nixos;
 
   <itemizedlist>
     <listitem><para><literal>services/monitoring/longview.nix</literal></para></listitem>
+    <listitem><para><literal>services/networking/pdnsd.nix</literal></para></listitem>
     <listitem><para><literal>services/web-apps/pump.io.nix</literal></para></listitem>
     <listitem><para><literal>services/security/haka.nix</literal></para></listitem>
   </itemizedlist>
diff --git a/nixos/modules/misc/ids.nix b/nixos/modules/misc/ids.nix
index fa203365bfd3..19da804c13f3 100644
--- a/nixos/modules/misc/ids.nix
+++ b/nixos/modules/misc/ids.nix
@@ -250,6 +250,7 @@
       rmilter = 226;
       cfdyndns = 227;
       gammu-smsd = 228;
+      pdnsd = 229;
 
       # When adding a uid, make sure it doesn't match an existing gid. And don't use uids above 399!
 
@@ -476,6 +477,7 @@
       rspamd = 225;
       rmilter = 226;
       cfdyndns = 227;
+      pdnsd = 229;
 
       # When adding a gid, make sure it doesn't match an existing
       # uid. Users and groups with the same name should have equal
diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix
index 92a1fe72b31f..8254cdd6f5eb 100644
--- a/nixos/modules/module-list.nix
+++ b/nixos/modules/module-list.nix
@@ -342,6 +342,7 @@
   ./services/networking/openntpd.nix
   ./services/networking/openvpn.nix
   ./services/networking/ostinato.nix
+  ./services/networking/pdnsd.nix
   ./services/networking/polipo.nix
   ./services/networking/prayer.nix
   ./services/networking/privoxy.nix
diff --git a/nixos/modules/services/networking/pdnsd.nix b/nixos/modules/services/networking/pdnsd.nix
new file mode 100644
index 000000000000..f4467b818958
--- /dev/null
+++ b/nixos/modules/services/networking/pdnsd.nix
@@ -0,0 +1,93 @@
+{ config, pkgs, lib, ... }:
+
+with lib;
+
+let
+  cfg = config.services.pdnsd;
+  pdnsd = pkgs.pdnsd;
+  pdnsdUser = "pdnsd";
+  pdnsdGroup = "pdnsd";
+  pdnsdConf = pkgs.writeText "pdnsd.conf"
+    ''
+      global {
+        run_as=${pdnsdUser};
+        cache_dir="${cfg.cacheDir}";
+        ${cfg.globalConfig}
+      }
+
+      server {
+        ${cfg.serverConfig}
+      }
+      ${cfg.extraConfig}
+    '';
+in
+
+{ options =
+    { services.pdnsd =
+        { enable = mkEnableOption "pdnsd";
+
+          cacheDir = mkOption {
+            type = types.str;
+            default = "/var/cache/pdnsd";
+            description = "Directory holding the pdnsd cache";
+          };
+
+          globalConfig = mkOption {
+            type = types.lines;
+            default = "";
+            description = ''
+              Global configuration that should be added to the global directory
+              of <literal>pdnsd.conf</literal>.
+            '';
+          };
+
+          serverConfig = mkOption {
+            type = types.lines;
+            default = "";
+            description = ''
+              Server configuration that should be added to the server directory
+              of <literal>pdnsd.conf</literal>.
+            '';
+          };
+
+          extraConfig = mkOption {
+            type = types.lines;
+            default = "";
+            description = ''
+              Extra configuration directives that should be added to
+              <literal>pdnsd.conf</literal>.
+            '';
+          };
+        };
+    };
+
+  config = mkIf cfg.enable {
+    users.extraUsers = singleton {
+      name = pdnsdUser;
+      uid = config.ids.uids.pdnsd;
+      group = pdnsdGroup;
+      description = "pdnsd user";
+    };
+
+    users.extraGroups = singleton {
+      name = pdnsdGroup;
+      gid = config.ids.gids.pdnsd;
+    };
+
+    systemd.services.pdnsd =
+      { wantedBy = [ "multi-user.target" ];
+        after = [ "network.target" ];
+        preStart =
+          ''
+            mkdir -p "${cfg.cacheDir}"
+            touch "${cfg.cacheDir}/pdnsd.cache"
+            chown -R ${pdnsdUser}:${pdnsdGroup} "${cfg.cacheDir}"
+          '';
+        description = "pdnsd";
+        serviceConfig =
+          {
+            ExecStart = "${pdnsd}/bin/pdnsd -c ${pdnsdConf}";
+          };
+      };
+  };
+}
diff --git a/pkgs/tools/networking/pdnsd/default.nix b/pkgs/tools/networking/pdnsd/default.nix
index 40d57cd65b63..b1e7e92e815c 100644
--- a/pkgs/tools/networking/pdnsd/default.nix
+++ b/pkgs/tools/networking/pdnsd/default.nix
@@ -12,6 +12,8 @@ stdenv.mkDerivation rec {
     sed -i 's/.*(cachedir).*/:/' Makefile.in
   '';
 
+  configureFlags = [ "--enable-ipv6" ];
+
   meta = { 
     description = "Permanent DNS caching";
     homepage = http://www.phys.uu.nl/~rombouts/pdnsd.html;