diff options
| author | patrick-scho | 2025-04-11 15:38:33 +0200 |
|---|---|---|
| committer | patrick-scho | 2025-04-11 15:38:33 +0200 |
| commit | e72f3f9d2c8a06cab6a5fd6ae773057effcef8b2 (patch) | |
| tree | 985f0747a145e66e2de3e0efe25813cdc3c5653b | |
| parent | 0c35c6390854d5bf7ca4aee7ab8df26671633c84 (diff) | |
| download | chirp-e72f3f9d2c8a06cab6a5fd6ae773057effcef8b2.tar.gz chirp-e72f3f9d2c8a06cab6a5fd6ae773057effcef8b2.zip | |
add systemd service to flake
| -rw-r--r-- | flake.nix | 34 |
1 files changed, 32 insertions, 2 deletions
@@ -21,7 +21,7 @@ ''; installPhase = '' - mkdir -p $out/bin + mkdir -p $out/bin $out/db cp zig-out/bin/chirp $out/bin ''; }; @@ -30,6 +30,36 @@ 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; + }; + }; + }; + }; + }; } |
