0
0
Fork 0
mirror of https://github.com/NixOS/nixpkgs.git synced 2025-07-13 21:50:33 +03:00

nixos/miniflux: add option to disable configuring a local postgresql db

This commit is contained in:
Sophie Tauchert 2024-02-15 09:47:58 +01:00
parent 051ebee8c9
commit 1f8385d6d1
No known key found for this signature in database
GPG key ID: 52701DE5F5F51125

View file

@ -16,10 +16,20 @@ in
{ {
options = { options = {
services.miniflux = { services.miniflux = {
enable = mkEnableOption (lib.mdDoc "miniflux and creates a local postgres database for it"); enable = mkEnableOption (lib.mdDoc "miniflux");
package = mkPackageOption pkgs "miniflux" { }; package = mkPackageOption pkgs "miniflux" { };
createDatabaseLocally = lib.mkOption {
type = lib.types.bool;
default = true;
description = ''
Whether a PostgreSQL database should be automatically created and
configured on the local host. If set to `false`, you need provision a
database yourself and make sure to create the hstore extension in it.
'';
};
config = mkOption { config = mkOption {
type = with types; attrsOf (oneOf [ str int ]); type = with types; attrsOf (oneOf [ str int ]);
example = literalExpression '' example = literalExpression ''
@ -38,7 +48,7 @@ in
''; '';
}; };
adminCredentialsFile = mkOption { adminCredentialsFile = mkOption {
type = types.path; type = types.path;
description = lib.mdDoc '' description = lib.mdDoc ''
File containing the ADMIN_USERNAME and File containing the ADMIN_USERNAME and
@ -51,14 +61,14 @@ in
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
services.miniflux.config = { services.miniflux.config = {
LISTEN_ADDR = mkDefault defaultAddress; LISTEN_ADDR = mkDefault defaultAddress;
DATABASE_URL = "user=miniflux host=/run/postgresql dbname=miniflux"; DATABASE_URL = lib.mkIf cfg.createDatabaseLocally "user=miniflux host=/run/postgresql dbname=miniflux";
RUN_MIGRATIONS = 1; RUN_MIGRATIONS = 1;
CREATE_ADMIN = 1; CREATE_ADMIN = 1;
}; };
services.postgresql = { services.postgresql = lib.mkIf cfg.createDatabaseLocally {
enable = true; enable = true;
ensureUsers = [ { ensureUsers = [ {
name = "miniflux"; name = "miniflux";
@ -67,7 +77,7 @@ in
ensureDatabases = [ "miniflux" ]; ensureDatabases = [ "miniflux" ];
}; };
systemd.services.miniflux-dbsetup = { systemd.services.miniflux-dbsetup = lib.mkIf cfg.createDatabaseLocally {
description = "Miniflux database setup"; description = "Miniflux database setup";
requires = [ "postgresql.service" ]; requires = [ "postgresql.service" ];
after = [ "network.target" "postgresql.service" ]; after = [ "network.target" "postgresql.service" ];
@ -81,8 +91,9 @@ in
systemd.services.miniflux = { systemd.services.miniflux = {
description = "Miniflux service"; description = "Miniflux service";
wantedBy = [ "multi-user.target" ]; wantedBy = [ "multi-user.target" ];
requires = [ "miniflux-dbsetup.service" ]; requires = lib.optional cfg.createDatabaseLocally "miniflux-dbsetup.service";
after = [ "network.target" "postgresql.service" "miniflux-dbsetup.service" ]; after = [ "network.target" ]
++ lib.optionals cfg.createDatabaseLocally [ "postgresql.service" "miniflux-dbsetup.service" ];
serviceConfig = { serviceConfig = {
ExecStart = "${cfg.package}/bin/miniflux"; ExecStart = "${cfg.package}/bin/miniflux";