Problem/Motivation
The shellHook in template/flake.nix uses echo to print informational messages — "Entering development environment for ${projectName}" and "Use '?', '??', or 'flake-help' to see the commands provided in this flake." These messages are written to stdout.
When a downstream tool runs nix develop -c <command> and pipes the command's output to a structured-data parser (e.g., jq for JSON, or grep for table output), the shellHook banner text contaminates stdout. For example, running:
nix develop -c drush status --format=json 2>/dev/nullproduces stdout like:
Entering development environment for myproject Use '?', '??', or 'flake-help' to see the commands provided in this flake. {"drupal-version": "11.1.0", ...}
— which is not valid JSON and breaks any consumer expecting clean output. The same issue affects the test shell (nix develop .#test).
Steps to reproduce
- Create a new project from the drupal-flake template:
nix flake init -t git+https://git.drupalcode.org/project/drupal_flake - Run a command that outputs structured data through the dev shell:
nix develop -c drush status --format=json 2>/dev/null - Observe that the JSON output is preceded by the shellHook banner messages, making it unparseable
Proposed resolution
Change echo to >&2 echo in the two shellHook definitions inside template/flake.nix:
- Dev shell
shellHook(~line 896): redirect bothechocalls to stderr - Test shell
shellHook(~line 1040): same change
This is a one-line prefix change per echo statement. Informational messages remain visible on the terminal (stderr is displayed by default) but no longer interfere with stdout-based pipelines. Example:
- echo "Entering development environment for ${projectName}" - echo "Use '?', '??', or 'flake-help' to see the commands provided in this flake." + >&2 echo "Entering development environment for ${projectName}" + >&2 echo "Use '?', '??', or 'flake-help' to see the commands provided in this flake."
Remaining tasks
- Review and merge the change
- Tag a new release
User interface changes
None. The messages continue to display in the terminal; only their output stream changes from stdout to stderr.
API changes
None.
Data model changes
None.
Issue summary and fix AI-assisted by DeepSeek V4 Flash.
Comments
Comment #3
freelockThis is already included/working.