Skip to content

stdenv: add no-broken-symlinks hook#370750

Merged
philiptaron merged 8 commits intoNixOS:stagingfrom
ConnorBaker:feat/stdenv-no-broken-symlinks-hook
Jan 23, 2025
Merged

stdenv: add no-broken-symlinks hook#370750
philiptaron merged 8 commits intoNixOS:stagingfrom
ConnorBaker:feat/stdenv-no-broken-symlinks-hook

Conversation

@ConnorBaker
Copy link
Contributor

@ConnorBaker ConnorBaker commented Jan 3, 2025

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:

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 25.05 Release Notes (or backporting 24.11 and 25.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

@ConnorBaker ConnorBaker self-assigned this Jan 3, 2025
@github-actions github-actions bot added the 6.topic: stdenv Standard environment label Jan 3, 2025
@ConnorBaker ConnorBaker requested a review from K900 January 3, 2025 23:37
@github-actions github-actions bot added 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 Jan 3, 2025
Copy link
Contributor

@K900 K900 left a 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?

@wegank wegank added the 12.approvals: 1 This PR was reviewed and approved by one person. label Jan 6, 2025
@wegank wegank removed the 12.approvals: 1 This PR was reviewed and approved by one person. label Jan 19, 2025
@philiptaron
Copy link
Contributor

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 testBuildFailure, showing:

  1. Reflexive symlink fails
  2. Dangling symlink fails
  3. They don't fail if dontCheckForBrokenSymlinks is specified.

@ConnorBaker ConnorBaker force-pushed the feat/stdenv-no-broken-symlinks-hook branch from 865fa50 to 7aedd5a Compare January 22, 2025 01:33
@github-actions github-actions bot added the 8.has: documentation This PR adds or changes documentation label Jan 22, 2025
@nix-owners
Copy link

nix-owners bot commented Jan 22, 2025

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:

  • If the changes should go to the master branch, change the base branch to master
  • If the changes should go to the staging branch, rebase your PR onto the merge base with the staging branch:
    # git rebase --onto $(git merge-base upstream/staging HEAD) $(git merge-base upstream/master HEAD)
    git rebase --onto eac5f2caf93e16315194c6227cab4937af4b74e3 db0f0fb937b73c4585444925e17446726836a405
    git push --force-with-lease

@ConnorBaker ConnorBaker force-pushed the feat/stdenv-no-broken-symlinks-hook branch from 7aedd5a to 229fdf0 Compare January 22, 2025 01:35
@ConnorBaker
Copy link
Contributor Author

Added docs and tests, force-pushed and rebased!

@K900 and @philiptaron would you mind taking another look?

@ConnorBaker ConnorBaker requested a review from K900 January 22, 2025 01:37
@nix-owners nix-owners bot removed the request for review from K900 January 22, 2025 01:37
bjornfor added a commit to bjornfor/nixpkgs that referenced this pull request Feb 11, 2025
bjornfor added a commit that referenced this pull request Feb 11, 2025
@jhargraveiii
Copy link

I couldn't find an issue logged for cudaPackaes.tensorrt - I can try to create one if needed.

@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/still-cant-print-after-6-months-canon-mf445dw-at-the-end-of-my-rope/24665/26

@athas
Copy link
Contributor

athas commented Mar 1, 2025

mlkit was also broken by this change: #385089

I think it is not great that a cosmetic improvement breaks previously working derivations, without any automation for dealing with it.

drupol pushed a commit that referenced this pull request Mar 19, 2025
There was a dangling symlink left, which was caused by
19396e3 renaming the .jar file. This
was turned into an error by #370750, causing the build to fail.
@DavHau
Copy link
Member

DavHau commented Mar 20, 2025

Where is the documentation for this feature? I don't think something like this should be merged without docs.

@RossComputerGuy
Copy link
Member

Where is the documentation for this feature?

Right here: https://github.com/NixOS/nixpkgs/pull/370750/files#diff-f5fe95f260cb2cfb8edfaf1588832dc7686f8132220a6e664c2feae66c99ad26R1374-R1383

https://nixos.org/manual/nixpkgs/unstable/#no-broken-symlinks.sh

I don't think something like this should be merged without docs.

That is true but was already done.

@DavHau
Copy link
Member

DavHau commented Mar 20, 2025

Oops, I should have checked the PR's changes.

Unfortunately the manual failed me here. If I encounter an error like ERROR: noBrokenSymlinks: my instinct is to search the manual for noBrokenSymlinks. But the manual doesn't contain this string.
Optimally the error message would be changed or the manual adapted.

matthiasdotsh added a commit to matthiasdotsh/nixpkgs that referenced this pull request May 23, 2025
Resolve build issues with Kaldi due to OpenFST dependency on GCC14

When compiling OpenFST (a Kaldi dependency) with GCC13,
numerous warnings occur, such as:
`warning: expected 'template' keyword before dependent template name`.

However, with GCC14, these warnings escalate to errors, causing the
build to fail. Consequently, the Kaldi package is no longer building
with versions >25.05, as the standard environment (stdenv) now relies on
GCC14.

Building with gcc13Stdenv however still fails with:
```
> ERROR: noBrokenSymlinks: found 40 dangling symlinks, 0 reflexive symlinks and 0 unreadable symlinks
```

Looks like this is related to NixOS#370750

Setting `dontCheckForBrokenSymlinks = true;` can prevent it from
happening.
@matthiasdotsh matthiasdotsh mentioned this pull request May 23, 2025
13 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.topic: stdenv Standard environment 8.has: documentation This PR adds or changes documentation 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.