X-Git-Url: https://gitweb.ps.run/chirp/blobdiff_plain/905636122af78773898162129182c7663a72a9d4..82ffe1a0f6aa569a718a0db07a380f7f93c7f1d8:/flake.nix?ds=inline diff --git a/flake.nix b/flake.nix index 3444d10..cef0b0f 100644 --- a/flake.nix +++ b/flake.nix @@ -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; + }; + }; + }; + }; + }; }