nixos/modules/services/nextcloud.nix

104 lines
3.8 KiB
Nix
Raw Normal View History

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;
appstoreEnable = false;
2023-10-04 15:40:28 +08:00
https = true;
2024-06-08 13:24:41 +08:00
package = inputs.pkgs.nextcloud28;
2023-10-04 15:40:28 +08:00
maxUploadSize = "10G";
config =
{
dbtype = "pgsql";
dbpassFile = inputs.config.sops.secrets."nextcloud/postgresql".path;
adminuser = "admin";
adminpassFile = inputs.config.sops.secrets."nextcloud/admin".path;
overwriteProtocol = "https";
defaultPhoneRegion = "CN";
};
configureRedis = true;
2024-06-08 12:21:01 +08:00
settings =
2023-10-04 16:14:25 +08:00
{
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";
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-12-02 10:52:42 +08:00
# nix-prefetch-url --unpack
2023-11-22 21:48:23 +08:00
maps = inputs.pkgs.fetchNextcloudApp
{
2024-06-06 22:15:33 +08:00
url = githubRelease "nextcloud/maps" "v1.4.0/maps-1.4.0.tar.gz";
sha256 = "1gqms3rrdpjmpb1h5d72b4lwbvsl8p10zwnkhgnsmvfcf93h3r1c";
license = "agpl3Only";
2023-11-22 21:48:23 +08:00
};
phonetrack = inputs.pkgs.fetchNextcloudApp
{
2024-06-06 22:15:33 +08:00
url = githubRelease "julien-nc/phonetrack" "v0.8.1/phonetrack-0.8.1.tar.gz";
sha256 = "1i28xgzp85yb44ay2l2zw18fk00yd6fh6yddj92gdrljb3w9zpap";
license = "agpl3Only";
2023-11-22 21:48:23 +08:00
};
2024-03-04 12:08:53 +08:00
twofactor_webauthn = inputs.pkgs.fetchNextcloudApp
2023-11-22 21:48:23 +08:00
{
2024-06-06 22:15:33 +08:00
url = githubRelease "nextcloud-releases/twofactor_webauthn" "v1.4.0/twofactor_webauthn-v1.4.0.tar.gz";
sha256 = "0llxakzcdcy9hscyzw3na5zp1p57h03w5fmm0gs9g62k1b88k6kw";
license = "agpl3Only";
2024-03-02 22:06:41 +08:00
};
calendar = inputs.pkgs.fetchNextcloudApp
{
2024-06-06 22:15:33 +08:00
url = githubRelease "nextcloud-releases/calendar" "v4.7.6/calendar-v4.7.6.tar.gz";
sha256 = "09rsp5anpaqzwmrixza5qh12vmq9hd3an045064vm3rnynz537qc";
license = "agpl3Only";
2023-11-22 21:48:23 +08:00
};
2023-10-04 20:59:17 +08:00
};
};
2023-10-04 15:40:28 +08:00
nixos.services =
{
2024-05-10 15:56:42 +08:00
postgresql.instances.nextcloud = {};
2023-10-04 15:40:28 +08:00
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;
};
};
systemd.services.nextcloud-setup = rec { requires = [ "postgresql.service" ]; after = requires; };
2023-10-04 15:40:28 +08:00
};
}