diff options
author | Linnnus <[email protected]> | 2023-09-30 14:53:27 +0200 |
---|---|---|
committer | Linnnus <[email protected]> | 2023-09-30 14:53:55 +0200 |
commit | d7fc02342227fbd442f47e27fa12a42ff7998cd5 (patch) | |
tree | 9f90238e85d4f271cdce6dfe26e8683add68f10f /services | |
parent | 039061095ad29da895479ea3dbd68e40689f5f72 (diff) |
fix everything forever i hope
Diffstat (limited to 'services')
-rw-r--r-- | services/default.nix | 1 | ||||
-rw-r--r-- | services/on-demand-minecraft/default.nix | 2 | ||||
-rw-r--r-- | services/push-notification-api/default.nix | 67 |
3 files changed, 70 insertions, 0 deletions
diff --git a/services/default.nix b/services/default.nix index 995ca27..39e030b 100644 --- a/services/default.nix +++ b/services/default.nix @@ -9,5 +9,6 @@ [ ./on-demand-minecraft ./duksebot + ./push-notification-api ]; } diff --git a/services/on-demand-minecraft/default.nix b/services/on-demand-minecraft/default.nix index e811f39..541a624 100644 --- a/services/on-demand-minecraft/default.nix +++ b/services/on-demand-minecraft/default.nix @@ -50,6 +50,7 @@ in The internal port which the minecraft server will listen to. This port does not need to be exposed to the network. ''; + type = types.port; default = cfg.external-port + 1; }; @@ -63,6 +64,7 @@ in You may also have to set up port forwarding if you want to play with friends who are not on the same LAN. ''; + type = types.port; default = 25565; }; 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 ]; + }; + }; +} |