darwin case hack is busted #332

Open
opened 2024-05-19 18:15:07 +00:00 by pennae · 5 comments
Owner

the way nix extracts nars on darwin (since 276a40b31f) may append ~nix~case~hack~.* strings to paths during extraction, silently fucking up the extracted store path. even worse, during dumping of store paths such suffixes are removed even when they weren't added for disambiguation, which lets us produce invalid nars:

(import <nixpkgs> { system = "aarch64-darwin"; }).runCommand "foo" {} ''
  mkdir $out $out/~nix~case~hack~this-should-be-a-number
  touch $out $out/~nix~case~hack~this-should-be-a-number/1
''

gives

❯ nix-build foo.nix                                   
this derivation will be built:
  /nix/store/xx9f6533jr88v6i2pq9v8cqxaa9kzqy4-foo.drv
building '/nix/store/xx9f6533jr88v6i2pq9v8cqxaa9kzqy4-foo.drv' on 'ssh-ng://m1@build01.aarch64-darwin.lix.systems'...
copying 0 paths...
building '/nix/store/xx9f6533jr88v6i2pq9v8cqxaa9kzqy4-foo.drv'...
copying 1 paths...
copying path '/nix/store/qs1z1sz8lbkazj5xi7x6bkhkisdd58rd-foo' from 'ssh-ng://m1@build01.aarch64-darwin.lix.systems'...
error: NAR contains invalid file name ''
error: builder for '/nix/store/xx9f6533jr88v6i2pq9v8cqxaa9kzqy4-foo.drv' failed with exit code 1

we should remove the case hack nonsense, print a loud diagnostic when extracting nars that would require it asking the user to make their nix store cases-sensitive, and maybe even apply case-sensitive settings from the installer.

the way nix extracts nars on darwin (since 276a40b31f631c188d6dcbdf603a738e1380ff74) may append `~nix~case~hack~.*` strings to paths during extraction, silently fucking up the extracted store path. even worse, during *dumping* of store paths such suffixes are removed *even when they weren't added for disambiguation*, which lets us produce invalid nars: ``` (import <nixpkgs> { system = "aarch64-darwin"; }).runCommand "foo" {} '' mkdir $out $out/~nix~case~hack~this-should-be-a-number touch $out $out/~nix~case~hack~this-should-be-a-number/1 '' ``` gives ``` ❯ nix-build foo.nix this derivation will be built: /nix/store/xx9f6533jr88v6i2pq9v8cqxaa9kzqy4-foo.drv building '/nix/store/xx9f6533jr88v6i2pq9v8cqxaa9kzqy4-foo.drv' on 'ssh-ng://m1@build01.aarch64-darwin.lix.systems'... copying 0 paths... building '/nix/store/xx9f6533jr88v6i2pq9v8cqxaa9kzqy4-foo.drv'... copying 1 paths... copying path '/nix/store/qs1z1sz8lbkazj5xi7x6bkhkisdd58rd-foo' from 'ssh-ng://m1@build01.aarch64-darwin.lix.systems'... error: NAR contains invalid file name '' error: builder for '/nix/store/xx9f6533jr88v6i2pq9v8cqxaa9kzqy4-foo.drv' failed with exit code 1 ``` we should remove the case hack nonsense, print a loud diagnostic when extracting nars that would require it asking the user to make their nix store cases-sensitive, and maybe even apply case-sensitive settings from the installer.
pennae added the
bug
label 2024-05-19 18:15:07 +00:00
Owner

Arguably the original reason this was added was because /nix used to be on the root partition which is of course hard to make case sensitive. But we could make the store case sensitive in the installer now that it's a separate APFS container, and then just refuse to do these. We just have to figure out if you can retroactively make a container case sensitive.

Arguably the original reason this was added was because /nix used to be on the root partition which is of course hard to make case sensitive. But we could make the store case sensitive in the installer now that it's a separate APFS container, and then just refuse to do these. We just have to figure out if you can retroactively make a container case sensitive.
Owner

Thinking harder about this: we cannot fix existing containers either online or offline. Though it's true that case sensitivity is an attribute in the superblock, there's hash maps in the fs that would be probably invalidated by tampering it.

I think the solution here is to make a nix doctor apfs --fix that copies to a new container.

Thinking harder about this: we cannot fix existing containers either online or offline. Though it's true that case sensitivity is an attribute in the superblock, there's hash maps in the fs that would be probably invalidated by tampering it. I think the solution here is to make a `nix doctor apfs --fix` that copies to a new container.
Member

This issue was mentioned on Gerrit on the following CLs:

  • commit message in cl/1503 ("macOS: default to case sensitive")
<!-- GERRIT_LINKBOT: {"cls": [{"backlink": "https://gerrit.lix.systems/c/lix-installer/+/1503", "number": 1503, "kind": "commit message"}], "cl_meta": {"1503": {"change_title": "macOS: default to case sensitive"}}} --> This issue was mentioned on Gerrit on the following CLs: * commit message in [cl/1503](https://gerrit.lix.systems/c/lix-installer/+/1503) ("macOS: default to case sensitive")
jade added the
OS/macOS
label 2024-06-23 03:09:58 +00:00
Owner

One bug found while bootstrapping: https://github.com/mesonbuild/meson/pull/13349

One bug found while bootstrapping: https://github.com/mesonbuild/meson/pull/13349
jade added a new dependency 2024-06-30 19:14:56 +00:00
Owner
equiv nix bug: https://github.com/NixOS/nix/issues/10746
Sign in to join this conversation.
No milestone
No project
No assignees
3 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference: lix-project/lix#332
No description provided.