I want to run a custom systemd service as the nextcloud user.
Currently I’ve hardcoded the username. But I would prefer to read the nextcloud username from the nixos/modules/services/web-apps/nextcloud.nix module.
The nextcloud module defines the nextcloud user hardcoded as follows
users.users.nextcloud = {
home = "${cfg.home}";
group = "nextcloud";
isSystemUser = true;
};
My guess is that because of this hardcoded username in the nextcloud module, I cannot read the defined username (users.users.nextcloud
) without modifying the nextcloud module itself.
Am I right? Or does nix/NixOS offer some solution I haven’t found yet?
This is my systemd custom service example
systemd = {
paths.nextcloud-brother-filewatch = {
wantedBy = [ "multi-user.target" ];
pathConfig.PathChanged = [ "${nextcloud-folder}" ];
};
services.nextcloud-brother-filewatch = {
wantedBy = [ "multi-user.target" ];
after = [ "network.target" ];
description = "Watch groups home dir for changes and trigger nextcloud rescan.";
serviceConfig = {
Type = "oneshot";
User = "nextcloud"; # todo replace by nextcloud config variable
ExecStart = "/run/current-system/sw/bin/nextcloud-occ groupfolders:scan ${nextcloud-groupfolder-id}";
}; #
};
};