`$out/share` linked with `nix profile install` but not otherwise?

Context:

I found some behavior that surprised me. If I install qemu via nix profile install, its $out/share gets symlinked to my profile:

$ nix profile install nixpkgs#qemu
$ fd -uL edk2-aarch64-code.fd ~/.nix-profile
/Users/n8henrie/.nix-profile/share/qemu/edk2-aarch64-code.fd

However, if I install declaratively via nix-darwin (or home-manager), I don’t see share/qemu in /run/current-system/sw/share or /run/current-system/... anywhere.

$ nix profile remove "$(nix profile list | awk '/qemu/ { print $1 }')"
removing 'flake:nixpkgs#legacyPackages.aarch64-darwin.qemu'
$ type -a qemu-system-aarch64
qemu-system-aarch64 is /run/current-system/sw/bin/qemu-system-aarch64
$ ls /run/current-system/sw/share/qemu
ls: cannot access '/run/current-system/sw/share/qemu': No such file or directory
$ ls /run/current-system/etc/profiles/per-user/n8henrie/share/qemu
ls: cannot access '/run/current-system/etc/profiles/per-user/n8henrie/share/qemu': No such file or directory
$ sudo find -L /run -path '*/share/qemu/*'
$

Is this expected behavior – for $out/share to be linked with a profile install but not otherwise? (Looks like it may be.) I see the same behavior on x86_64-linux NixOS, so I don’t think it’s a nix-darwin or arm64 issue.

1 Like

Adding this to my nix-darwin config seems to be a reasonable workaround:

environment.pathsToLink = ["/share/qemu"];
3 Likes