Merge pull request #93584 from DavHau/nextcloud-improvements
nextcloud: restrict web server support to nginx; stop sharing nginx user/group; improve setup service
This commit is contained in:
commit
50d8cdb3ca
@ -45,6 +45,12 @@ let
|
|||||||
inherit (config.system) stateVersion;
|
inherit (config.system) stateVersion;
|
||||||
|
|
||||||
in {
|
in {
|
||||||
|
|
||||||
|
imports = [
|
||||||
|
( mkRemovedOptionModule [ "services" "nextcloud" "nginx" "enable" ]
|
||||||
|
"The nextcloud module dropped support for other webservers than nginx.")
|
||||||
|
];
|
||||||
|
|
||||||
options.services.nextcloud = {
|
options.services.nextcloud = {
|
||||||
enable = mkEnableOption "nextcloud";
|
enable = mkEnableOption "nextcloud";
|
||||||
hostName = mkOption {
|
hostName = mkOption {
|
||||||
@ -91,16 +97,6 @@ in {
|
|||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
nginx.enable = mkOption {
|
|
||||||
type = types.bool;
|
|
||||||
default = false;
|
|
||||||
description = ''
|
|
||||||
Whether to enable nginx virtual host management.
|
|
||||||
Further nginx configuration can be done by adapting <literal>services.nginx.virtualHosts.<name></literal>.
|
|
||||||
See <xref linkend="opt-services.nginx.virtualHosts"/> for further information.
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
webfinger = mkOption {
|
webfinger = mkOption {
|
||||||
type = types.bool;
|
type = types.bool;
|
||||||
default = false;
|
default = false;
|
||||||
@ -468,10 +464,18 @@ in {
|
|||||||
script = ''
|
script = ''
|
||||||
chmod og+x ${cfg.home}
|
chmod og+x ${cfg.home}
|
||||||
ln -sf ${cfg.package}/apps ${cfg.home}/
|
ln -sf ${cfg.package}/apps ${cfg.home}/
|
||||||
mkdir -p ${cfg.home}/config ${cfg.home}/data ${cfg.home}/store-apps
|
|
||||||
ln -sf ${overrideConfig} ${cfg.home}/config/override.config.php
|
|
||||||
|
|
||||||
chown -R nextcloud:nginx ${cfg.home}/config ${cfg.home}/data ${cfg.home}/store-apps
|
# create nextcloud directories.
|
||||||
|
# if the directories exist already with wrong permissions, we fix that
|
||||||
|
for dir in ${cfg.home}/config ${cfg.home}/data ${cfg.home}/store-apps; do
|
||||||
|
if [ ! -e $dir ]; then
|
||||||
|
install -o nextcloud -g nextcloud -d $dir
|
||||||
|
elif [ $(stat -c "%G" $dir) != "nextcloud" ]; then
|
||||||
|
chgrp -R nextcloud $dir
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
ln -sf ${overrideConfig} ${cfg.home}/config/override.config.php
|
||||||
|
|
||||||
# Do not install if already installed
|
# Do not install if already installed
|
||||||
if [[ ! -e ${cfg.home}/config/config.php ]]; then
|
if [[ ! -e ${cfg.home}/config/config.php ]]; then
|
||||||
@ -484,6 +488,7 @@ in {
|
|||||||
${occSetTrustedDomainsCmd}
|
${occSetTrustedDomainsCmd}
|
||||||
'';
|
'';
|
||||||
serviceConfig.Type = "oneshot";
|
serviceConfig.Type = "oneshot";
|
||||||
|
serviceConfig.User = "nextcloud";
|
||||||
};
|
};
|
||||||
nextcloud-cron = {
|
nextcloud-cron = {
|
||||||
environment.NEXTCLOUD_CONFIG_DIR = "${cfg.home}/config";
|
environment.NEXTCLOUD_CONFIG_DIR = "${cfg.home}/config";
|
||||||
@ -502,7 +507,7 @@ in {
|
|||||||
services.phpfpm = {
|
services.phpfpm = {
|
||||||
pools.nextcloud = {
|
pools.nextcloud = {
|
||||||
user = "nextcloud";
|
user = "nextcloud";
|
||||||
group = "nginx";
|
group = "nextcloud";
|
||||||
phpOptions = phpOptionsStr;
|
phpOptions = phpOptionsStr;
|
||||||
phpPackage = phpPackage;
|
phpPackage = phpPackage;
|
||||||
phpEnv = {
|
phpEnv = {
|
||||||
@ -510,27 +515,25 @@ in {
|
|||||||
PATH = "/run/wrappers/bin:/nix/var/nix/profiles/default/bin:/run/current-system/sw/bin:/usr/bin:/bin";
|
PATH = "/run/wrappers/bin:/nix/var/nix/profiles/default/bin:/run/current-system/sw/bin:/usr/bin:/bin";
|
||||||
};
|
};
|
||||||
settings = mapAttrs (name: mkDefault) {
|
settings = mapAttrs (name: mkDefault) {
|
||||||
"listen.owner" = "nginx";
|
"listen.owner" = config.services.nginx.user;
|
||||||
"listen.group" = "nginx";
|
"listen.group" = config.services.nginx.group;
|
||||||
} // cfg.poolSettings;
|
} // cfg.poolSettings;
|
||||||
extraConfig = cfg.poolConfig;
|
extraConfig = cfg.poolConfig;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
users.extraUsers.nextcloud = {
|
users.users.nextcloud = {
|
||||||
home = "${cfg.home}";
|
home = "${cfg.home}";
|
||||||
group = "nginx";
|
group = "nextcloud";
|
||||||
createHome = true;
|
createHome = true;
|
||||||
};
|
};
|
||||||
|
users.groups.nextcloud.members = [ "nextcloud" config.services.nginx.user ];
|
||||||
|
|
||||||
environment.systemPackages = [ occ ];
|
environment.systemPackages = [ occ ];
|
||||||
}
|
|
||||||
|
|
||||||
(mkIf cfg.nginx.enable {
|
services.nginx = mkDefault {
|
||||||
services.nginx = {
|
|
||||||
enable = true;
|
enable = true;
|
||||||
virtualHosts = {
|
virtualHosts.${cfg.hostName} = {
|
||||||
${cfg.hostName} = {
|
|
||||||
root = cfg.package;
|
root = cfg.package;
|
||||||
locations = {
|
locations = {
|
||||||
"= /robots.txt" = {
|
"= /robots.txt" = {
|
||||||
@ -630,8 +633,7 @@ in {
|
|||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
}
|
||||||
})
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
meta.doc = ./nextcloud.xml;
|
meta.doc = ./nextcloud.xml;
|
||||||
|
@ -33,7 +33,6 @@ in {
|
|||||||
|
|
||||||
services.nextcloud = {
|
services.nextcloud = {
|
||||||
enable = true;
|
enable = true;
|
||||||
nginx.enable = true;
|
|
||||||
hostName = "nextcloud";
|
hostName = "nextcloud";
|
||||||
config = {
|
config = {
|
||||||
# Don't inherit adminuser since "root" is supposed to be the default
|
# Don't inherit adminuser since "root" is supposed to be the default
|
||||||
|
@ -17,7 +17,6 @@ in {
|
|||||||
services.nextcloud = {
|
services.nextcloud = {
|
||||||
enable = true;
|
enable = true;
|
||||||
hostName = "nextcloud";
|
hostName = "nextcloud";
|
||||||
nginx.enable = true;
|
|
||||||
https = true;
|
https = true;
|
||||||
caching = {
|
caching = {
|
||||||
apcu = true;
|
apcu = true;
|
||||||
|
@ -17,7 +17,6 @@ in {
|
|||||||
services.nextcloud = {
|
services.nextcloud = {
|
||||||
enable = true;
|
enable = true;
|
||||||
hostName = "nextcloud";
|
hostName = "nextcloud";
|
||||||
nginx.enable = true;
|
|
||||||
caching = {
|
caching = {
|
||||||
apcu = false;
|
apcu = false;
|
||||||
redis = true;
|
redis = true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user