diff --git a/flake.nix b/flake.nix index 605b0c3..436e71b 100644 --- a/flake.nix +++ b/flake.nix @@ -35,5 +35,35 @@ devShells.default = pkgs.devshell.mkShell {packages = with pkgs; [go gopls];}; formatter = pkgs.alejandra; - }); + }) + // { + nixosModules.default = { + config, + lib, + ... + }: + with lib; let + cfg = config.services.twitter-prometheus; + in { + options.services.twitter-prometheus = { + enable = mkEnableOption "Enables the twitter-prometheus service"; + listenAddr = mkOption { + type = types.string; + description = "The address to listen on."; + default = "localhost:9700"; + }; + }; + config = mkIf cfg.enable { + systemd.services.twitter-prometheus = { + description = self.description; + wantedBy = ["multi-user.target"]; + serviceConfig = { + User = "twitter-prometheus"; + ExecStart = "${self.apps.default}/bin/twitter-prometheus -listenAddr ${cfg.listenAddr}"; + Restart = "on-failure"; + }; + }; + }; + }; + }; }