WIP setup db and webserver

this is the first working version. system could be tested and worked.
it maybe that database setup is still wrong and privileges of /var/ep3bs
are not handled properly right now
This commit is contained in:
2023-03-20 20:55:21 +01:00
parent 5feae91463
commit bec8f91848
2 changed files with 19 additions and 15 deletions

View File

@@ -167,7 +167,7 @@ in
name = mkOption {
type = types.str;
default = "ep3bs";
default = "ep3bsdb";
description = lib.mdDoc "Database name.";
};
@@ -229,7 +229,6 @@ in
"d '${cfg.stateDir}/config/autoload' 777 ${cfg.user} ep3-bs - -"
"d '${cfg.stateDir}/vendor' 777 ${cfg.user} ep3-bs - -"
"d '${cfg.stateDir}/vendor/symfony' 777 ${cfg.user} ep3-bs - -"
#"z '${cfg.stateDir}' 777 ${cfg.user} ep3-bs - -"
"Z '${cfg.stateDir}' 777 ${cfg.user} ep3-bs - -"
];
@@ -243,14 +242,16 @@ in
"rewrite"
];
virtualHosts.localhost = {
documentRoot = mkDefault "${cfg.stateDir}";
documentRoot = mkDefault "${cfg.stateDir}/public/";
extraConfig = ''
<Directory ${cfg.stateDir}/>
<Directory ${cfg.stateDir}/public/>
DirectoryIndex index.php index.htm index.html
Allow from *
Options +FollowSymlinks
AllowOverride All
Require all granted
php_admin_flag display_errors on
php_admin_value error_reporting 22517
</Directory>
'';
};
@@ -260,18 +261,20 @@ in
enable = mkDefault true;
package = mkDefault pkgs.mariadb;
initialScript = let
mysqlInitScript = pkgs.writeText "mysqlInitScript" ''
CREATE USER '${cfg.database.user}'@'localhost' IDENTIFIED BY '${cfg.database.password}';
#GRANT ALL PRIVILEGES ON DATABASE ${cfg.database.name} TO '${cfg.database.user}'@'localhost';
initialScript = pkgs.writeText "mysqlInitScript" ''
CREATE USER '${cfg.database.user}'@localhost IDENTIFIED BY '${cfg.database.password}';
CREATE DATABASE ${cfg.database.name};
GRANT ALL PRIVILEGES ON *.* TO '${cfg.database.user}'@localhost IDENTIFIED BY '${cfg.database.password}';
FLUSH PRIVILEGES;
'';
in "${mysqlInitScript}";
ensureDatabases = [ cfg.database.name ];
ensureUsers = [
{ name = cfg.database.user;
ensurePermissions = { "${cfg.database.name}.*" = "ALL PRIVILEGES"; };
}
];
#ensureDatabases = [ cfg.database.name ];
#ensureUsers = [
# { name = cfg.database.user;
# ensurePermissions = { "${cfg.database.name}.*" = "ALL PRIVILEGES"; };
# }
#];
};
systemd.services.ep3-bs = {

View File

@@ -34,6 +34,7 @@
./ep3-bs.nix
{
services.ep3-bs.enable = true;
services.ep3-bs.database.user = "testuser3";
services.ep3-bs.database.password = "testPassword1234";
users.users.test = {
isNormalUser = true;