1 { config, pkgs, lib, ... }:
6 cfg = config.services.skydns;
9 options.services.skydns = {
10 enable = mkEnableOption (lib.mdDoc "skydns service");
14 default = [ "http://127.0.0.1:2379" ];
15 type = types.listOf types.str;
16 description = lib.mdDoc "Skydns list of etcd endpoints to connect to.";
21 type = types.nullOr types.path;
22 description = lib.mdDoc "Skydns path of TLS client certificate - private key.";
27 type = types.nullOr types.path;
28 description = lib.mdDoc "Skydns path of TLS client certificate - public key.";
33 type = types.nullOr types.path;
34 description = lib.mdDoc "Skydns path of TLS certificate authority public key.";
39 default = "0.0.0.0:53";
41 description = lib.mdDoc "Skydns address to bind to.";
45 default = "skydns.local.";
47 description = lib.mdDoc "Skydns default domain if not specified by etcd config.";
50 nameservers = mkOption {
51 default = map (n: n + ":53") config.networking.nameservers;
52 defaultText = literalExpression ''map (n: n + ":53") config.networking.nameservers'';
53 type = types.listOf types.str;
54 description = lib.mdDoc "Skydns list of nameservers to forward DNS requests to when not authoritative for a domain.";
55 example = ["8.8.8.8:53" "8.8.4.4:53"];
59 default = pkgs.skydns;
60 defaultText = literalExpression "pkgs.skydns";
62 description = lib.mdDoc "Skydns package to use.";
65 extraConfig = mkOption {
67 type = types.attrsOf types.str;
68 description = lib.mdDoc "Skydns attribute set of extra config options passed as environment variables.";
72 config = mkIf (cfg.enable) {
73 systemd.services.skydns = {
74 wantedBy = [ "multi-user.target" ];
75 after = [ "network.target" "etcd.service" ];
76 description = "Skydns Service";
78 ETCD_MACHINES = concatStringsSep "," cfg.etcd.machines;
79 ETCD_TLSKEY = cfg.etcd.tlsKey;
80 ETCD_TLSPEM = cfg.etcd.tlsPem;
81 ETCD_CACERT = cfg.etcd.caCert;
82 SKYDNS_ADDR = cfg.address;
83 SKYDNS_DOMAIN = cfg.domain;
84 SKYDNS_NAMESERVERS = concatStringsSep "," cfg.nameservers;
87 ExecStart = "${cfg.package}/bin/skydns";
91 environment.systemPackages = [ cfg.package ];