diff --git a/docs/individual-docs/services/tideways.md b/docs/individual-docs/services/tideways.md new file mode 100644 index 000000000..d3615c80f --- /dev/null +++ b/docs/individual-docs/services/tideways.md @@ -0,0 +1,5 @@ + + +[comment]: # (Please add your documentation on top of this line) + +@AUTOGEN_OPTIONS@ diff --git a/docs/reference/options.md b/docs/reference/options.md index 85abcd61c..69cd0b76a 100644 --- a/docs/reference/options.md +++ b/docs/reference/options.md @@ -70994,6 +70994,161 @@ Port for the Web UI. +## services.tideways.enable + + + +Whether to enable Tideways profiler daemon + +It automatically installs Tideways PHP extension. +. + + + +*Type:* +boolean + + + +*Default:* +` false ` + + + +*Example:* +` true ` + +*Declared by:* + - [https://github.com/cachix/devenv/blob/main/src/modules/services/tideways.nix](https://github.com/cachix/devenv/blob/main/src/modules/services/tideways.nix) + + + +## services.tideways.apiKey + + + +Sets the API-Key for the Tideways Daemon. + + + +*Type:* +string + + + +*Default:* +` "" ` + +*Declared by:* + - [https://github.com/cachix/devenv/blob/main/src/modules/services/tideways.nix](https://github.com/cachix/devenv/blob/main/src/modules/services/tideways.nix) + + + +## services.tideways.cliPackage + + + +Which package of tideways-cli to use + + + +*Type:* +package + + + +*Default:* +` pkgs.tideways-cli ` + +*Declared by:* + - [https://github.com/cachix/devenv/blob/main/src/modules/services/tideways.nix](https://github.com/cachix/devenv/blob/main/src/modules/services/tideways.nix) + + + +## services.tideways.daemonPackage + + + +Which package of tideways-daemon to use + + + +*Type:* +package + + + +*Default:* +` pkgs.tideways-daemon ` + +*Declared by:* + - [https://github.com/cachix/devenv/blob/main/src/modules/services/tideways.nix](https://github.com/cachix/devenv/blob/main/src/modules/services/tideways.nix) + + + +## services.tideways.environment + + + +Sets the Environment for Tideways Daemon. + + + +*Type:* +string + + + +*Default:* +` "devenv" ` + +*Declared by:* + - [https://github.com/cachix/devenv/blob/main/src/modules/services/tideways.nix](https://github.com/cachix/devenv/blob/main/src/modules/services/tideways.nix) + + + +## services.tideways.profilingSpace + + + +When the profiling space is enabled, the default monitoring will be disabled. + + + +*Type:* +boolean + + + +*Default:* +` true ` + +*Declared by:* + - [https://github.com/cachix/devenv/blob/main/src/modules/services/tideways.nix](https://github.com/cachix/devenv/blob/main/src/modules/services/tideways.nix) + + + +## services.tideways.service + + + +Sets the Service name for Tideways Daemon. + + + +*Type:* +string + + + +*Default:* +` "" ` + +*Declared by:* + - [https://github.com/cachix/devenv/blob/main/src/modules/services/tideways.nix](https://github.com/cachix/devenv/blob/main/src/modules/services/tideways.nix) + + + ## services.trafficserver.enable diff --git a/docs/services-all.md b/docs/services-all.md index 6babc17f1..a5b963945 100644 --- a/docs/services-all.md +++ b/docs/services-all.md @@ -27,6 +27,7 @@ services.redis.enable = true; services.sqld.enable = true; services.temporal.enable = true; + services.tideways.enable = true; services.trafficserver.enable = true; services.typesense.enable = true; services.varnish.enable = true; diff --git a/docs/supported-services/tideways.md b/docs/supported-services/tideways.md new file mode 100644 index 000000000..66074d589 --- /dev/null +++ b/docs/supported-services/tideways.md @@ -0,0 +1,134 @@ +[comment]: # (Do not edit this file as it is autogenerated. Go to docs/individual-docs if you want to make edits.) + + +[comment]: # (Please add your documentation on top of this line) + +## services\.tideways\.enable + + + +Whether to enable Tideways profiler daemon + +It automatically installs Tideways PHP extension\. +\. + + + +*Type:* +boolean + + + +*Default:* +` false ` + + + +*Example:* +` true ` + + + +## services\.tideways\.apiKey + +Sets the API-Key for the Tideways Daemon\. + + + +*Type:* +string + + + +*Default:* +` "" ` + + + +## services\.tideways\.cliPackage + + + +Which package of tideways-cli to use + + + +*Type:* +package + + + +*Default:* +` pkgs.tideways-cli ` + + + +## services\.tideways\.daemonPackage + + + +Which package of tideways-daemon to use + + + +*Type:* +package + + + +*Default:* +` pkgs.tideways-daemon ` + + + +## services\.tideways\.environment + + + +Sets the Environment for Tideways Daemon\. + + + +*Type:* +string + + + +*Default:* +` "devenv" ` + + + +## services\.tideways\.profilingSpace + + + +When the profiling space is enabled, the default monitoring will be disabled\. + + + +*Type:* +boolean + + + +*Default:* +` true ` + + + +## services\.tideways\.service + + + +Sets the Service name for Tideways Daemon\. + + + +*Type:* +string + + + +*Default:* +` "" ` diff --git a/src/modules/languages/php.nix b/src/modules/languages/php.nix index 9b7bbcadb..57a4dc202 100644 --- a/src/modules/languages/php.nix +++ b/src/modules/languages/php.nix @@ -317,7 +317,8 @@ in languages.php.extensions = lib.optionals config.services.rabbitmq.enable [ "amqp" ] ++ lib.optionals config.services.redis.enable [ "redis" ] - ++ lib.optionals config.services.blackfire.enable [ "blackfire" ]; + ++ lib.optionals config.services.blackfire.enable [ "blackfire" ] + ++ lib.optionals config.services.tideways.enable [ "tideways" ]; languages.php.ini = '' ${lib.optionalString config.services.mysql.enable '' diff --git a/src/modules/services/tideways.nix b/src/modules/services/tideways.nix new file mode 100644 index 000000000..09998f743 --- /dev/null +++ b/src/modules/services/tideways.nix @@ -0,0 +1,87 @@ +{ pkgs, lib, config, ... }: + +let + cfg = config.services.tideways; + + socket = "${config.env.DEVENV_STATE}/tideways/tidewaysd.sock"; + + startScript = pkgs.writeShellScriptBin "start-tideways" '' + set -euo pipefail + + if [[ ! -d "${config.env.DEVENV_STATE}/tideways" ]]; then + mkdir -p "${config.env.DEVENV_STATE}/tideways" + fi + + exec ${cfg.daemonPackage}/bin/tideways-daemon -address ${socket} --env ${cfg.environment} + ''; +in +{ + options.services.tideways = { + enable = lib.mkEnableOption '' + Tideways profiler daemon + + It automatically installs Tideways PHP extension. + ''; + + apiKey = lib.mkOption { + type = lib.types.str; + description = '' + Sets the API-Key for the Tideways Daemon. + ''; + default = ""; + }; + + service = lib.mkOption { + type = lib.types.str; + description = '' + Sets the Service name for Tideways Daemon. + ''; + default = ""; + }; + + environment = lib.mkOption { + type = lib.types.str; + description = '' + Sets the Environment for Tideways Daemon. + ''; + default = "devenv"; + }; + + profilingSpace = lib.mkOption { + type = lib.types.bool; + description = '' + When the profiling space is enabled, the default monitoring will be disabled. + ''; + default = true; + }; + + daemonPackage = lib.mkOption { + type = lib.types.package; + description = "Which package of tideways-daemon to use"; + default = pkgs.tideways-daemon; + defaultText = lib.literalExpression "pkgs.tideways-daemon"; + }; + + cliPackage = lib.mkOption { + type = lib.types.package; + description = "Which package of tideways-cli to use"; + default = pkgs.tideways-cli; + defaultText = lib.literalExpression "pkgs.tideways-cli"; + }; + }; + + config = lib.mkIf cfg.enable { + packages = [ + cfg.cliPackage + ]; + + processes.tideways-daemon.exec = "${startScript}/bin/start-tideways"; + + languages.php.ini = '' + tideways.api_key=${cfg.apiKey} + tideways.service=${cfg.service} + tideways.connection=unix://${socket} + ${lib.optionalString cfg.profilingSpace "tideways.monitor=none"} + ''; + }; +}