Files
Dark Steveneq 646b892680
Some checks failed
Periodic Merges (6h) / master → staging-nixos (push) Failing after 12m50s
Periodic Merges (6h) / master → staging-next (push) Failing after 12m54s
Periodic Merges (24h) / merge-base(master,staging) → haskell-updates (push) Failing after 11m54s
Periodic Merges (6h) / staging-next → staging (push) Failing after 12m13s
Periodic Merges (24h) / staging-next-25.05 → staging-25.05 (push) Failing after 13m24s
Periodic Merges (24h) / release-25.05 → staging-next-25.05 (push) Failing after 14m28s
push sheeet
2025-10-09 14:15:47 +02:00

1.9 KiB

Blackfire profiler

Source: {file}modules/services/development/blackfire.nix

Upstream documentation: https://blackfire.io/docs/introduction

Blackfire is a proprietary tool for profiling applications. There are several languages supported by the product but currently only PHP support is packaged in Nixpkgs. The back-end consists of a module that is loaded into the language runtime (called probe) and a service (agent) that the probe connects to and that sends the profiles to the server.

To use it, you will need to enable the agent and the probe on your server. The exact method will depend on the way you use PHP but here is an example of NixOS configuration for PHP-FPM:

let
  php = pkgs.php.withExtensions ({ enabled, all }: enabled ++ (with all; [ blackfire ]));
in
{
  # Enable the probe extension for PHP-FPM.
  services.phpfpm = {
    phpPackage = php;
  };

  # Enable and configure the agent.
  services.blackfire-agent = {
    enable = true;
    settings = {
      # You will need to get credentials at https://blackfire.io/my/settings/credentials
      # You can also use other options described in https://blackfire.io/docs/up-and-running/configuration/agent
      server-id = "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX";
      server-token = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    };
  };

  # Make the agent run on start-up.
  # (WantedBy= from the upstream unit not respected: https://github.com/NixOS/nixpkgs/issues/81138)
  # Alternately, you can start it manually with `systemctl start blackfire-agent`.
  systemd.services.blackfire-agent.wantedBy = [ "phpfpm-foo.service" ];
}

On your developer machine, you will also want to install the client (see blackfire package) or the browser extension to actually trigger the profiling.