diff options
author | Linnnus <[email protected]> | 2023-10-01 19:20:04 +0200 |
---|---|---|
committer | Linnnus <[email protected]> | 2023-10-01 19:20:04 +0200 |
commit | bb5319539738e39fd4c5412ffff2acb97369e9c3 (patch) | |
tree | 39d46cd5fa2a51bc921e00aa0e120bb0543ccc86 | |
parent | 280aa48893458f0ae980c87fed5e733373ccec9d (diff) |
Move push-notifications-api service definition to own flake
-rw-r--r-- | flake.lock | 12 | ||||
-rw-r--r-- | flake.nix | 3 | ||||
-rw-r--r-- | services/default.nix | 1 | ||||
-rw-r--r-- | services/push-notification-api/default.nix | 67 |
4 files changed, 8 insertions, 75 deletions
@@ -126,11 +126,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1695825837, - "narHash": "sha256-4Ne11kNRnQsmSJCRSSNkFRSnHC4Y5gPDBIQGjjPfJiU=", + "lastModified": 1696039360, + "narHash": "sha256-g7nIUV4uq1TOVeVIDEZLb005suTWCUjSY0zYOlSBsyE=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "5cfafa12d57374f48bcc36fda3274ada276cf69e", + "rev": "32dcb45f66c0487e92db8303a798ebc548cadedc", "type": "github" }, "original": { @@ -148,11 +148,11 @@ ] }, "locked": { - "lastModified": 1696078003, - "narHash": "sha256-h/g1YUfz6L3P3KCQ0ulOXfEqsigLAxghNLiLh+03Jhc=", + "lastModified": 1696180615, + "narHash": "sha256-TBCwnIx0f9nWu9XL5vjq/yo+OYoHWKTFYs9dVz7PnPk=", "owner": "linnnus", "repo": "push-notification-api", - "rev": "1f8f8448e9b879e8e2938482055dd917019cb96f", + "rev": "2a7b14fdd3a947a60ef9db47429da26f28d346ac", "type": "github" }, "original": { @@ -21,7 +21,7 @@ }; }; - outputs = { self, nixpkgs, home-manager, nix-darwin, agenix, ... }@inputs: + outputs = { self, nixpkgs, home-manager, nix-darwin, agenix, push-notification-api, ... }@inputs: let args = { flakeInputs = inputs; @@ -66,6 +66,7 @@ { _module.args = args; } home-manager.nixosModules.home-manager agenix.nixosModules.default + push-notification-api.nixosModules.default ./hosts/ahmed/configuration.nix ./hosts/common.nix ./home diff --git a/services/default.nix b/services/default.nix index 39e030b..995ca27 100644 --- a/services/default.nix +++ b/services/default.nix @@ -9,6 +9,5 @@ [ ./on-demand-minecraft ./duksebot - ./push-notification-api ]; } diff --git a/services/push-notification-api/default.nix b/services/push-notification-api/default.nix deleted file mode 100644 index 1897cd1..0000000 --- a/services/push-notification-api/default.nix +++ /dev/null @@ -1,67 +0,0 @@ -# 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 ]; - }; - }; -} |