infra/services/monitoring/pyroscope/module.nix

37 lines
1.1 KiB
Nix
Raw Normal View History

{ pkgs, lib, config, ... }:
let
inherit (lib) mkEnableOption mkPackageOption mkOption types mkIf;
settingsFormatYaml = pkgs.formats.yaml { };
cfg = config.services.pyroscope;
configFile = settingsFormatYaml.generate "settings.yaml" cfg.settings;
in
{
options.services.pyroscope = {
enable = mkEnableOption "pyroscope, a continuous profiling platform";
package = mkPackageOption pkgs "pyroscope" { };
settings = mkOption {
description = "Pyroscope settings. See <>";
type = types.submodule {
freeformType = settingsFormatYaml.type;
};
};
};
config = mkIf cfg.enable {
systemd.services.pyroscope = {
description = "Pyroscope server - a continuous profiling platform";
wantedBy = [ "multi-user.target" ];
serviceConfig = {
ExecStart = "${cfg.package}/bin/pyroscope -config.file ${configFile}";
WorkingDirectory = "/var/lib/pyroscope";
User = "pyroscope";
DynamicUser = true;
Restart = "on-failure";
RuntimeDirectory = "pyroscope";
StateDirectory = "pyroscope";
};
};
};
}