[Nix#9579] Permission denied error when building symlink derivation #195

Closed
opened 2024-03-28 19:33:46 +00:00 by lix-bot · 5 comments
Member

Upstream-Issue: NixOS/nix#9579

Describe the bug

My apologies if this is already fixed on master branch, but I couldn't identify any particular issue or PR which describes this issue.

Nix 1.19.2 fails to build a derivation containing a symlink to store path.

# test-symlink.nix
{ local ? "/home/rodney/ops/nixpkgs"
, pkgs ? import local {}
}: rec {
  direct-symlink = pkgs.runCommand "direct-symlink" {} ''
    ln -vs ${local}/.version $out
  '';
  indirect-symlink = pkgs.runCommand "indirect-symlink" {} ''
    ln -vs ${direct-symlink} $out
  '';
}

Steps To Reproduce

The error message is:

rodney@tethys:~/ops/nixpkgs % nix build --experimental-features "nix-command" -f test-symlink.nix && readlink -f result*
warning: Nix search path entry '/nix/var/nix/profiles/per-user/root/channels' does not exist, ignoring
warning: Ignoring setting 'auto-allocate-uids' because experimental feature 'auto-allocate-uids' is not enabled
warning: Ignoring setting 'impure-env' because experimental feature 'configurable-impure-env' is not enabled
error:
       … while setting up the build environment

       error: getting attributes of path '/nix/store/ws9yl6ph10v79gx4p9ilhyxg214xf7i7-direct-symlink': Permission denied

Expected behavior

I expected both derivations to build and for the resulting store paths to be resolvable symlinks.

This is what happens with nix-2.18.1:

rodney@tethys:~/ops/nixpkgs % nix build --experimental-features "nix-command" -f test-symlink.nix && readlink -f result*
warning: Nix search path entry '/nix/var/nix/profiles/per-user/root/channels' does not exist, ignoring
/home/rodney/ops/nixpkgs/.version
/home/rodney/ops/nixpkgs/.version

nix-env --version output

This is the nixUnstable package, corresponding to revision 2c7f3c0fb7c08a0814627611d9d7d45ab6d75335 of nixpkgs.

nix (Nix) 2.19.2

Additional context

Introduced by

You might ask, why build such a silly derivation? Well, it's how mkOutOfStoreSymlink works under home-manager.

See: https://github.com/nix-community/home-manager/issues/4692

Priorities

Add 👍 to issues you find important.

Upstream-Issue: https://git.lix.systems/NixOS/nix/issues/9579 **Describe the bug** My apologies if this is already fixed on master branch, but I couldn't identify any particular issue or PR which describes this issue. Nix 1.19.2 fails to build a derivation containing a symlink to store path. ```nix # test-symlink.nix { local ? "/home/rodney/ops/nixpkgs" , pkgs ? import local {} }: rec { direct-symlink = pkgs.runCommand "direct-symlink" {} '' ln -vs ${local}/.version $out ''; indirect-symlink = pkgs.runCommand "indirect-symlink" {} '' ln -vs ${direct-symlink} $out ''; } ``` **Steps To Reproduce** The error message is: ``` rodney@tethys:~/ops/nixpkgs % nix build --experimental-features "nix-command" -f test-symlink.nix && readlink -f result* warning: Nix search path entry '/nix/var/nix/profiles/per-user/root/channels' does not exist, ignoring warning: Ignoring setting 'auto-allocate-uids' because experimental feature 'auto-allocate-uids' is not enabled warning: Ignoring setting 'impure-env' because experimental feature 'configurable-impure-env' is not enabled error: … while setting up the build environment error: getting attributes of path '/nix/store/ws9yl6ph10v79gx4p9ilhyxg214xf7i7-direct-symlink': Permission denied ``` **Expected behavior** I expected both derivations to build and for the resulting store paths to be resolvable symlinks. This is what happens with nix-2.18.1: ``` rodney@tethys:~/ops/nixpkgs % nix build --experimental-features "nix-command" -f test-symlink.nix && readlink -f result* warning: Nix search path entry '/nix/var/nix/profiles/per-user/root/channels' does not exist, ignoring /home/rodney/ops/nixpkgs/.version /home/rodney/ops/nixpkgs/.version ``` **`nix-env --version` output** This is the `nixUnstable` package, corresponding to revision 2c7f3c0fb7c08a0814627611d9d7d45ab6d75335 of nixpkgs. ``` nix (Nix) 2.19.2 ``` **Additional context** Introduced by - https://github.com/nixos/nix/pull/8965 You might ask, why build such a silly derivation? Well, it's how `mkOutOfStoreSymlink` works under home-manager. See: https://github.com/nix-community/home-manager/issues/4692 **Priorities** Add :+1: to [issues you find important](https://github.com/NixOS/nix/issues?q=is%3Aissue+is%3Aopen+sort%3Areactions-%2B1-desc).
lix-bot added the
bug
imported
labels 2024-03-28 19:33:46 +00:00
Owner

@xenua reported this reproduces on lix

@xenua reported this reproduces on lix
Member

meow

meow
Owner

this smells like lazy trees, even though it's in sandbox setup. the symlink changes made in libutil to get lazy trees to work have been pervasive

this smells like lazy trees, even though it's in sandbox setup. the symlink changes made in libutil to get lazy trees to work have been pervasive
Owner

purported fix PR although it does not look like the PR was going super well... https://github.com/NixOS/nix/pull/9723

purported fix PR although it does not look like the PR was going super well... https://github.com/NixOS/nix/pull/9723
Owner
fixed by https://gerrit.lix.systems/c/lix/+/829
jade closed this issue 2024-04-18 20:39:02 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
4 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

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