Add nixos module
This commit is contained in:
parent
6436cc2e57
commit
fa8f7fa147
32
flake.nix
32
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";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue