mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-18 19:51:17 +00:00
nixos/nextcloud: Support create database locally
This commit is contained in:
parent
b496e3b8cc
commit
047473aa32
|
@ -2285,6 +2285,14 @@
|
|||
like <literal>firefox</literal>.
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
The Nextcloud module now supports to create a Mysql database
|
||||
automatically with
|
||||
<literal>services.nextcloud.database.createLocally</literal>
|
||||
enabled.
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
The <literal>spark3</literal> package has been updated from
|
||||
|
|
|
@ -810,6 +810,9 @@ In addition to numerous new and upgraded packages, this release has the followin
|
|||
|
||||
- The `nss` package was split into `nss_esr` and `nss_latest`, with `nss` being an alias for `nss_esr`. This was done to ease maintenance of `nss` and dependent high-profile packages like `firefox`.
|
||||
|
||||
- The Nextcloud module now supports to create a Mysql database automatically
|
||||
with `services.nextcloud.database.createLocally` enabled.
|
||||
|
||||
- The `spark3` package has been updated from 3.1.2 to 3.2.1 ([#160075](https://github.com/NixOS/nixpkgs/pull/160075)):
|
||||
|
||||
- Testing has been enabled for `aarch64-linux` in addition to `x86_64-linux`.
|
||||
|
|
|
@ -251,6 +251,23 @@ in {
|
|||
'';
|
||||
};
|
||||
|
||||
database = {
|
||||
|
||||
createLocally = mkOption {
|
||||
type = types.bool;
|
||||
default = false;
|
||||
description = ''
|
||||
Create the database and database user locally. Only available for
|
||||
mysql database.
|
||||
Note that this option will use the latest version of MariaDB which
|
||||
is not officially supported by Nextcloud. As for now a workaround
|
||||
is used to also support MariaDB version >= 10.6.
|
||||
'';
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
|
||||
config = {
|
||||
dbtype = mkOption {
|
||||
type = types.enum [ "sqlite" "pgsql" "mysql" ];
|
||||
|
@ -583,6 +600,12 @@ in {
|
|||
else pkgs.php80;
|
||||
}
|
||||
|
||||
{ assertions = [
|
||||
{ assertion = cfg.database.createLocally -> cfg.config.dbtype == "mysql";
|
||||
message = ''services.nextcloud.config.dbtype must be set to mysql if services.nextcloud.database.createLocally is set to true.'';
|
||||
}
|
||||
]; }
|
||||
|
||||
{ systemd.timers.nextcloud-cron = {
|
||||
wantedBy = [ "timers.target" ];
|
||||
timerConfig.OnBootSec = "5m";
|
||||
|
@ -811,6 +834,32 @@ in {
|
|||
|
||||
environment.systemPackages = [ occ ];
|
||||
|
||||
services.mysql = lib.mkIf cfg.database.createLocally {
|
||||
enable = true;
|
||||
package = lib.mkDefault pkgs.mariadb;
|
||||
ensureDatabases = [ cfg.config.dbname ];
|
||||
ensureUsers = [{
|
||||
name = cfg.config.dbuser;
|
||||
ensurePermissions = { "${cfg.config.dbname}.*" = "ALL PRIVILEGES"; };
|
||||
}];
|
||||
# FIXME(@Ma27) Nextcloud isn't compatible with mariadb 10.6,
|
||||
# this is a workaround.
|
||||
# See https://help.nextcloud.com/t/update-to-next-cloud-21-0-2-has-get-an-error/117028/22
|
||||
settings = {
|
||||
mysqld = {
|
||||
innodb_read_only_compressed = 0;
|
||||
};
|
||||
};
|
||||
initialScript = pkgs.writeText "mysql-init" ''
|
||||
CREATE USER '${cfg.config.dbname}'@'localhost' IDENTIFIED BY '${builtins.readFile( cfg.config.dbpassFile )}';
|
||||
CREATE DATABASE IF NOT EXISTS ${cfg.config.dbname};
|
||||
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER,
|
||||
CREATE TEMPORARY TABLES ON ${cfg.config.dbname}.* TO '${cfg.config.dbuser}'@'localhost'
|
||||
IDENTIFIED BY '${builtins.readFile( cfg.config.dbpassFile )}';
|
||||
FLUSH privileges;
|
||||
'';
|
||||
};
|
||||
|
||||
services.nginx.enable = mkDefault true;
|
||||
|
||||
services.nginx.virtualHosts.${cfg.hostName} = {
|
||||
|
|
|
@ -26,6 +26,7 @@ in {
|
|||
redis = false;
|
||||
memcached = true;
|
||||
};
|
||||
database.createLocally = true;
|
||||
config = {
|
||||
dbtype = "mysql";
|
||||
dbname = "nextcloud";
|
||||
|
@ -38,28 +39,6 @@ in {
|
|||
};
|
||||
};
|
||||
|
||||
services.mysql = {
|
||||
enable = true;
|
||||
settings.mysqld = {
|
||||
bind-address = "127.0.0.1";
|
||||
|
||||
# FIXME(@Ma27) Nextcloud isn't compatible with mariadb 10.6,
|
||||
# this is a workaround.
|
||||
# See https://help.nextcloud.com/t/update-to-next-cloud-21-0-2-has-get-an-error/117028/22
|
||||
innodb_read_only_compressed = 0;
|
||||
};
|
||||
package = pkgs.mariadb;
|
||||
|
||||
initialScript = pkgs.writeText "mysql-init" ''
|
||||
CREATE USER 'nextcloud'@'localhost' IDENTIFIED BY 'hunter2';
|
||||
CREATE DATABASE IF NOT EXISTS nextcloud;
|
||||
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER,
|
||||
CREATE TEMPORARY TABLES ON nextcloud.* TO 'nextcloud'@'localhost'
|
||||
IDENTIFIED BY 'hunter2';
|
||||
FLUSH privileges;
|
||||
'';
|
||||
};
|
||||
|
||||
systemd.services.nextcloud-setup= {
|
||||
requires = ["mysql.service"];
|
||||
after = ["mysql.service"];
|
||||
|
|
Loading…
Reference in a new issue