From fd3a8eddcb44829c3e5aded7d768e0f7b27fb2f6 Mon Sep 17 00:00:00 2001 From: "Adam C. Stephens" Date: Sat, 29 Nov 2025 12:31:44 -0500 Subject: [PATCH] nixos/miniflux: don't require DATABASE_URL if not createDatabaseLocally For example, if providing through EnvironmentFile due to secrets then we need to allow the env to build without this config. Fixes this error: error: The option `services.miniflux.config.DATABASE_URL' was accessed but has no value defined. Try setting the option. --- nixos/modules/services/web-apps/miniflux.nix | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/nixos/modules/services/web-apps/miniflux.nix b/nixos/modules/services/web-apps/miniflux.nix index 03447395fef6..bad9c0d95337 100644 --- a/nixos/modules/services/web-apps/miniflux.nix +++ b/nixos/modules/services/web-apps/miniflux.nix @@ -64,8 +64,13 @@ in 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"; + type = types.nullOr types.str; + defaultText = literalExpression '' + if createDatabaseLocally then "user=miniflux host=/run/postgresql dbname=miniflux" else null + ''; + default = + if cfg.createDatabaseLocally then "user=miniflux host=/run/postgresql dbname=miniflux" else null; + description = '' Postgresql connection parameters. See [lib/pq](https://pkg.go.dev/github.com/lib/pq#hdr-Connection_String_Parameters) for more details. @@ -116,9 +121,6 @@ in message = "services.miniflux.adminCredentialsFile must be set if services.miniflux.config.CREATE_ADMIN is 1"; } ]; - services.miniflux.config = { - DATABASE_URL = lib.mkIf cfg.createDatabaseLocally "user=miniflux host=/run/postgresql dbname=miniflux"; - }; services.postgresql = lib.mkIf cfg.createDatabaseLocally { enable = true; @@ -202,7 +204,7 @@ in UMask = "0077"; }; - environment = lib.mapAttrs (_: toString) cfg.config; + environment = lib.mapAttrs (_: toString) (lib.filterAttrs (_: v: v != null) cfg.config); }; environment.systemPackages = [ cfg.package ];