miniflux.nix 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. { config, lib, ... }:
  2. with lib;
  3. let
  4. cfg = config.roles.server.miniflux;
  5. in {
  6. options.roles.server.miniflux = {
  7. enable = mkOption {
  8. default = false;
  9. type = types.bool;
  10. };
  11. domain = mkOption {
  12. default = config.roles.server.domain;
  13. type = types.str;
  14. };
  15. adminCredentialsFile = mkOption {
  16. default = "${pkgs.writeText "minifluxPass" ''
  17. ADMIN_USERNAME="admin"
  18. ADMIN_PASSWORD="password"
  19. ''}";
  20. type = types.str;
  21. };
  22. pollingFrequency = mkOption {
  23. default = "30";
  24. type = types.str;
  25. };
  26. };
  27. config = mkIf cfg.enable {
  28. roles.server.nginx.enable = mkForce true;
  29. systemd.services.miniflux.serviceConfig.RuntimeDirectoryMode = lib.mkForce "0755";
  30. services = {
  31. miniflux = {
  32. enable = true;
  33. inherit (cfg) adminCredentialsFile;
  34. config = {
  35. LISTEN_ADDR = "/run/miniflux/miniflux.sock";
  36. POLLING_FREQUENCY = cfg.pollingFrequency;
  37. BASE_URL = "https://rss." + cfg.domain;
  38. };
  39. };
  40. nginx = {
  41. upstreams.miniflux.servers = { "unix:${config.services.miniflux.config.LISTEN_ADDR}" = {}; };
  42. virtualHosts."rss.${cfg.domain}" = {
  43. forceSSL = true;
  44. useACMEHost = cfg.domain;
  45. locations."/".proxyPass = "http://miniflux";
  46. };
  47. };
  48. };
  49. };
  50. }