git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #8226 from offlinehacker/kubernetes/skydns

Add skydns module

commitcc96e474d3d21969b999865c817a41c44aab3dc3 authorJaka Hudoklin <jakahudoklin@gmail.com> dateMon 8 Jun 2015, 13:37 (11 years ago) parent889571623504e5
3 files changed+94
nixos/modules/misc/ids.nix+2 nixos/modules/module-list.nix+1 nixos/modules/services/networking/skydns.nix+91
nixos/modules/misc/ids.nix+2
@@ -218,6 +218,7 @@
218218 plex = 193;
219219 bird = 195;
220220 grafana = 196;
221+ skydns = 197;
221222
222223 # When adding a uid, make sure it doesn't match an existing gid. And don't use uids above 399!
223224
@@ -414,6 +415,7 @@
414415 sabnzbd = 194;
415416 bird = 195;
416417 #grafana = 196; #unused
418+ #skydns = 197; #unused
417419
418420 # When adding a gid, make sure it doesn't match an existing
419421 # uid. Users and groups with the same name should have equal
nixos/modules/module-list.nix+1
@@ -318,6 +318,7 @@
318318 ./services/networking/sabnzbd.nix
319319 ./services/networking/searx.nix
320320 ./services/networking/seeks.nix
321+ ./services/networking/skydns.nix
321322 ./services/networking/spiped.nix
322323 ./services/networking/sslh.nix
323324 ./services/networking/ssh/lshd.nix
nixos/modules/services/networking/skydns.nixnew file+91
@@ -0,0 +1,91 @@
1+{ config, pkgs, lib, ... }:
2+
3+with lib;
4+
5+let
6+ cfg = config.services.skydns;
7+
8+in {
9+ options.services.skydns = {
10+ enable = mkEnableOption "Whether to enable skydns service.";
11+
12+ etcd = {
13+ machines = mkOption {
14+ default = [ "http://localhost:4001" ];
15+ type = types.listOf types.str;
16+ description = "Skydns list of etcd endpoints to connect to.";
17+ };
18+
19+ tlsKey = mkOption {
20+ default = null;
21+ type = types.nullOr types.path;
22+ description = "Skydns path of TLS client certificate - private key.";
23+ };
24+
25+ tlsPem = mkOption {
26+ default = null;
27+ type = types.nullOr types.path;
28+ description = "Skydns path of TLS client certificate - public key.";
29+ };
30+
31+ caCert = mkOption {
32+ default = null;
33+ type = types.nullOr types.path;
34+ description = "Skydns path of TLS certificate authority public key.";
35+ };
36+ };
37+
38+ address = mkOption {
39+ default = "0.0.0.0:53";
40+ type = types.str;
41+ description = "Skydns address to bind to.";
42+ };
43+
44+ domain = mkOption {
45+ default = "skydns.local.";
46+ type = types.str;
47+ description = "Skydns default domain if not specified by etcd config.";
48+ };
49+
50+ nameservers = mkOption {
51+ default = map (n: n + ":53") config.networking.nameservers;
52+ type = types.listOf types.str;
53+ description = "Skydns list of nameservers to forward DNS requests to when not authoritative for a domain.";
54+ example = ["8.8.8.8:53" "8.8.4.4:53"];
55+ };
56+
57+ package = mkOption {
58+ default = pkgs.goPackages.skydns;
59+ type = types.package;
60+ description = "Skydns package to use.";
61+ };
62+
63+ extraConfig = mkOption {
64+ default = {};
65+ type = types.attrsOf types.str;
66+ description = "Skydns attribute set of extra config options passed as environemnt variables.";
67+ };
68+ };
69+
70+ config = mkIf (cfg.enable) {
71+ systemd.services.skydns = {
72+ wantedBy = [ "multi-user.target" ];
73+ after = [ "network.target" "etcd.service" ];
74+ description = "Skydns Service";
75+ environment = {
76+ ETCD_MACHINES = concatStringsSep "," cfg.etcd.machines;
77+ ETCD_TLSKEY = cfg.etcd.tlsKey;
78+ ETCD_TLSPEM = cfg.etcd.tlsPem;
79+ ETCD_CACERT = cfg.etcd.caCert;
80+ SKYDNS_ADDR = cfg.address;
81+ SKYDNS_DOMAIN = cfg.domain;
82+ SKYDNS_NAMESERVER = concatStringsSep "," cfg.nameservers;
83+ };
84+ serviceConfig = {
85+ ExecStart = "${cfg.package}/bin/skydns";
86+ };
87+ };
88+
89+ environment.systemPackages = [ cfg.package ];
90+ };
91+}