nixos/modules/services/nextcloud.nix

88 lines
3.0 KiB
Nix
Raw Permalink Normal View History

2023-10-04 15:40:28 +08:00
inputs:
{
2024-06-08 13:36:17 +08:00
options.nixos.services.nextcloud = let inherit (inputs.lib) mkOption types; in mkOption
2023-10-04 15:40:28 +08:00
{
2024-06-08 13:36:17 +08:00
type = types.nullOr (types.submodule { options =
{
hostname = mkOption { type = types.nonEmptyStr; default = "nextcloud.chn.moe"; };
};});
default = null;
2023-10-04 15:40:28 +08:00
};
2024-06-08 13:36:17 +08:00
config = let inherit (inputs.config.nixos.services) nextcloud; in inputs.lib.mkIf (nextcloud != null)
{
services.nextcloud =
2023-10-04 15:40:28 +08:00
{
2024-06-08 13:36:17 +08:00
enable = true;
hostName = nextcloud.hostname;
appstoreEnable = false;
https = true;
package = inputs.pkgs.nextcloud29;
maxUploadSize = "10G";
config =
2023-10-04 15:40:28 +08:00
{
2024-06-08 13:36:17 +08:00
dbtype = "pgsql";
dbpassFile = inputs.config.sops.secrets."nextcloud/postgresql".path;
adminuser = "admin";
adminpassFile = inputs.config.sops.secrets."nextcloud/admin".path;
2023-10-04 15:40:28 +08:00
};
2024-06-08 13:36:17 +08:00
configureRedis = true;
settings =
2023-10-04 15:40:28 +08:00
{
2024-06-08 13:36:17 +08:00
mail_domain = "chn.moe";
mail_from_address = "bot";
mail_smtphost = "mail.chn.moe";
mail_smtpport = 465;
mail_smtpsecure = "ssl";
mail_smtpauth = true;
mail_smtpname = "bot@chn.moe";
updatechecker = false;
overwriteprotocol = "https";
default_phone_region = "CN";
};
secretFile = inputs.config.sops.templates."nextcloud/secret".path;
extraApps =
let
2024-08-19 20:23:29 +08:00
version = inputs.lib.versions.major inputs.config.services.nextcloud.package.version;
info = builtins.fromJSON (builtins.readFile "${inputs.topInputs.nc4nix}/${version}.json");
getInfo = package:
2024-06-08 13:36:17 +08:00
{
2024-08-19 20:23:29 +08:00
inherit (info.${package}) hash url description homepage;
appName = package;
appVersion = info.${package}.version;
license =
let
licenses = { agpl = "agpl3Only"; };
originalLincense = builtins.head info.${package}.licenses;
in licenses.${originalLincense} or originalLincense;
2024-06-08 13:36:17 +08:00
};
2024-08-19 20:23:29 +08:00
in builtins.listToAttrs (builtins.map
(package: { name = package; value = inputs.pkgs.fetchNextcloudApp (getInfo package); })
[ "maps" "phonetrack" "twofactor_webauthn" "calendar" ]);
};
2024-06-08 13:36:17 +08:00
nixos.services =
{
postgresql.instances.nextcloud = {};
redis.instances.nextcloud.port = 3499;
nginx = { enable = true; https.${nextcloud.hostname}.global.configName = nextcloud.hostname; };
};
sops =
{
templates."nextcloud/secret" =
{
content = builtins.toJSON
2023-10-04 15:40:28 +08:00
{
2024-06-08 13:36:17 +08:00
redis.password = inputs.config.sops.placeholder."redis/nextcloud";
mail_smtppassword = inputs.config.sops.placeholder."mail/bot";
2023-10-04 15:40:28 +08:00
};
2024-06-08 13:36:17 +08:00
owner = inputs.config.users.users.nextcloud.name;
};
secrets =
{
"nextcloud/postgresql" = { key = "postgresql/nextcloud"; owner = inputs.config.users.users.nextcloud.name; };
"nextcloud/admin".owner = inputs.config.users.users.nextcloud.name;
2023-10-04 15:40:28 +08:00
};
};
2024-06-08 13:36:17 +08:00
systemd.services.nextcloud-setup = rec { requires = [ "postgresql.service" ]; after = requires; };
};
2023-10-04 15:40:28 +08:00
}