Skip to content
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

nar: fix executable permissions logic #282

Merged
merged 3 commits into from
Jul 30, 2024

Conversation

sandydoo
Copy link
Contributor

@sandydoo sandydoo commented Jul 23, 2024

This PR replaces Directories.getPermissions, which uses access to test whether the file is executable, with a mix of functions from the unix package to replicate the logic that Nix uses.

Nix doesn't use access to check whether a file is executable. It instead checks whether the owner executable bit is set.

When unpacking a NAR, Nix sets the executable bits for the owner, group, and other.

Fixes cachix/cachix#664.

Example in the wild

In the linked issue, the build of IINA contains multiple files with the extension .strings and permissions .r-xr-xr-x. Take for example, result/Applications/IINA.app/Contents/Resources/de.lproj/AboutWindowController.strings.
access returns false for X_OK when run on this file.
hnix fails to mark these files as executable when generating the NAR.

@sandydoo
Copy link
Contributor Author

Oof, I'm having trouble creating a test for this. It's not entirely clear to me what makes these files so special. Maybe there's more to investigate 🤔

@sandydoo
Copy link
Contributor Author

@Enzime figured out how to reproduce this cachix/cachix#664 (comment). We now have a working test case.

@sorki, how should we go about fixing CI?
The macos-latest (arm) runners now ship with a version of LLVM that's too new for GHC < 9.2. We can either switch to macos-13 (x86), or add a step to brew install LLVM 12, or use Nix, or remove a few versions of GHC 🙃

@sorki
Copy link
Member

sorki commented Jul 28, 2024

@sorki, how should we go about fixing CI? The macos-latest (arm) runners now ship with a version of LLVM that's too new for GHC < 9.2. We can either switch to macos-13 (x86), or add a step to brew install LLVM 12, or use Nix, or remove a few versions of GHC 🙃

Thanks for the pointers! Fixed in #283. I've kept only GHC 9.6 and added GHC 9.8. GHC 8.10.7 was there because of GHCJS which is now part of the mainline GHC anyway.

Nix doesn't use `access` to check whether a file is executable.
It instead checks whether the owner executable bit is set.

When unpacking a NAR, Nix sets the executable bits for the owner, group, and other.
@sandydoo sandydoo marked this pull request as ready for review July 29, 2024 17:27
@sorki sorki merged commit c105037 into haskell-nix:master Jul 30, 2024
4 checks passed
@sorki
Copy link
Member

sorki commented Jul 30, 2024

Thanks! I'll cut a release.

@sorki
Copy link
Member

sorki commented Jul 31, 2024

@sandydoo everything out!!

Reminder #233 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

NAR hash mismatch
2 participants