-
-
Notifications
You must be signed in to change notification settings - Fork 14.9k
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
stdenv: add no-broken-symlinks hook #370750
stdenv: add no-broken-symlinks hook #370750
Conversation
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.
Conceptually LGTM, bash looks roughly OK and I don't trust myself to comment any further than that. Has anyone tried running the data on the number of broken symlinks in the current Hydra outputs?
As with @K900, this looks good to me in theory and I support the idea that a dangling or reflexive symlink is more often than not a bug. I'd love a test. Could you write a few using
|
865fa50
to
7aedd5a
Compare
The PR's base branch is set to staging, but 4 commits from the master branch are included. Make sure you know the right base branch for your changes, then:
|
7aedd5a
to
229fdf0
Compare
Added docs and tests, force-pushed and rebased! @K900 and @philiptaron would you mind taking another look? |
Hi. Now there's lots of Example: Why is path I'd suggest to
|
Generally the right thing to do if upstream ships broken symlinks is to just disable the check. |
But then, what value does the hook bring? But yes, I guess that'd be preferable over nuking the paths, because then we have a semantic connection between the two (hook and workaround/fix). |
The value of the hook is to catch bad symlinks that are created by our packaging. |
I guess that's fair, although I think over time more people would just disable the hook |
But if the response to it finding a bad symlink is to disable the check (if we agree that's preferable to blindly deleting files in $out without a build time check/connection to the underlying setup hook), then the hook doesn't provide much value. Anyway, PRs that break a lot of packages should be reverted, right? |
Btw, I like the idea behind the hook, and would like to see it re-applied, but without the breakage and "mass PRs that work around the hook in non-obvious ways". |
It does still provide value. You can then easily grep for Most importantly, it prevents introducing new broken symlinks.
You can't easily revert this PR, because it would need to go through staging. So it wouldn't really help short-term to fix those packages, right? |
Good. But some PRs I found just
👍
Oh, I guess not. |
So I guess the general guideline should be here:
|
The hook could also export a bash function to remove given paths, iff they are problematic symlinks. That way we'd get build time check for when the invariant is broken, unlike |
it could even be a bash one liner using find to search for the broken symlinks and then removing them or just printing them out to have the maintainers removing them if needed |
Adds a setup hook which checks for broken symlinks; a symlink is considered broken if it's dangling (target doesn't exist) or reflexive (it refers to itself).
In my experience, outputs with broken symlinks are generally errors, and so we should provide a hook which can catch and report them.
The hook can be disabled by setting
dontCheckForBrokenSymlinks
.Future work
Fixup PRs:
bluez: set dontCheckForBrokenSymlinks #376210(superseded by no-broken-symlinks: restrict checks to symlinks pointing inside the store #376261)systemd: set dontCheckForBrokenSymlinks #376218(superseded by no-broken-symlinks: restrict checks to symlinks pointing inside the store #376261)Things done
nix.conf
? (See Nix manual)sandbox = relaxed
sandbox = true
nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"
. Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/
)Add a 👍 reaction to pull requests you find important.