From fa8f7fa147d88d61c3144bb89bb6c77c23a0622d Mon Sep 17 00:00:00 2001 From: Sam Willcocks Date: Thu, 4 Aug 2022 10:45:31 +0300 Subject: [PATCH] Add nixos module --- flake.nix | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) 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"; + }; + }; + }; + }; + }; }