import:
{ imports = [ ./hardware-configuration.nix ./lnmp.nix ./mastodon.nix ./peertube.nix ./nextcloud.nix ]; }
新建nextcloud.nix:
nano /etc/nixos/nextcloud.nix
我的配置如下:
{ config, pkgs, lib, ... }: { security.acme = { acceptTerms = true; defaults = { email = "nextcloud@example.com"; }; }; services.nginx = { enable = true; virtualHosts."nextcloud.example.com" = { enableACME = true; forceSSL = true; kTLS = true; }; }; services.nextcloud = { enable = true; package = pkgs.nextcloud24; https = true; webfinger = true; hostName = "nextcloud.example.com"; maxUploadSize = "10240M"; database.createLocally = true; config = { overwriteProtocol = "https"; defaultPhoneRegion = "CN"; adminuser = "imlala"; adminpassFile = "/etc/nextcloud-admin-password"; dbtype = "mysql"; dbname = "nextcloud"; dbuser = "nextcloud"; dbpassFile = "/etc/nextcloud-db-password"; }; }; }
mastodon包的维护者是直接帮你配置好nginx,你完全不用操心nginx的配置。peertube包的维护者是不管nginx配置,需要你自动手动配置。
而nextcloud包的维护者是帮你配置了nginx但没有启用ssl,所以我们只需要配置一个和services.nextcloud.hostName相同的services.nginx.virtualHosts并启用ssl即可。
除此之外,需要设置好管理员密码:
echo "password" > /etc/nextcloud-admin-password
以及数据库的密码:
echo "password" > /etc/nextcloud-db-password
配置完成后重建系统:
nixos-rebuild switch
一个nextcloud实例就配置好了,看一下概览可以发现只有一个smtp未配置的警告:
甚至连后台任务都帮你配置成使用系统cron了,可以看得出来这个包的维护者也都是讲究人,包的质量很高:
NixOS配置NixOS