notbad.dynv6.net.nix 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. { config, pkgs, inputs, ... }:
  2. let
  3. domain = "notbad.dynv6.net";
  4. email = "badya65@gmail.com";
  5. homepage.root = "/system/data/homepage";
  6. public = {
  7. alias = "/system/data/pub/";
  8. extraConfig = ''
  9. fancyindex on;
  10. fancyindex_exact_size on;
  11. directio 4M;
  12. '';
  13. };
  14. in {
  15. roles.server = {
  16. inherit domain;
  17. forgejo.enable = true;
  18. miniflux = {
  19. enable = true;
  20. adminCredentialsFile = config.age.secrets.miniflux.path;
  21. };
  22. nginx.enable = true;
  23. };
  24. age.secrets = with inputs.self.modules; {
  25. dynv6.file = secrets.dynv6;
  26. miniflux.file = secrets.miniflux;
  27. nix-serve.file = secrets."nix.notbad.dynv6.net-1";
  28. };
  29. services.nix-serve = {
  30. enable = true;
  31. package = pkgs.nix-serve;
  32. secretKeyFile = config.age.secrets.nix-serve.path;
  33. };
  34. security.acme.certs.${domain} = {
  35. environmentFile = config.age.secrets.dynv6.path;
  36. domain = "*." + domain;
  37. dnsPropagationCheck = true;
  38. dnsProvider = "rfc2136";
  39. inherit email;
  40. extraDomainNames = [ domain ];
  41. inherit (config.security.acme.defaults) group;
  42. };
  43. services.nginx.virtualHosts = {
  44. ${domain} = {
  45. forceSSL = true;
  46. enableACME = true;
  47. acmeRoot = null;
  48. locations."/" = homepage;
  49. locations."/pub/" = public;
  50. extraConfig = ''
  51. add_header Strict-Transport-Security "max-age=15552000; includeSubDomains" always;
  52. '';
  53. };
  54. "nix.${domain}" = {
  55. forceSSL = true;
  56. useACMEHost = domain;
  57. locations."/".proxyPass = "http://${config.services.nix-serve.bindAddress}:${toString config.services.nix-serve.port}";
  58. };
  59. "*.${domain}" = {
  60. default = true;
  61. forceSSL = true;
  62. useACMEHost = domain;
  63. globalRedirect = domain;
  64. };
  65. };
  66. }