-
-
Notifications
You must be signed in to change notification settings - Fork 13.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
docs: expand explanation of patchShebangs hook #121015
Conversation
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/what-is-the-patchshebangs-command-in-nix-build-expressions/12656/11 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, few minor comments.
@jtojnar Thanks for the precise observations, corrected. |
Anyone wants to merge this? |
LGTM, but please resolve the merge conflict. |
b05ba67
to
6e19469
Compare
udocker commits here? |
6e19469
to
25ec239
Compare
Random stuff from rebasing, I don't know... |
f128334
to
8ab498f
Compare
@SuperSandro2000 @jtojnar Can we finish the discussion on using source links and merge this? I hope having links in the first place is undisputed, as it helps people diving into the code, and the code is the definition of how things work. Calling @Ericson2314 because we looked at the PR together. Some considerations, leading me to conclude that permalinks are the better option: Pros:
Con: (same as for all prose documentation)
One could add an item to the release checklist, to go through permalinks and update them to the latest pre-release revision. That may in fact encourage people to actually look at the docs now and then and see if they still make sense. @tomberek what do you think? Using links to release branches or
Con:
|
@fricklerhandwerk I would prefer The maintenance burden is very real, however, and I don't want to sweap that under the rug. It's a lot of up-front the work, but I think the answer is doing a (very!) technical solution for this:
As part of the docs build:
We thus ensure the docs are in sync with no manual auditing effort, and as a bonus make the release process easier (no need to update the URLs, keep them updated with backports, etc.). Bonus, in addition to links we can have the same method for code snippets that render in the docs too! This is a lot of work, but I think it is extremely valuable, as it would allow us to document Nixpkgs with far, far more textual references in a way is sustainable with respect to human effort and avoiding the damage of false out of date documentation (arguably worse that no docs at all!) |
I would prefer master, because the manual should document the version of the code it itself came from!
Agreed.
In general, with monorepos, there is a tendency to hit issues where the mono repo in affect refers to / depends on prior versions of itself
Which kind of issues do you mean exactly? I find it hard to imagine if those references are immutable and persistent.
It's a lot of up-front the work
Yes, and it sounds conceptually awfully complicated for throwing in a few links to the code.
One much simpler automation I could agree on would be to compare the contents[1] at the tip of the branch in question to contents behind the permalink, update the link if there was no change, and throw a build error otherwise to force maintainers to check for semantic consistency. I don’t know whether already or how we tell the build which branch we are currently on, though.
In any case this is optional and independent of this change right now. Nonetheless I find it too expensive to be worthwhile, as my impression is that people rather iterate over small parts incrementally, such that we can expect some manual care to be exercised. We can reconsider if someone who actually does the work (or convincingly claims to be prevented to do that work as things are) would significantly benefit from automation.
[1]: Exact contents for line references (usually preferable anyway), existing file for file references. The latter as in „the implementation can be found in `foo.nix`“.
avoiding the damage of false out of date documentation (arguably worse that no docs at all!)
What is the argument here? Some parts of the docs seem to be stale or confusing, and I’m not convinced this is worse than not having them. Disagree on the term damage, since the PR in question appears to me a niche topic. Also see my argument that permalinks stay consistent with prose by default. Semantic code changes would already require prose change. Someone implementing that prose change may as well check how recent the links are and whether they point to something appropriate. Review is also involved in this kind of sanity check.
|
I prefer permalinks precisely for the reasons you outlined. As someone who writes docs, the consideration what to do when a link is outdated is most important to me:
Yes, a new linking scheme such as the one John would resolve this more elegantly. But it is significantly more work than just using the permalink, even though it is essentially the same solution. The main difference is that the new scheme would store the snippet as a part of a link, whereas the permalink scheme stores the snippet in the link target. Yes, the former would allow for more flexibility (e.g. using regexes) but again, I am not sure it is worth the effort. And yes, all of those are at least partially automatable but until we have such automatization, the permalinks make most sense to me, as mentioned above. |
Yeah. Links to files from specific commits are fine to start. Maybe we can accumulate a few of those and then the case for the automation will build up over time. |
8ab498f
to
c1a8004
Compare
@jtojnar @Ericson2314 updated to permalinks. Ready to merge? |
ffebf47
to
b90429d
Compare
Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
This setup hook patches installed scripts to add Nix store paths to their shebang interpreter as found in the build environment. The [shebang](https://en.wikipedia.org/wiki/Shebang_(Unix)) line tells a Unix-like operating system which interpreter to use to execute the script's contents. | ||
|
||
::: note | ||
The [generic builder][generic-builder] populates `PATH` from inputs of the derivation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe link to the place that actually does that instead, since people might click the link and be confused.
} | ||
``` | ||
|
||
The file [`patch-shebangs.sh`][patch-shebangs.sh] defines the [`patchShebangs`][patchShebangs] function. It is used to implement [`patchShebangsAuto`][patchShebangsAuto], the [setup hook](#ssec-setup-hooks) that is registered to run during the [fixup phase](#ssec-fixup-phase) by default. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe move this to the beginning to serve as an overview.
@jtojnar Thanks for the hints, incorporated some. Though in general I would like reviewers to tell what must be changed to meet agreed-upon quality standards, not what could be changed because it's nice to have. This PR is already over a year old. We can always slightly improve later if it appears important enough. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's merge this soon.
Co-authored-by: Jan Tojnar <jtojnar@gmail.com>
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/tweag-nix-dev-update-34/20901/1 |
based on https://discourse.nixos.org/t/what-is-the-patchshebangs-command-in-nix-build-expressions/12656
I haven't yet decided if adding source links to the manual is a good idea and haven't found any discussion on the topic.
Would be cool if we had a preprocessor that converts references to
/path/to/file:L123-L456
in the current repository into GitHub links, but keeping it consistent with changing code would be a can of worms on its own.Opinions?
Closes #129741
Motivation for this change
Things done
sandbox
innix.conf
on non-NixOS linux)nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
./result/bin/
)nix path-info -S
before and after)