Skip to content

Commit

Permalink
turn on mysql and uncomment other stuff
Browse files Browse the repository at this point in the history
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 <name>`
`systemctl status <name>`
  • Loading branch information
albertchae committed Aug 30, 2023
1 parent d291d8e commit 147c8ac
Showing 1 changed file with 45 additions and 44 deletions.
89 changes: 45 additions & 44 deletions modules/flarum.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ let
cfg = config.services.flarum;
opt = options.services.flarum;

flarumInstallConfig = writeText "config.php" ''
flarumInstallConfig = pkgs.writeText "config.php" ''
<?php return array (
'debug' => 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).
Expand Down Expand Up @@ -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
'';
};
};
}

0 comments on commit 147c8ac

Please sign in to comment.