summaryrefslogtreecommitdiffstats
path: root/nixos/modules/services/misc
diff options
context:
space:
mode:
authorFelix Singer <felixsinger@posteo.net>2024-03-23 16:47:24 +0100
committerFelix Singer <felixsinger@posteo.net>2024-03-30 08:23:20 +0100
commitddd15dc2d92f52138b8cac9be2a2f5e6c277b1c0 (patch)
tree9e8e8ec3a1eda7e0b15d5f6fc5b99b1044520697 /nixos/modules/services/misc
parent19edccb0eed14b297863817cbc032932600f5203 (diff)
nixos/redmine: Allow using SQLite as database backend
Signed-off-by: Felix Singer <felixsinger@posteo.net>
Diffstat (limited to 'nixos/modules/services/misc')
-rw-r--r--nixos/modules/services/misc/redmine.nix13
1 files changed, 7 insertions, 6 deletions
diff --git a/nixos/modules/services/misc/redmine.nix b/nixos/modules/services/misc/redmine.nix
index 1873d7da4cb9..957571944b28 100644
--- a/nixos/modules/services/misc/redmine.nix
+++ b/nixos/modules/services/misc/redmine.nix
@@ -13,11 +13,12 @@ let
databaseSettings = {
production = {
adapter = cfg.database.type;
- database = cfg.database.name;
+ database = if cfg.database.type == "sqlite3" then "${cfg.stateDir}/database.sqlite3" else cfg.database.name;
+ } // optionalAttrs (cfg.database.type != "sqlite3") {
host = if (cfg.database.type == "postgresql" && cfg.database.socket != null) then cfg.database.socket else cfg.database.host;
port = cfg.database.port;
username = cfg.database.user;
- } // optionalAttrs (cfg.database.passwordFile != null) {
+ } // optionalAttrs (cfg.database.type != "sqlite3" && cfg.database.passwordFile != null) {
password = "#dbpass#";
} // optionalAttrs (cfg.database.type == "mysql2" && cfg.database.socket != null) {
socket = cfg.database.socket;
@@ -150,7 +151,7 @@ in
database = {
type = mkOption {
- type = types.enum [ "mysql2" "postgresql" ];
+ type = types.enum [ "mysql2" "postgresql" "sqlite3" ];
example = "postgresql";
default = "mysql2";
description = lib.mdDoc "Database engine to use.";
@@ -266,7 +267,7 @@ in
config = mkIf cfg.enable {
assertions = [
- { assertion = cfg.database.passwordFile != null || cfg.database.socket != null;
+ { assertion = cfg.database.type != "sqlite3" -> cfg.database.passwordFile != null || cfg.database.socket != null;
message = "one of services.redmine.database.socket or services.redmine.database.passwordFile must be set";
}
{ assertion = cfg.database.createLocally -> cfg.database.user == cfg.user;
@@ -275,7 +276,7 @@ in
{ assertion = pgsqlLocal -> cfg.database.user == cfg.database.name;
message = "services.redmine.database.user and services.redmine.database.name must be the same when using a local postgresql database";
}
- { assertion = cfg.database.createLocally -> cfg.database.socket != null;
+ { assertion = cfg.database.createLocally -> cfg.database.type != "sqlite3" && cfg.database.socket != null;
message = "services.redmine.database.socket must be set if services.redmine.database.createLocally is set to true";
}
{ assertion = cfg.database.createLocally -> cfg.database.host == "localhost";
@@ -402,7 +403,7 @@ in
# handle database.passwordFile & permissions
cp -f ${databaseYml} "${cfg.stateDir}/config/database.yml"
- ${optionalString (cfg.database.passwordFile != null) ''
+ ${optionalString ((cfg.database.type != "sqlite3") && (cfg.database.passwordFile != null)) ''
DBPASS="$(head -n1 ${cfg.database.passwordFile})"
sed -e "s,#dbpass#,$DBPASS,g" -i "${cfg.stateDir}/config/database.yml"
''}