at 23.11-pre 1.6 kB view raw
1{ config, lib, pkgs, ... }: 2 3let 4 cfg = config.services.blackfire-agent; 5 6 agentConfigFile = lib.generators.toINI {} { 7 blackfire = cfg.settings; 8 }; 9 10 agentSock = "blackfire/agent.sock"; 11in { 12 meta = { 13 maintainers = pkgs.blackfire.meta.maintainers; 14 doc = ./blackfire.md; 15 }; 16 17 options = { 18 services.blackfire-agent = { 19 enable = lib.mkEnableOption (lib.mdDoc "Blackfire profiler agent"); 20 settings = lib.mkOption { 21 description = lib.mdDoc '' 22 See https://blackfire.io/docs/up-and-running/configuration/agent 23 ''; 24 type = lib.types.submodule { 25 freeformType = with lib.types; attrsOf str; 26 27 options = { 28 server-id = lib.mkOption { 29 type = lib.types.str; 30 description = lib.mdDoc '' 31 Sets the server id used to authenticate with Blackfire 32 33 You can find your personal server-id at https://blackfire.io/my/settings/credentials 34 ''; 35 }; 36 37 server-token = lib.mkOption { 38 type = lib.types.str; 39 description = lib.mdDoc '' 40 Sets the server token used to authenticate with Blackfire 41 42 You can find your personal server-token at https://blackfire.io/my/settings/credentials 43 ''; 44 }; 45 }; 46 }; 47 }; 48 }; 49 }; 50 51 config = lib.mkIf cfg.enable { 52 environment.etc."blackfire/agent".text = agentConfigFile; 53 54 services.blackfire-agent.settings.socket = "unix:///run/${agentSock}"; 55 56 systemd.packages = [ 57 pkgs.blackfire 58 ]; 59 }; 60}