From 147c8ac01aa6618bdefa7f6923db3f35654b7f99 Mon Sep 17 00:00:00 2001 From: Albert Chae Date: Wed, 30 Aug 2023 16:54:54 -0700 Subject: [PATCH] turn on mysql and uncomment other stuff fix reference to writeText flarum-install is failing on `php flarum migrate`, we suspect because flarum/flarum does not have a reference to the MigrateCommand and instead it lives in flarum/framework other useful commands `nixos-container root-login flarum` `systemctl start ` `systemctl status ` --- modules/flarum.nix | 89 +++++++++++++++++++++++----------------------- 1 file changed, 45 insertions(+), 44 deletions(-) diff --git a/modules/flarum.nix b/modules/flarum.nix index 0cd99d30..7432f49f 100644 --- a/modules/flarum.nix +++ b/modules/flarum.nix @@ -12,7 +12,7 @@ let cfg = config.services.flarum; opt = options.services.flarum; - flarumInstallConfig = writeText "config.php" '' + flarumInstallConfig = pkgs.writeText "config.php" '' false, // enables or disables debug mode, used to troubleshoot issues 'offline' => false, // enables or disables site maintenance mode. This makes your site inaccessible to all users (including admins). @@ -165,48 +165,49 @@ in { }; }; - #services.mysql = mkIf cfg.enable { - # enable = true; - # ensureDatabases = [ cfg.database.database ]; - # ensureUsers = [{ - # name = cfg.database.username; - # ensurePermissions = { - # "${cfg.database.database}.*" = "ALL PRIVILEGES"; - # }; - # }]; - #}; - - #assertions = [{ - # assertion = !cfg.createDatabaseLocally || cfg.database.driver == "mysql"; - # message = "Flarum can only be automatically installed in MySQL/MariaDB."; - #}]; - - #systemd.services.flarum-install = { - # description = "Flarum installation"; - # after = [ "mysql.service" ]; - # requires = [ "mysql.service" ]; - # before = [ "nginx.service" "phpfm-flarum.service" ]; - # wantedBy = [ "phpfpm-flarum.service" ]; - # serviceConfig = { - # Type = "oneshot"; - # User = cfg.user; - # Group = cfg.group; - # }; - # path = [ config.services.phpfpm.phpPackage ]; - # script = '' - # mkdir -p ${cfg.stateDir}/{extensions,public/assets/avatars} - # mkdir -p ${cfg.stateDir}/storage/{formatter,sessions,views} - # cd ${cfg.stateDir} - # cp -f ${cfg.package}/{extend.php,site.php,flarum} . - # ln -sf ${cfg.package}/vendor . - # ln -sf ${cfg.package}/public/index.php public/ - # chmod a+x . public - # '' + lib.optionalString - # (cfg.createDatabaseLocally && cfg.database.driver == "mysql") '' - # cp ${flarumInstallConfig} . - # php flarum migrate - # php flarum cache:clear - # ''; - #}; + services.mysql = mkIf cfg.enable { + enable = true; + package = pkgs.mysql; + ensureDatabases = [ cfg.database.database ]; + ensureUsers = [{ + name = cfg.database.username; + ensurePermissions = { + "${cfg.database.database}.*" = "ALL PRIVILEGES"; + }; + }]; + }; + + assertions = [{ + assertion = !cfg.createDatabaseLocally || cfg.database.driver == "mysql"; + message = "Flarum can only be automatically installed in MySQL/MariaDB."; + }]; + + systemd.services.flarum-install = { + description = "Flarum installation"; + after = [ "mysql.service" ]; + requires = [ "mysql.service" ]; + before = [ "nginx.service" "phpfm-flarum.service" ]; + wantedBy = [ "phpfpm-flarum.service" ]; + serviceConfig = { + Type = "oneshot"; + User = cfg.user; + Group = cfg.group; + }; + path = [ config.services.phpfpm.phpPackage ]; + script = '' + mkdir -p ${cfg.stateDir}/{extensions,public/assets/avatars} + mkdir -p ${cfg.stateDir}/storage/{formatter,sessions,views} + cd ${cfg.stateDir} + cp -f ${cfg.package}/build/{extend.php,site.php,flarum} . + ln -sf ${cfg.package}/build/vendor . + ln -sf ${cfg.package}/build/public/index.php public/ + chmod a+x . public + '' + lib.optionalString + (cfg.createDatabaseLocally && cfg.database.driver == "mysql") '' + cp ${flarumInstallConfig} . + php flarum migrate + php flarum cache:clear + ''; + }; }; }