From 1f2adf6ba58c4cbcb47a3e6eff7c8001f40cbadd Mon Sep 17 00:00:00 2001 From: Minijackson Date: Sun, 30 May 2021 16:30:11 +0200 Subject: gotify-server: init --- flake.nix | 2 ++ usecases/server/gotify-server.nix | 46 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 usecases/server/gotify-server.nix diff --git a/flake.nix b/flake.nix index 5a04fb3..f8e6fe0 100644 --- a/flake.nix +++ b/flake.nix @@ -76,6 +76,7 @@ ankisyncd = (import ./usecases/server/ankisyncd.nix inputs); audit = (import ./usecases/server/audit.nix inputs); fail2ban = (import ./usecases/server/fail2ban.nix inputs); + gotify-server = (import ./usecases/server/gotify-server.nix inputs); monitoringTarget = (import ./usecases/server/monitoring-target.nix inputs); radicale = (import ./usecases/server/radicale.nix inputs); smartd = (import ./usecases/server/smartd.nix inputs); @@ -169,6 +170,7 @@ self.nixosModules.test self.nixosModules.profiles.server self.nixosModules.usecases.server.ankisyncd + self.nixosModules.usecases.server.gotify-server self.nixosModules.usecases.server.radicale self.nixosModules.usecases.server.zfs diff --git a/usecases/server/gotify-server.nix b/usecases/server/gotify-server.nix new file mode 100644 index 0000000..5445827 --- /dev/null +++ b/usecases/server/gotify-server.nix @@ -0,0 +1,46 @@ +inputs: + +{ config, ... }: + +{ + services.gotify = { + enable = true; + port = 8082; + }; + + # TODO: add proper boot notification + + /* + systemd.services.gotify-notify-boot = { + after = [ "gotify-server.service" ]; + wantedBy = [ "multi-user.target" ]; + + restartIfChanged = false; + + serviceConfig = { + Type = "oneshot"; + + # Priority is needed because there is no configuration, hence no default + # priority to fallback to + ExecStart = let params = lib.cli.toGNUCommandLineShell { } { + url = "http://localhost:${toString config.services.gotify.port}"; + token = "$GOTIFY_TOKEN"; + priority = 0; + }; + in "${pkgs.gotify-cli}/bin/gotify push ${params} 'The system has booted'"; + + RemainAfterExit = "yes"; + # Adds lots of security options + DynamicUser = "yes"; + EnvironmentFile = "/etc/nixos/res/gotify-config.env"; + + Restart = "on-failure"; + RestartSec = "3s"; + }; + }; + */ + + networking.firewall.interfaces.${config.topology.mainVpn.interfaceName}.allowedTCPPorts = [ + config.services.gotify.port + ]; +} -- cgit v1.2.3