git.iko.soy/typeable/nixpkgs
on master help sign in
nixos/coredns: init (#54931)
commitb381c27b589c3b03d9c281b2e4fcae9c887ea72b authorDavid Duarte <deltaduartedavid@gmail.com> dateFri 1 Mar 2019, 10:10 (8 years ago) parent3944fa4
2 files changed+51
nixos/modules/module-list.nix+1 nixos/modules/services/networking/coredns.nix+50
nixos/modules/module-list.nix+1
@@ -528,6 +528,7 @@
528528 ./services/networking/cntlm.nix
529529 ./services/networking/connman.nix
530530 ./services/networking/consul.nix
531+ ./services/networking/coredns.nix
531532 ./services/networking/coturn.nix
532533 ./services/networking/dante.nix
533534 ./services/networking/ddclient.nix
nixos/modules/services/networking/coredns.nixnew file+50
@@ -0,0 +1,50 @@
1+{ config, lib, pkgs, ... }:
2+
3+with lib;
4+
5+let
6+ cfg = config.services.coredns;
7+ configFile = pkgs.writeText "Corefile" cfg.config;
8+in {
9+ options.services.coredns = {
10+ enable = mkEnableOption "Coredns dns server";
11+
12+ config = mkOption {
13+ default = "";
14+ example = ''
15+ . {
16+ whoami
17+ }
18+ '';
19+ type = types.lines;
20+ description = "Verbatim Corefile to use. See <link xlink:href=\"https://coredns.io/manual/toc/#configuration\"/> for details.";
21+ };
22+
23+ package = mkOption {
24+ default = pkgs.coredns;
25+ defaultText = "pkgs.coredns";
26+ type = types.package;
27+ description = "Coredns package to use.";
28+ };
29+ };
30+
31+ config = mkIf cfg.enable {
32+ systemd.services.coredns = {
33+ description = "Coredns dns server";
34+ after = [ "network.target" ];
35+ wantedBy = [ "multi-user.target" ];
36+ serviceConfig = {
37+ PermissionsStartOnly = true;
38+ LimitNPROC = 512;
39+ LimitNOFILE = 1048576;
40+ CapabilityBoundingSet = "cap_net_bind_service";
41+ AmbientCapabilities = "cap_net_bind_service";
42+ NoNewPrivileges = true;
43+ DynamicUser = true;
44+ ExecStart = "${getBin cfg.package}/bin/coredns -conf=${configFile}";
45+ ExecReload = "${pkgs.coreutils}/bin/kill -SIGUSR1 $MAINPID";
46+ Restart = "on-failure";
47+ };
48+ };
49+ };
50+}