Skip to content

qemu-vm: fix case-hack appearing in store image#347636

Merged
nikstur merged 1 commit intoNixOS:masterfrom
Enzime:fix/case-hack
Oct 12, 2024
Merged

qemu-vm: fix case-hack appearing in store image#347636
nikstur merged 1 commit intoNixOS:masterfrom
Enzime:fix/case-hack

Conversation

@Enzime
Copy link
Member

@Enzime Enzime commented Oct 10, 2024

When using darwin.linux-builder after #241373, the Nix case hack suffix doesn't get removed and is present in the linux-builder's store:

$ tree -L 1 /nix/store/sy6029qwc2a379081zriyq8hly31nrvh-ncurses-6.4.20221231/share/terminfo
/nix/store/sy6029qwc2a379081zriyq8hly31nrvh-ncurses-6.4.20221231/share/terminfo
├── 1
├── 2
├── 3
├── 4
├── 5
├── 6
├── 7
├── 8
├── 9
├── A
├── E
├── L
├── M
├── N
├── P
├── Q
├── X
├── a~nix~case~hack~1
├── b
├── c
├── d
├── e~nix~case~hack~1
├── f
├── g
├── h
├── i
├── j
├── k
├── l~nix~case~hack~1
├── m~nix~case~hack~1
├── n~nix~case~hack~1
├── o
├── p~nix~case~hack~1
├── q~nix~case~hack~1
├── r
├── s
├── t
├── u
├── v
├── w
├── x~nix~case~hack~1
└── z

This leads to issues when building a derivation like:

pkgs.buildEnv {
  name = "system-path";
  paths = [ pkgs.alacritty.terminfo pkgs.ncurses ];
  ignoreCollisions = true;
  pathsToLink = [ "/share/terminfo" ];
};

pkgs.alacritty.terminfo:

$ tree /nix/store/r0ljq2kgfvchnaa7a9ifjjjjj1dd45fc-alacritty-0.13.2-terminfo/share/terminfo
/nix/store/r0ljq2kgfvchnaa7a9ifjjjjj1dd45fc-alacritty-0.13.2-terminfo/share/terminfo
└── a
    ├── alacritty
    └── alacritty-direct

The derivation will successfully build on aarch64-linux but the two a directories won't get correctly merged and the store path will look like:

$ tree -L 1 /nix/store/ba93lbk52rvzgx6k8al8yg5kh4sk7g3l-system-path/share/terminfo
/nix/store/ba93lbk52rvzgx6k8al8yg5kh4sk7g3l-system-path/share/terminfo
├── A
├── a
└── a~nix~case~hack~1

Which will fail to get copied to aarch64-darwin:

building '/nix/store/3lmhyv6abflzr1x4zp60qr0pifkw7xcc-system-path.drv'...
system-path> warning: collision between `/nix/store/zwwfyrswrgv6akmsqhr3n1f917g7drwr-xwayland-24.1.2/share/man/man1/Xserver.1.gz' and `/nix/store/lilzagdmycrraggzfwyg0plavs4kdhrl-xorg-server-21.1.13/share/man/man1/Xserver.1.gz'
system-path> warning: collision between `/nix/store/zwwfyrswrgv6akmsqhr3n1f917g7drwr-xwayland-24.1.2/lib/xorg/protocol.txt' and `/nix/store/lilzagdmycrraggzfwyg0plavs4kdhrl-xorg-server-21.1.13/lib/xorg/protocol.txt'
system-path> created 8030 symlinks in user environment
system-path> gtk-update-icon-cache: Cache file created successfully.
copying 1 paths...
copying path '/nix/store/ba93lbk52rvzgx6k8al8yg5kh4sk7g3l-system-path' from 'ssh-ng://'...
error: filesystem error: in create_symlink: File exists ["/nix/store/sy6029qwc2a379081zriyq8hly31nrvh-ncurses-6.4.20221231/share/terminfo/a~nix~case~hack~1"] ["/nix/store/ba93lbk52rvzgx6k8al8yg5kh4sk7g3l-system-path/share/terminfo/a~nix~case~hack~1"]
error: builder for '/nix/store/3lmhyv6abflzr1x4zp60qr0pifkw7xcc-system-path.drv' failed with exit code 1

cc @roberth @emilazy @nikstur

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/)
  • 24.11 Release Notes (or backporting 23.11 and 24.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.

@github-actions github-actions bot added 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: module (update) This PR changes an existing module in `nixos/` labels Oct 10, 2024
@nix-owners nix-owners bot requested a review from RaitoBezarius October 10, 2024 01:56
@ofborg ofborg bot added 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. labels Oct 10, 2024
Copy link
Member

@roberth roberth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Technically incorrect if the store doesn't have the case hack (but won't be a problem, because who has real files with that in the name...)
  • Would be nice to have a test, but it'd be unwieldy
  • macOS doesn't technically need the case hack because the installer could have created a case sensitive volume. I believe Lix is experimenting with that, but this will take a while before the ecosystem adopts it (if we're even happy about it; probably?)

... so let's just fix it like this.
Thank you for figuring out a good solution!

@Enzime Enzime added the 12.approvals: 1 This PR was reviewed and approved by one person. label Oct 10, 2024
@nikstur
Copy link
Contributor

nikstur commented Oct 10, 2024

@ofborg test qemu-vm-store

@emilazy
Copy link
Member

emilazy commented Oct 10, 2024

  • macOS doesn't technically need the case hack because the installer could have created a case sensitive volume. I believe Lix is experimenting with that, but this will take a while before the ecosystem adopts it (if we're even happy about it; probably?)

While I loathe the case hack, run with a case‐sensitive store volume, and strongly think we should standardized on a case‐sensitive store volume across the ecosystem, it’s unfortunately not quite that simple. There are lots of code paths in Nix that put stuff into $TMPDIR in a load‐bearing way, so we need a /nix/tmp. Getting Nix to use it is hard: build-dir is insufficient, and $TMPDIR on the daemon isn’t even sufficient because some of that fetching/unpacking stuff runs in nix(1). There needs to be work on the Nix side to make this viable; we need a temp-dir setting that everything respects, to default build-dir to it, and to default temp-dir to /nix/tmp on macOS (and probably /var/tmp or /var/tmp/nix on Linux; see #338181 (comment)). See NixOS/nix#8995 and NixOS/nix#10746 (comment) for more discussion.

I currently run nix-daemon with $TMPDIR set and wrap the Nix package with a wrapper that sets $TMPDIR for all Nix commands, per @lilyball, but even that behaves incorrectly with e.g. nix shell. Sorry to hijack this perfectly good PR with this info dump, but I keep meaning to write all this up and @roberth prompted me to get it done :)

@Enzime
Copy link
Member Author

Enzime commented Oct 12, 2024

@nikstur looks like the qemu-vm-store test is succeeding on x86_64-linux and aarch64-linux continues to fail for unrelated reasons

Seems like it's always failed on aarch64-linux: https://hydra.nixos.org/job/nixos/trunk-combined/nixos.tests.qemu-vm-store.aarch64-linux/all

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: module (update) This PR changes an existing module in `nixos/` 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. 12.approvals: 1 This PR was reviewed and approved by one person.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants