forked from meterriblecrew/packages
modules/snipe-it: remove PostgreSQL support
Since Laravel, the PHP framework used by Snipe-IT in general supports PostgreSQL and other database systems, there was a slight hope that it would just work™, even though Snipe-IT itself officially only supports MySQL. Turns out it doesn't. SQLite seems to work fine so far.master
parent
f8c0d8a036
commit
1538ca5859
|
@ -19,8 +19,6 @@ let
|
||||||
fileinfo
|
fileinfo
|
||||||
bcmath
|
bcmath
|
||||||
gd
|
gd
|
||||||
] ++ optionals usePgsql [
|
|
||||||
pdo_pgsql
|
|
||||||
] ++ optionals useMysql [
|
] ++ optionals useMysql [
|
||||||
pdo_mysql
|
pdo_mysql
|
||||||
])
|
])
|
||||||
|
@ -32,7 +30,6 @@ let
|
||||||
group = cfg.group;
|
group = cfg.group;
|
||||||
|
|
||||||
db = cfg.database;
|
db = cfg.database;
|
||||||
usePgsql = db.type == "pgsql";
|
|
||||||
useMysql = db.type == "mysql";
|
useMysql = db.type == "mysql";
|
||||||
useSqlite = db.type == "sqlite";
|
useSqlite = db.type == "sqlite";
|
||||||
|
|
||||||
|
@ -120,8 +117,8 @@ in {
|
||||||
|
|
||||||
database = {
|
database = {
|
||||||
type = mkOption {
|
type = mkOption {
|
||||||
type = types.enum [ "pgsql" "mysql" "sqlite" ];
|
type = types.enum [ "mysql" "sqlite" ];
|
||||||
default = "pgsql";
|
default = "mysql";
|
||||||
description = "Database engine to use.";
|
description = "Database engine to use.";
|
||||||
};
|
};
|
||||||
host = mkOption {
|
host = mkOption {
|
||||||
|
@ -140,7 +137,7 @@ in {
|
||||||
name = mkOption {
|
name = mkOption {
|
||||||
type = types.str;
|
type = types.str;
|
||||||
default = "snipe-it";
|
default = "snipe-it";
|
||||||
description = "Name of the PostgreSQL or MySQL database.";
|
description = "Name of the MySQL database.";
|
||||||
};
|
};
|
||||||
username = mkOption {
|
username = mkOption {
|
||||||
type = types.str;
|
type = types.str;
|
||||||
|
@ -315,12 +312,6 @@ in {
|
||||||
};
|
};
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
assertions = [
|
|
||||||
{ assertion = usePgsql -> db.port == 5432;
|
|
||||||
message = "PostgreSQL is currently only supported with default port 5432.";
|
|
||||||
}
|
|
||||||
];
|
|
||||||
|
|
||||||
warnings =
|
warnings =
|
||||||
optional (!useMysql) ''
|
optional (!useMysql) ''
|
||||||
Please note: Using another database than MySQL isn't officially supported.
|
Please note: Using another database than MySQL isn't officially supported.
|
||||||
|
@ -328,15 +319,6 @@ in {
|
||||||
|
|
||||||
environment.systemPackages = [ artisan ];
|
environment.systemPackages = [ artisan ];
|
||||||
|
|
||||||
services.postgresql = mkIf (usePgsql && db.host == "localhost") {
|
|
||||||
enable = mkDefault true;
|
|
||||||
ensureDatabases = [ db.name ];
|
|
||||||
ensureUsers = [{
|
|
||||||
name = db.username;
|
|
||||||
ensurePermissions = { "DATABASE \"${db.name}\"" = "ALL PRIVILEGES"; };
|
|
||||||
}];
|
|
||||||
};
|
|
||||||
|
|
||||||
services.mysql = mkIf (useMysql && db.host == "localhost") {
|
services.mysql = mkIf (useMysql && db.host == "localhost") {
|
||||||
enable = mkDefault true;
|
enable = mkDefault true;
|
||||||
package = mkDefault pkgs.mariadb;
|
package = mkDefault pkgs.mariadb;
|
||||||
|
@ -431,8 +413,7 @@ in {
|
||||||
systemd.services.snipe-it-setup = {
|
systemd.services.snipe-it-setup = {
|
||||||
description = "Preparation tasks for Snipe-IT";
|
description = "Preparation tasks for Snipe-IT";
|
||||||
before = [ "phpfpm-snipe-it.service" ];
|
before = [ "phpfpm-snipe-it.service" ];
|
||||||
after = optional useMysql "mysql.service"
|
after = optional useMysql "mysql.service";
|
||||||
++ optional usePgsql "postgresql.service";
|
|
||||||
wantedBy = [ "multi-user.target" ];
|
wantedBy = [ "multi-user.target" ];
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
Type = "oneshot";
|
Type = "oneshot";
|
||||||
|
|
Loading…
Reference in New Issue