nextcloud: create service

This commit is contained in:
Antoine Martin 2021-03-23 19:31:59 +01:00
parent 48c87a4d8a
commit b04d9e51a1
6 changed files with 80 additions and 0 deletions

View file

@ -114,6 +114,10 @@ in
domain = "monitoring.${config.networking.domain}"; domain = "monitoring.${config.networking.domain}";
}; };
nextcloud = {
enable = true;
};
postgresql-backup = { postgresql-backup = {
enable = true; enable = true;
}; };

View file

@ -12,6 +12,8 @@ with lib;
miniflux-admin-credentials = lib.fileContents ./miniflux-admin-credentials.secret; miniflux-admin-credentials = lib.fileContents ./miniflux-admin-credentials.secret;
borg-backup-repo = lib.fileContents ./borg-backup-repo.secret; borg-backup-repo = lib.fileContents ./borg-backup-repo.secret;
transmission-password = lib.fileContents ./transmission.secret; transmission-password = lib.fileContents ./transmission.secret;
nextcloud-admin-pass = lib.fileContents ./nextcloud-admin-pass.secret;
nextcloud-admin-user = lib.fileContents ./nextcloud-admin-user.secret;
wireguard = pkgs.callPackage ./wireguard.nix { }; wireguard = pkgs.callPackage ./wireguard.nix { };
}; };

Binary file not shown.

Binary file not shown.

View file

@ -11,6 +11,7 @@
./media.nix ./media.nix
./miniflux.nix ./miniflux.nix
./monitoring.nix ./monitoring.nix
./nextcloud.nix
./nginx.nix ./nginx.nix
./postgresql-backup.nix ./postgresql-backup.nix
./tgv.nix ./tgv.nix

73
services/nextcloud.nix Normal file
View file

@ -0,0 +1,73 @@
{ lib, config, pkgs, ... }:
# TODO: setup prometheus exporter
let
cfg = config.my.services.nextcloud;
my = config.my;
domain = config.networking.domain;
dbName = "nextcloud";
in
{
options.my.services.nextcloud = {
enable = lib.mkEnableOption "NextCloud";
};
config = lib.mkIf cfg.enable {
# FIXME: set postgresql package globally
services.postgresql = {
enable = true;
ensureDatabases = [ dbName ];
ensureUsers = [
{
name = "nextcloud";
ensurePermissions = {
"DATABASE ${dbName}" = "ALL PRIVILEGES";
};
}
];
};
services.postgresqlBackup = {
databases = [ dbName ];
};
services.nextcloud = {
enable = true;
hostName = "cloud.${domain}";
https = true;
package = pkgs.nextcloud21;
maxUploadSize = "1G";
config = {
overwriteProtocol = "https";
defaultPhoneRegion = "FR";
dbtype = "pgsql";
dbuser = "nextcloud";
dbname = dbName;
dbhost = "/run/postgresql";
adminuser = my.secrets.nextcloud-admin-user;
adminpass = my.secrets.nextcloud-admin-pass;
};
};
services.nginx = {
virtualHosts = {
"cloud.${domain}" = {
forceSSL = true;
enableACME = true;
};
};
};
my.services.borg-backup = lib.mkIf cfg.enable {
paths = [ config.services.nextcloud.home ];
};
};
}