2023-10-04 15:40:28 +08:00
|
|
|
inputs:
|
|
|
|
{
|
2023-10-04 15:42:34 +08:00
|
|
|
options.nixos.services.nextcloud = let inherit (inputs.lib) mkOption types; in
|
2023-10-04 15:40:28 +08:00
|
|
|
{
|
2023-10-04 15:46:55 +08:00
|
|
|
enable = mkOption { type = types.bool; default = false; };
|
2023-11-12 17:29:40 +08:00
|
|
|
hostname = mkOption { type = types.nonEmptyStr; default = "nextcloud.chn.moe"; };
|
2023-10-04 15:40:28 +08:00
|
|
|
};
|
|
|
|
config =
|
|
|
|
let
|
2023-10-04 15:42:34 +08:00
|
|
|
inherit (inputs.config.nixos.services) nextcloud;
|
2023-10-04 15:40:28 +08:00
|
|
|
inherit (inputs.localLib) attrsToList;
|
|
|
|
inherit (inputs.lib) mkIf mkMerge;
|
|
|
|
inherit (builtins) map listToAttrs toString replaceStrings filter toJSON;
|
2023-10-04 15:42:34 +08:00
|
|
|
in mkIf nextcloud.enable
|
2023-10-04 15:40:28 +08:00
|
|
|
{
|
|
|
|
services.nextcloud =
|
|
|
|
{
|
|
|
|
enable = true;
|
2023-10-04 15:42:34 +08:00
|
|
|
hostName = nextcloud.hostname;
|
2023-10-04 20:45:05 +08:00
|
|
|
appstoreEnable = false;
|
2023-10-04 15:40:28 +08:00
|
|
|
https = true;
|
|
|
|
package = inputs.pkgs.nextcloud27;
|
|
|
|
maxUploadSize = "10G";
|
|
|
|
config =
|
|
|
|
{
|
|
|
|
dbtype = "pgsql";
|
|
|
|
dbpassFile = inputs.config.sops.secrets."nextcloud/postgresql".path;
|
|
|
|
dbport = 5432;
|
|
|
|
adminuser = "admin";
|
|
|
|
adminpassFile = inputs.config.sops.secrets."nextcloud/admin".path;
|
|
|
|
overwriteProtocol = "https";
|
|
|
|
defaultPhoneRegion = "CN";
|
|
|
|
};
|
|
|
|
configureRedis = true;
|
2023-10-04 16:14:25 +08:00
|
|
|
extraOptions =
|
|
|
|
{
|
|
|
|
mail_domain = "chn.moe";
|
2023-10-04 20:06:45 +08:00
|
|
|
mail_from_address = "bot";
|
2023-10-04 16:14:25 +08:00
|
|
|
mail_smtphost = "mail.chn.moe";
|
|
|
|
mail_smtpport = 465;
|
|
|
|
mail_smtpsecure = "ssl";
|
|
|
|
mail_smtpauth = true;
|
|
|
|
mail_smtpname = "bot@chn.moe";
|
2023-10-05 16:12:53 +08:00
|
|
|
updatechecker = false;
|
2023-10-04 16:14:25 +08:00
|
|
|
};
|
2023-10-04 15:40:28 +08:00
|
|
|
secretFile = inputs.config.sops.templates."nextcloud/secret".path;
|
2023-10-04 20:59:17 +08:00
|
|
|
extraApps =
|
2023-11-22 21:48:23 +08:00
|
|
|
let
|
|
|
|
githubRelease = repo: file: "https://github.com/${repo}/releases/download/${file}";
|
|
|
|
in
|
2023-10-04 20:59:17 +08:00
|
|
|
{
|
2023-11-22 21:48:23 +08:00
|
|
|
maps = inputs.pkgs.fetchNextcloudApp
|
|
|
|
{
|
|
|
|
url = githubRelease "nextcloud/maps" "v1.1.1/maps-1.1.1.tar.gz";
|
|
|
|
sha256 = "1rcmqnm5364h5gaq1yy6b6d7k17napgn0yc9ymrnn75bps9s71v9";
|
|
|
|
license = "agpl3";
|
|
|
|
};
|
|
|
|
phonetrack = inputs.pkgs.fetchNextcloudApp
|
|
|
|
{
|
|
|
|
url = githubRelease "julien-nc/phonetrack" "v0.7.6/phonetrack-0.7.6.tar.gz";
|
|
|
|
sha256 = "1p15vw7c5c1h08czyxi1r6svjd5hjmnc0i6is4vl3xq2kfjmcyyx";
|
|
|
|
license = "agpl3";
|
|
|
|
};
|
|
|
|
twofactor_webauthn = inputs.pkgs.fetchNextcloudApp
|
|
|
|
{
|
|
|
|
url = githubRelease "nextcloud/twofactor_webauthn" "v1.3.0/twofactor_webauthn-v1.3.0.tar.gz";
|
|
|
|
sha256 = "1akqd5sqz5g58dx3rp15ls7sczviikwwcqn8pj3kii1ffvi9xqx8";
|
|
|
|
license = "agpl3";
|
|
|
|
};
|
2023-10-04 20:59:17 +08:00
|
|
|
};
|
|
|
|
};
|
2023-10-04 15:40:28 +08:00
|
|
|
nixos.services =
|
|
|
|
{
|
|
|
|
postgresql = { enable = true; instances.nextcloud = {}; };
|
|
|
|
redis.instances.nextcloud.port = 3499;
|
2023-11-16 15:51:47 +08:00
|
|
|
nginx = { enable = true; https.${nextcloud.hostname}.global.configName = nextcloud.hostname; };
|
2023-10-04 15:40:28 +08:00
|
|
|
};
|
|
|
|
sops =
|
|
|
|
{
|
2023-10-04 15:56:11 +08:00
|
|
|
templates."nextcloud/secret" =
|
|
|
|
{
|
2023-10-04 16:14:25 +08:00
|
|
|
content = toJSON
|
|
|
|
{
|
|
|
|
redis.password = inputs.config.sops.placeholder."redis/nextcloud";
|
|
|
|
mail_smtppassword = inputs.config.sops.placeholder."mail/bot";
|
|
|
|
};
|
2023-10-04 15:56:11 +08:00
|
|
|
owner = inputs.config.users.users.nextcloud.name;
|
|
|
|
};
|
2023-10-04 15:40:28 +08:00
|
|
|
secrets =
|
|
|
|
{
|
|
|
|
"nextcloud/postgresql" = { key = "postgresql/nextcloud"; owner = inputs.config.users.users.nextcloud.name; };
|
|
|
|
"nextcloud/admin".owner = inputs.config.users.users.nextcloud.name;
|
|
|
|
};
|
|
|
|
};
|
2023-11-20 20:46:29 +08:00
|
|
|
systemd.services.nextcloud-setup = rec { requires = [ "postgresql.service" ]; after = requires; };
|
2023-10-04 15:40:28 +08:00
|
|
|
};
|
|
|
|
}
|