haskell-nix / hnix-store

Haskell implementation of the Nix store
Apache License 2.0
87 stars 23 forks source link

nar: fix executable permissions logic #282

Closed sandydoo closed 2 months ago

sandydoo commented 2 months ago

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 https://github.com/cachix/cachix/issues/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 commented 2 months ago

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 commented 2 months ago

@Enzime figured out how to reproduce this https://github.com/cachix/cachix/issues/664#issuecomment-2246883325. 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 commented 2 months ago

@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.

sorki commented 2 months ago

Thanks! I'll cut a release.

sorki commented 2 months ago

@sandydoo everything out!!

Reminder https://github.com/haskell-nix/hnix-store/issues/233#issuecomment-1822673746