Skip to content

Conversation

@jpds
Copy link
Contributor

@jpds jpds commented Nov 19, 2025

More likely to find the version number in --version than --help so look for that first.

Things done

  • Built on platform:
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • Tested, as applicable:
  • Ran nixpkgs-review on this PR. See nixpkgs-review usage.
  • Tested basic functionality of all binary files, usually in ./result/bin/.
  • Nixpkgs Release Notes
    • Package update: when the change is major or breaking.
  • NixOS Release Notes
    • Module addition: when adding a new NixOS module.
    • Module update: when the change is significant.
  • Fits CONTRIBUTING.md, pkgs/README.md, maintainers/README.md and other READMEs.

Add a 👍 reaction to pull requests you find important.

@jpds jpds requested a review from doronbehar November 19, 2025 15:57
@nixpkgs-ci nixpkgs-ci bot added 10.rebuild-linux: 501+ This PR causes many rebuilds on Linux and should normally target the staging branches. 10.rebuild-darwin: 501+ This PR causes many rebuilds on Darwin and should normally target the staging branches. 10.rebuild-darwin: 5001+ This PR causes many rebuilds on Darwin and must target the staging branches. 10.rebuild-linux: 5001+ This PR causes many rebuilds on Linux and must target the staging branches. labels Nov 19, 2025
@jpds jpds force-pushed the versioncheckhook-version-first branch from 11a50bb to ed0803a Compare November 19, 2025 16:28
@nixpkgs-ci nixpkgs-ci bot added the 8.has: documentation This PR adds or changes documentation label Nov 19, 2025
@Zaczero
Copy link
Member

Zaczero commented Nov 19, 2025

My first thought: Does this change improve anything realistically?

More likely

Is there any evidence? 👀

@jpds
Copy link
Contributor Author

jpds commented Nov 19, 2025

Is there any evidence? 👀

Yeah, a quick grep shows that a 800+ packages where a bunch of us decided to manually specify this over 5 who hardcoded --help.

@Zaczero
Copy link
Member

Zaczero commented Nov 19, 2025

Hmm. If "--help" is the first default, there's no reason for people to specify "--help" explicitly. I don't think your statistic is sound.

@jpds
Copy link
Contributor Author

jpds commented Nov 19, 2025

I know, I do not know why those people decided to specify that.

I do know that I've been adding it to my packages as I don't see the point in calling something every time when one knows it's going to fail, both at a test build level and in Hydra.

Edit: and there's also established software like ClickHouse that don't show a version number in their help usage, see: https://hydra.nixos.org/build/312909059/nixlog/2

Copy link
Member

@Zaczero Zaczero left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I went ahead and run research AI agents:

Gemini:

The Dominant Pattern: The GNU style of --version (exclusively for metadata) and --help (exclusively for instruction) is the overwhelming norm.

The Modern Shift: A "Hybrid" pattern is emerging, primarily in Rust-based tooling, where version info is displayed in both locations. This accounts for roughly 15-20% of newer tools but does not displace the dedicated version flag.

Gemini 2:

Based on the analysis of 108 common Linux tools, the findings are as follows:

Approximately 93% of the analyzed tools provide their version number when the --version flag (or an equivalent such as -V or -v) is used.

Approximately 53% of these tools also include their version number within the output of the --help flag (or display it when the command is invoked with invalid options or by default).

ChatGPT:

Percentage statistics: Out of our sample of 24 tools, about 25% (roughly one-quarter) included their version number in the --help output. These were mainly interactive or user-facing tools like Bash, Wget, Apt, Vim, and Nano. In contrast, almost all tools (around 95% of those sampled) provided a dedicated --version flag (or equivalent -V) to display the version info. Only very few exceptions (≈5%) lacked a version flag (for example, the minimalist shell dash).

Based on that, I am convinced this is a positive change.

@nixpkgs-ci nixpkgs-ci bot added the 12.approvals: 1 This PR was reviewed and approved by one person. label Nov 19, 2025
@doronbehar doronbehar marked this pull request as draft November 19, 2025 17:43
@doronbehar doronbehar changed the base branch from master to staging November 19, 2025 17:43
@nixpkgs-ci nixpkgs-ci bot closed this Nov 19, 2025
@nixpkgs-ci nixpkgs-ci bot reopened this Nov 19, 2025
@doronbehar
Copy link
Contributor

Could you please fix the staging rebase?

github-actions[bot]

This comment was marked as resolved.

@jpds jpds force-pushed the versioncheckhook-version-first branch from ed0803a to f1d090e Compare November 19, 2025 17:53
@github-actions github-actions bot dismissed their stale review November 19, 2025 17:53

All good now, thank you!

@jpds jpds marked this pull request as ready for review November 19, 2025 18:32
@doronbehar
Copy link
Contributor

Hmm maybe we should remove the versionCheckProgramArg = "--version"; lines now? We are targeting staging anyway so we can live with the large amount of rebuilds. This script can be used:

