twitter-prometheus/flake.nix

70 lines
1.9 KiB
Nix
Raw Normal View History

2022-08-03 23:59:15 +01:00
{
description = "Twitter follower counts in Prometheus.";
inputs.utils.url = "github:numtide/flake-utils";
inputs.devshell = {
url = "github:numtide/devshell";
inputs.utils.follows = "utils";
};
outputs = {
self,
nixpkgs,
utils,
devshell,
}:
utils.lib.eachDefaultSystem (system: let
pkgs = import nixpkgs {
inherit system;
overlays = [devshell.overlay];
};
in rec {
packages.default = pkgs.buildGoModule {
name = "twitter-prometheus";
src = self;
2022-08-04 00:03:19 +01:00
vendorSha256 = "vZ56zJNcMSZonNqLNPEWCQkyuDH50SqGOC/vdz0w6uA=";
2022-08-03 23:59:15 +01:00
# Inject the git version if you want
#ldflags = ''
# -X main.version=${if self ? rev then self.rev else "dirty"}
#'';
};
apps.default = utils.lib.mkApp {drv = packages.default;};
devShells.default =
pkgs.devshell.mkShell {packages = with pkgs; [go gopls];};
formatter = pkgs.alejandra;
2022-08-04 08:45:31 +01:00
})
// {
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";
};
};
};
};
};
2022-08-03 23:59:15 +01:00
}