diff --git a/nixos/modules/services/web-apps/miniflux.nix b/nixos/modules/services/web-apps/miniflux.nix index 8b89c03b24bc..e4ffc1677626 100644 --- a/nixos/modules/services/web-apps/miniflux.nix +++ b/nixos/modules/services/web-apps/miniflux.nix @@ -17,7 +17,7 @@ let ; cfg = config.services.miniflux; - defaultAddress = "localhost:8080"; + boolToInt = b: if b then 1 else 0; pgbin = "${config.services.postgresql.package}/bin"; preStart = pkgs.writeScript "miniflux-pre-start" '' @@ -44,25 +44,53 @@ in }; config = mkOption { - type = - with types; - attrsOf (oneOf [ - str - int - ]); - example = literalExpression '' - { - CLEANUP_FREQUENCY = 48; - LISTEN_ADDR = "localhost:8080"; - } - ''; + type = types.submodule { + freeformType = + with types; + attrsOf (oneOf [ + str + int + ]); + options = { + LISTEN_ADDR = mkOption { + type = types.str; + default = "localhost:8080"; + description = '' + Address to listen on. Use absolute path for a Unix socket. + Multiple addresses can be specified, separated by commas. + ''; + example = "127.0.0.1:8080, 127.0.0.1:8081"; + }; + DATABASE_URL = mkOption { + type = types.str; + defaultText = "user=miniflux host=/run/postgresql dbname=miniflux"; + description = '' + Postgresql connection parameters. + See [lib/pq](https://pkg.go.dev/github.com/lib/pq#hdr-Connection_String_Parameters) for more details. + ''; + }; + RUN_MIGRATIONS = mkOption { + type = with types; coercedTo bool boolToInt int; + default = true; + description = "Run database migrations."; + }; + CREATE_ADMIN = mkOption { + type = with types; coercedTo bool boolToInt int; + default = true; + description = "Create an admin user from environment variables."; + }; + WATCHDOG = mkOption { + type = with types; coercedTo bool boolToInt int; + default = true; + description = "Enable or disable Systemd watchdog."; + }; + }; + }; + default = { }; description = '' Configuration for Miniflux, refer to for documentation on the supported values. - - Correct configuration for the database is already provided. - By default, listens on ${defaultAddress}. ''; }; @@ -87,11 +115,7 @@ in } ]; services.miniflux.config = { - LISTEN_ADDR = mkDefault defaultAddress; DATABASE_URL = lib.mkIf cfg.createDatabaseLocally "user=miniflux host=/run/postgresql dbname=miniflux"; - RUN_MIGRATIONS = 1; - CREATE_ADMIN = lib.mkDefault 1; - WATCHDOG = 1; }; services.postgresql = lib.mkIf cfg.createDatabaseLocally {