default.nix 911 B

1234567891011121314151617181920212223242526272829303132
  1. { config, pkgs, ... }:
  2. let
  3. local-dns = pkgs.runCommand "local-dns" {} ''
  4. mkdir -p $out/bin
  5. cp ${./local-dns} $out/bin/local-dns
  6. '';
  7. in
  8. {
  9. environment.systemPackages = [ local-dns ];
  10. services.unbound = {
  11. enable = true;
  12. enableRootTrustAnchor = false;
  13. extraConfig = ''
  14. include: /var/lib/unbound/unbound-resolvconf.conf
  15. remote-control:
  16. control-enable: yes
  17. control-interface: /var/lib/unbound/unbound.sock
  18. '';
  19. };
  20. # make unbound use unbound group instead so that the control socket is secure
  21. # instead of being in nogroup
  22. users.users.unbound.group = "unbound";
  23. users.groups.unbound = {};
  24. # actually have openresolv update our DNS
  25. networking.resolvconf.extraConfig = ''
  26. unbound_conf=/var/lib/unbound/unbound-resolvconf.conf
  27. unbound_restart="${pkgs.unbound}/bin/unbound-control -c /var/lib/unbound/unbound.conf reload || true"
  28. '';
  29. }