nixos/nextcloud-notify_push: init

This commit is contained in:
ajs124 2022-12-13 21:08:00 +01:00
parent 3b2a768f0f
commit 1f0aa74c8f
2 changed files with 58 additions and 0 deletions

View file

@ -1166,6 +1166,7 @@
./services/web-apps/moodle.nix
./services/web-apps/netbox.nix
./services/web-apps/nextcloud.nix
./services/web-apps/nextcloud-notify_push.nix
./services/web-apps/nexus.nix
./services/web-apps/nifi.nix
./services/web-apps/node-red.nix

View file

@ -0,0 +1,57 @@
{ config, lib, pkgs, ... }:
let
cfg = config.services.nextcloud.notify_push;
in
{
options.services.nextcloud.notify_push = {
enable = lib.mkEnableOption (lib.mdDoc "Notify push");
package = lib.mkOption {
type = lib.types.package;
default = pkgs.nextcloud-notify_push;
defaultText = lib.literalMD "pkgs.nextcloud-notify_push";
description = lib.mdDoc "Which package to use for notify_push";
};
socketPath = lib.mkOption {
type = lib.types.str;
default = "/run/nextcloud-notify_push/sock";
description = lib.mdDoc "Socket path to use for notify_push";
};
logLevel = lib.mkOption {
type = lib.types.enum [ "error" "warn" "info" "debug" "trace" ];
default = "error";
description = lib.mdDoc "Log level";
};
};
config = lib.mkIf cfg.enable {
systemd.services.nextcloud-notify_push = let
nextcloudUrl = "http${lib.optionalString config.services.nextcloud.https "s"}://${config.services.nextcloud.hostName}";
in {
description = "Push daemon for Nextcloud clients";
documentation = [ "https://github.com/nextcloud/notify_push" ];
after = [ "phpfpm-nextcloud.service" ];
wantedBy = [ "multi-user.target" ];
environment = {
NEXTCLOUD_URL = nextcloudUrl;
SOCKET_PATH = cfg.socketPath;
LOG = cfg.logLevel;
};
postStart = ''
${config.services.nextcloud.occ}/bin/nextcloud-occ notify_push:setup ${nextcloudUrl}/push
'';
serviceConfig = {
ExecStart = "${cfg.package}/bin/notify_push --glob-config ${config.services.nextcloud.datadir}/config/config.php";
User = "nextcloud";
Group = "nextcloud";
RuntimeDirectory = [ "nextcloud-notify_push" ];
};
};
services.nginx.virtualHosts.${config.services.nextcloud.hostName}.locations."^~ /push/" = {
proxyPass = "http://unix:${cfg.socketPath}";
proxyWebsockets = true;
recommendedProxySettings = true;
};
};
}