default.nix 876 B

12345678910111213141516171819202122232425262728293031
  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. extraConfig = ''
  13. include: /var/lib/unbound/unbound-resolvconf.conf
  14. remote-control:
  15. control-enable: yes
  16. control-interface: /var/lib/unbound/unbound.sock
  17. '';
  18. };
  19. # make unbound use unbound group instead so that the control socket is secure
  20. # instead of being in nogroup
  21. users.users.unbound.group = "unbound";
  22. users.groups.unbound = {};
  23. # actually have openresolv update our DNS
  24. networking.resolvconf.extraConfig = ''
  25. unbound_conf=/var/lib/unbound/unbound-resolvconf.conf
  26. unbound_restart="${pkgs.unbound}/bin/unbound-control -c /var/lib/unbound/unbound.conf reload || true"
  27. '';
  28. }