git grep -l 'versionCheckProgramArg = "--version";' | while read f; do
  sed -i '/versionCheckProgramArg/d' "$f"
done

@jpds jpds force-pushed the versioncheckhook-version-first branch 2 times, most recently from 238c9e7 to 28e15a8 Compare November 20, 2025 10:28
jpds added 2 commits November 20, 2025 10:38
More likely to find the version number in `--version` than `--help` so
look for that first.
```shell
git grep -l -e 'versionCheckProgramArg = "--version";' -e 'versionCheckProgramArg = \[ "--version" \];' | while read f; do
  sed -i '/versionCheckProgramArg/d' "$f"
  sed -i '/^$/N;/\n$/D' "$f"
done
```
@jpds jpds force-pushed the versioncheckhook-version-first branch from 28e15a8 to 116036d Compare November 20, 2025 10:39
@nixpkgs-ci nixpkgs-ci bot added the 6.topic: python Python is a high-level, general-purpose programming language. label Nov 20, 2025
@nixpkgs-ci nixpkgs-ci bot added 6.topic: vim Advanced text editor 6.topic: lua Lua is a powerful, efficient, lightweight, embeddable scripting language. 6.topic: docker tools Open-source software for deploying and running of containerized applications 6.topic: jupyter Interactive computing tooling: kernels, notebook, jupyterlab 6.topic: php PHP is a general-purpose scripting language geared towards web development. 6.topic: k3s Kubernates distribution (https://k3s.io/) labels Nov 20, 2025
@doronbehar
Copy link
Contributor

git grep -l -e 'versionCheckProgramArg = "--version";' -e 'versionCheckProgramArg = \[ "--version" \];' | while read f; do
  sed -i '/versionCheckProgramArg/d' "$f"
  sed -i '/^$/N;/\n$/D' "$f"
done

Why didn't you use the full pattern in the sed commands? Also it seems like the last sed command removes any empty line from these files.

@jpds
Copy link
Contributor Author

jpds commented Nov 20, 2025

@doronbehar The last sed removes double empty lines from the files as was the case when versionCheckProgramArg was floating by itself - you can look at ahoy for example in the diff.

The pattern I just took from your command.

@doronbehar
Copy link
Contributor

Ah OK I get it now , and yes indeed I used a simpler pattern match in the sed command :).

Copy link
Contributor

@doronbehar doronbehar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me, but TBH I'm not sconfident enough to merge such tree wide changes . I hope we can get a few more eyes on this.

@nixpkgs-ci nixpkgs-ci bot added 12.approvals: 2 This PR was reviewed and approved by two persons. 12.approved-by: package-maintainer This PR was reviewed and approved by a maintainer listed in any of the changed packages. and removed 12.approvals: 1 This PR was reviewed and approved by one person. labels Nov 20, 2025
@kachick kachick mentioned this pull request Nov 23, 2025
13 tasks
@jpds jpds requested a review from philiptaron November 24, 2025 17:55
Copy link
Contributor

@philiptaron philiptaron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I read the whole thing. LGTM.

@@ -61,7 +61,7 @@ versionCheckHook(){
exit 2
fi
if [[ -z "${versionCheckProgramArg}" ]]; then
for cmdArg in "--help" "--version"; do
for cmdArg in "--version" "--help"; do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is the key change.

@philiptaron philiptaron added this pull request to the merge queue Nov 26, 2025
Merged via the queue into NixOS:staging with commit feb4539 Nov 26, 2025
40 checks passed
@doronbehar
Copy link
Contributor

doronbehar commented Nov 26, 2025 via email

@jpds jpds mentioned this pull request Nov 26, 2025
13 tasks
@kachick kachick mentioned this pull request Nov 28, 2025
13 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.topic: docker tools Open-source software for deploying and running of containerized applications 6.topic: jupyter Interactive computing tooling: kernels, notebook, jupyterlab 6.topic: k3s Kubernates distribution (https://k3s.io/) 6.topic: lua Lua is a powerful, efficient, lightweight, embeddable scripting language. 6.topic: php PHP is a general-purpose scripting language geared towards web development. 6.topic: python Python is a high-level, general-purpose programming language. 6.topic: vim Advanced text editor 8.has: documentation This PR adds or changes documentation 10.rebuild-darwin: 501+ This PR causes many rebuilds on Darwin and should normally target the staging branches. 10.rebuild-darwin: 5001+ This PR causes many rebuilds on Darwin and must target the staging branches. 10.rebuild-linux: 501+ This PR causes many rebuilds on Linux and should normally target the staging branches. 10.rebuild-linux: 5001+ This PR causes many rebuilds on Linux and must target the staging branches. 12.approvals: 2 This PR was reviewed and approved by two persons. 12.approved-by: package-maintainer This PR was reviewed and approved by a maintainer listed in any of the changed packages.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants