summaryrefslogtreecommitdiff
path: root/services/push-notification-api
diff options
context:
space:
mode:
authorLinnnus <[email protected]>2023-09-30 14:53:27 +0200
committerLinnnus <[email protected]>2023-09-30 14:53:55 +0200
commitd7fc02342227fbd442f47e27fa12a42ff7998cd5 (patch)
tree9f90238e85d4f271cdce6dfe26e8683add68f10f /services/push-notification-api
parent039061095ad29da895479ea3dbd68e40689f5f72 (diff)
fix everything forever i hope
Diffstat (limited to 'services/push-notification-api')
-rw-r--r--services/push-notification-api/default.nix67
1 files changed, 67 insertions, 0 deletions
diff --git a/services/push-notification-api/default.nix b/services/push-notification-api/default.nix
new file mode 100644
index 0000000..1897cd1
--- /dev/null
+++ b/services/push-notification-api/default.nix
@@ -0,0 +1,67 @@
+# Temporary definition for push-notification-api service. This will be moved
+# into the flake once it's finished.
+
+{ pkgs, lib, config, flakeInputs, ... }:
+
+let
+ inherit (lib) mkEnableOption mkOption mkIf types;
+ cfg = config.my.services.push-notification-api;
+in
+{
+ options.my.services.push-notification-api = {
+ enable = mkEnableOption "Push notification API";
+
+ package = mkOption {
+ description = "What package to use.";
+ default = flakeInputs.push-notification-api.packages.${pkgs.system}.default;
+ type = types.package;
+ };
+
+ host = mkOption {
+ description = "Host(name) to passed to server";
+ type = types.nonEmptyStr;
+ default = "0.0.0.0";
+ };
+
+ port = mkOption {
+ description = "Port to listen for requests on";
+ type = types.port;
+ default = 8000;
+ };
+
+ openFirewall = mkEnableOption "Poke holes in the firewall to permit LAN connections.";
+ };
+
+ config = mkIf cfg.enable {
+ # Create a user to run the server under.
+ users.users.push-notification-api = {
+ description = "Runs daily dukse reminder";
+ group = "push-notification-api";
+ isSystemUser = true;
+ home = "/srv/push-notification-api";
+ createHome = true;
+ };
+ users.groups.push-notification-api = { };
+
+ # Create a service which runs the server.
+ systemd.services.push-notification-api = {
+ wantedBy = [ "multi-user.target" ];
+ after = [ "network.target" "netowrk-online.target" ];
+ wants = [ "network.target" ];
+
+ serviceConfig = {
+ Type = "simple";
+ User = config.users.users.push-notification-api.name;
+ Group = config.users.users.push-notification-api.group;
+ WorkingDirectory = config.users.users.push-notification-api.home;
+ ExecStart = ''
+ "${cfg.package}"/bin/push-notification-api --port ${toString cfg.port} --host "${cfg.host}"
+ '';
+ };
+ };
+
+ networking.firewall = mkIf cfg.openFirewall {
+ allowedTCPPorts = [ cfg.port ];
+ };
+ };
+}