]> gitweb.ps.run Git - chirp/blobdiff - flake.nix
update ziglmdb and remove unneeded directory creation from flake
[chirp] / flake.nix
index 3444d104a79e43d2873a10a5cc86ce241a4f4092..cef0b0f6b61416d58553bad6ba0219a27367a870 100644 (file)
--- a/flake.nix
+++ b/flake.nix
           type = "app";
           program = "${self.packages.${system}.default}/bin/chirp";
         };
-      });
+      })
+      // {
+        nixosModules.default = { config, lib, pkgs, ... }: {
+          options.services.chirp = {
+            enable = lib.mkEnableOption "Enable Chirp";
+
+            port = lib.mkOption {
+              type = lib.types.port;
+              default = 8080;
+              description = "Port to listen on";
+            };
+          };
+
+          config = lib.mkIf config.services.chirp.enable {
+            systemd.services.chirp = {
+              description = "Chirp SystemD Service";
+              wantedBy = ["multi-user.target"];
+              after = ["network.target"];
+              serviceConfig = {
+                ExecStart = "${self.packages.${pkgs.system}.default}/bin/chirp";
+                Restart = "always";
+                Type = "simple";
+                DynamicUser = "yes";
+              };
+              environment = {
+                PORT = toString config.services.chirp.port;
+              };
+            };
+          };
+        };
+      };
 }