forked from the-distro/infra
43 lines
1.3 KiB
Nix
43 lines
1.3 KiB
Nix
{ 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" { };
|
|
secretFile = mkOption {
|
|
type = types.path;
|
|
};
|
|
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" ];
|
|
wants = [ "network-online.target" ];
|
|
after = [ "network-online.target" ];
|
|
serviceConfig = {
|
|
ExecStart = "${cfg.package}/bin/pyroscope -config.file ${configFile} -config.expand-env";
|
|
WorkingDirectory = "/var/lib/pyroscope";
|
|
User = "pyroscope";
|
|
DynamicUser = true;
|
|
Restart = "on-failure";
|
|
RuntimeDirectory = "pyroscope";
|
|
StateDirectory = "pyroscope";
|
|
EnvironmentFile = [ cfg.secretFile ];
|
|
};
|
|
};
|
|
};
|
|
}
|