Merge pull request #141443 from jtojnar/blackfire-2

This commit is contained in:
Sandro 2021-10-21 20:22:09 +02:00 committed by GitHub
commit 5d74ff4206
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 15 deletions

View File

@ -19,7 +19,7 @@ in {
enable = lib.mkEnableOption "Blackfire profiler agent"; enable = lib.mkEnableOption "Blackfire profiler agent";
settings = lib.mkOption { settings = lib.mkOption {
description = '' description = ''
See https://blackfire.io/docs/configuration/agent See https://blackfire.io/docs/up-and-running/configuration/agent
''; '';
type = lib.types.submodule { type = lib.types.submodule {
freeformType = with lib.types; attrsOf str; freeformType = with lib.types; attrsOf str;
@ -53,13 +53,8 @@ in {
services.blackfire-agent.settings.socket = "unix:///run/${agentSock}"; services.blackfire-agent.settings.socket = "unix:///run/${agentSock}";
systemd.services.blackfire-agent = { systemd.packages = [
description = "Blackfire agent"; pkgs.blackfire
];
serviceConfig = {
ExecStart = "${pkgs.blackfire}/bin/blackfire-agent";
RuntimeDirectory = "blackfire";
};
};
}; };
} }

View File

@ -28,13 +28,14 @@ in {
enable = true; enable = true;
settings = { settings = {
# You will need to get credentials at https://blackfire.io/my/settings/credentials # 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/configuration/agent # 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-id = "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX";
server-token = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; server-token = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
}; };
}; };
# Make the agent run on start-up. # 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`. # Alternately, you can start it manually with `systemctl start blackfire-agent`.
systemd.services.blackfire-agent.wantedBy = [ "phpfpm-foo.service" ]; systemd.services.blackfire-agent.wantedBy = [ "phpfpm-foo.service" ];
}</programlisting> }</programlisting>

View File

@ -10,12 +10,12 @@
}: }:
stdenv.mkDerivation rec { stdenv.mkDerivation rec {
pname = "blackfire-agent"; pname = "blackfire";
version = "1.49.4"; version = "2.5.1";
src = fetchurl { src = fetchurl {
url = "https://packages.blackfire.io/debian/pool/any/main/b/blackfire-php/blackfire-agent_${version}_amd64.deb"; url = "https://packages.blackfire.io/debian/pool/any/main/b/blackfire/blackfire_${version}_amd64.deb";
sha256 = "t1S54z3xTMTUBWz0jCFX1A7GJdWWsP/lTa9MMjo8t1A="; sha256 = "wak7LE5j6OKIHqCsEGrxSq1FAFzehMetYj6c/Zkr9dk=";
}; };
nativeBuildInputs = [ nativeBuildInputs = [
@ -32,13 +32,26 @@ stdenv.mkDerivation rec {
mv $out/usr/* $out mv $out/usr/* $out
rmdir $out/usr rmdir $out/usr
# Fix ExecStart path and replace deprecated directory creation method,
# use dynamic user.
substituteInPlace "$out/lib/systemd/system/blackfire-agent.service" \
--replace '/usr/' "$out/" \
--replace 'ExecStartPre=/bin/mkdir -p /var/run/blackfire' 'RuntimeDirectory=blackfire' \
--replace 'ExecStartPre=/bin/chown blackfire: /var/run/blackfire' "" \
--replace 'User=blackfire' 'DynamicUser=yes' \
--replace 'PermissionsStartOnly=true' ""
# Modernize socket path.
substituteInPlace "$out/etc/blackfire/agent" \
--replace '/var/run' '/run'
runHook postInstall runHook postInstall
''; '';
passthru = { passthru = {
updateScript = writeShellScript "update-${pname}" '' updateScript = writeShellScript "update-${pname}" ''
export PATH="${lib.makeBinPath [ curl jq common-updater-scripts ]}" export PATH="${lib.makeBinPath [ curl jq common-updater-scripts ]}"
update-source-version "$UPDATE_NIX_ATTR_PATH" "$(curl https://blackfire.io/api/v1/releases | jq .agent --raw-output)" update-source-version "$UPDATE_NIX_ATTR_PATH" "$(curl https://blackfire.io/api/v1/releases | jq .cli --raw-output)"
''; '';
}; };