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

View File

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