Add nixos module

This commit is contained in:
Sam W 2022-08-04 10:45:31 +03:00
parent 6436cc2e57
commit fa8f7fa147
1 changed files with 31 additions and 1 deletions

View File

@ -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";
};
};
};
};
};
}