Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: permission denied when trying to mkOutOfStoreSymlink #4692

Open
2 tasks done
austinliuigi opened this issue Nov 23, 2023 · 24 comments
Open
2 tasks done

bug: permission denied when trying to mkOutOfStoreSymlink #4692

austinliuigi opened this issue Nov 23, 2023 · 24 comments
Assignees
Labels
bug triage Issues or feature request that have not been triaged yet

Comments

@austinliuigi
Copy link

Are you following the right branch?

  • My Nixpkgs and Home Manager versions are in sync

Is there an existing issue for this?

  • I have searched the existing issues

Issue description

When trying to build my home-manager configuration, I get:

error:
       … while setting up the build environment

       error: getting attributes of path '/nix/store/d5w0zqag0v8wkyab59aph7v9ypkr3h6y-hm_nvim': Permission denied

The corresponding piece of the config that is causing it is:

    home.packages = [
      pkgs.neovim
    ];

    # create a symlink of the config to the proper location
    xdg.configFile = {
      nvim.source = config.lib.file.mkOutOfStoreSymlink "${config.dotfiles}/neovim/.config/nvim";
    };

By the time it errors, /nix/store/d5w0zqag0v8wkyab59aph7v9ypkr3h6y-hm_nvim links to the correct directory. It is afterwards at which it errors.

I am doing this on a multi-user installation of nix (version 2.19.1) on an Ubuntu 22.04 VM. When I build the configuration on a machine running NixOS with nix (version 2.17.0), it works fine.

Maintainer CC

@rycee

System information

- system: `"x86_64-linux"`
 - host os: `Linux 6.2.0-34-generic, Ubuntu, 22.04.3 LTS (Jammy Jellyfish), nobuild`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.19.1`
 - channels(root): `"nixpkgs"`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixpkgs`
@austinliuigi austinliuigi added bug triage Issues or feature request that have not been triaged yet labels Nov 23, 2023
@cole-h
Copy link
Member

cole-h commented Nov 26, 2023

This might be caused by NixOS/nix#8965, which was first released in Nix 2.19.0.

@myguidingstar
Copy link

I also ran into this issue after upgrading nixpkgs + hm. It's even stranger that I still can't build with nix 2.17

nix run nixpkgs#nixVersions.nix_2_17 build <myflake>#nixosConfigurations.<mysystem>.config.s
ystem.build.toplevel

as it still throws getting attributes of path '/nix/store/<some-file>': Permission denied

@spector700
Copy link

I am also getting this with:

  home.file.".config/nvim".source = config.lib.file.mkOutOfStoreSymlink "${config.home.homeDirectory}/.config/nixos-config/modules/editors/neovim/nvim";

Is there a workaround?

@prescientmoon
Copy link

I am also getting the same issue

@myguidingstar
Copy link

@spector700 not sure if it's the best way, but my work around was:

  1. temporarily comment out all code that use mkOutOfStoreSymlink
  2. in system config, set nix.package = pkgs.nixVersions.nix_2_17;
  3. boot to new system, now nix is 2.17
  4. undo step 1 and rebuild your system

@rvl
Copy link
Contributor

rvl commented Dec 10, 2023

@spector700 My workaround was to remove the nix.package = pkgs.nixUnstable; setting from NixOS (i.e. revert to nix v2.18.1).

@myguidingstar Changing the version of the nix build command won't work because the nix-daemon service is actually running the build. You can rollback your NixOS system to some previous generation. Or you can temporarily override the version with systemctl edit --runtime nix-daemon.service && systemctl restart nix-daemon.service (review the systemd docs for instructions).

@spector700
Copy link

@rvl Thank you that worked

@Jak-Ch-ll
Copy link

For anyone not using NixOS, you can install an older version of Nix by using the direct link to the install scripts: sh <(curl -L https://releases.nixos.org/nix/nix-2.18.1/install) --daemon

But uninstall and reinstalling of Nix is a bit of a hassle, does anyone know of an easier way to switch the nix-daemon version on a non NixOS system?

@nixos-discourse
Copy link

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/home-manager-mkoutofstoresymlink-and-nixunstable/37241/1

@rvl
Copy link
Contributor

rvl commented Dec 23, 2023

But uninstall and reinstalling of Nix is a bit of a hassle, does anyone know of an easier way to switch the nix-daemon version on a non NixOS system?

@Jak-Ch-ll I know of some ways which could work, but can't remember exactly the details of how nix-daemon runs on a non-NixOS system. The procedure would probably also depend on whether your non-NixOS system is also non-Linux and/or non-systemd.

Best to ask on NixOS Discourse. I created a thread, which is linked above.

@dyfrgi
Copy link

dyfrgi commented Mar 8, 2024

If you are looking for a workaround for non-NixOS systems, I did the following and it worked for me.

sudo nix-env -i nix-2.18.1
sudo systemctl daemon-reload
sudo systemctl restart nix-daemon.service

I am not certain that the systemctl steps are necessary, but they won't hurt anything. If anyone tries without those, please report back.

After those steps, I was able to use mkOutOfStoreSymlink.

It looks like nix 2.20.5 was just merged into nixpkgs, so the unstable channel should have a fix for this soon. At that point, I think it should be sufficient to run nix-env --upgrade. Whoops, actually NixOS/nix#9579 is still not fixed, so an upgrade probably won't be helpful.

nekowinston added a commit to nekowinston/dotfiles that referenced this issue Mar 11, 2024
@guibou
Copy link

guibou commented Mar 21, 2024

I removed my usage of mkOutOfStoreSymlink by using an activation script:

  home.activation = {
    # This was using .config and mkOuOfStoreSymlink, but it is broken in recent nix
   # see https://github.com/nix-community/home-manager/issues/4692
    updateLinks = ''
      export ROOT="${config.home.homeDirectory}/.config/home-manager/home"
      mkdir -p .config/i3
      ln -sf "$ROOT/i3config" .config/i3/config
      ln -sf "$ROOT/i3status.conf" .i3status.conf
      i3-msg restart

      mkdir -p .config/mpv/scripts
      ln -sf "$ROOT/mpv_sub-cut.lua" .config/mpv/scripts/sub-cut.lua
    '';
  };

Where .config/home-manager/home is the directyr which contains my file to symlink.

This is not perfect (for example, here the i3-msg restart is called for every activation, not only when the i3config file changed, as it was previously, but it works with the new nix version.

@Sgiath
Copy link

Sgiath commented Mar 22, 2024

I am on NixOS, same issue, solved by reverting back to nixStable

This is no longer true, nixStable is now on version 2.18.2 and I had to downgrade to 2.17.1 to keep it in the working state. Is there a plan to fix this function or will it be removed? It is not usable anymore with current versions of nix

otavio added a commit to otavio/nix-config that referenced this issue Mar 31, 2024
Nix 1.19.2 fails to build a derivation containing a symlink to store path.

```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
  '';
}
```

So we had to comment out the code below:

```nix
home.file."home-config" = {
  target = ".config/home-manager";
  source = config.lib.file.mkOutOfStoreSymlink "${config.home.homeDirectory}/src/nix-config";
};
```

Refs:
- nix-community/home-manager#4692
- NixOS/nix#9579

Signed-off-by: Otavio Salvador <[email protected]>
otavio added a commit to otavio/nix-config that referenced this issue Mar 31, 2024
Nix 1.19.2 fails to build a derivation containing a symlink to store path.

```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
  '';
}
```

Refs:
- nix-community/home-manager#4692
- NixOS/nix#9579

Signed-off-by: Otavio Salvador <[email protected]>
otavio added a commit to otavio/nix-config that referenced this issue Mar 31, 2024
Nix 1.19.2 fails to build a derivation containing a symlink to store path.

```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
  '';
}
```

Refs:
- nix-community/home-manager#4692
- NixOS/nix#9579

Signed-off-by: Otavio Salvador <[email protected]>
PartyWumpus added a commit to PartyWumpus/dotfiles that referenced this issue Apr 14, 2024
@PartyWumpus
Copy link

PartyWumpus commented Apr 14, 2024

This issue is fixed if i build nix from the 2.21-maintenance branch, probably fixed by #10456.

Means it'd be fixed for anyone using nix.package = pkgs.nixVersions.unstable once 2.21.3 comes out. It's (assuming that PR is the one that fixes it) also been backported to 2.20 & 2.19, but not 2.18 which is the current stable. Looks like the issue might not be present in 2.18 though.

Here's how I got nix to use the most most recent commit from 2.21-maintenance

nix.package = pkgs.nixVersions.unstable.overrideAttrs (oldAttrs: {
	src = pkgs.fetchFromGitHub {
		owner = "NixOS";
		repo = "nix";
		# 2.21-maintenance, basically just want 2.21.3
		rev = "60824fa97c588a0faf68ea61260a47e388b0a4e5";
		sha256 = "10z/SoidVl9/lh56cMLj7ntJZHtVrumFvmn1YEqXmaM=";
	};
});

PartyWumpus added a commit to PartyWumpus/dotfiles that referenced this issue Apr 14, 2024
@idlip
Copy link

idlip commented May 2, 2024

I can confirm that there is no issue with nixUnstable i.e, nix 2.22 (maybe 2.21 also as above comment said)

@GCBallesteros
Copy link

@idlip I'm still getting the same error on: 2.22.0 and 2.22.1. I installed those with the following commands:

sudo -i nix upgrade-nix --nix-store-paths-url https://releases.nixos.org/nix/nix-2.22.1/fallback-paths.nix

guibou added a commit to guibou/nixos_config that referenced this issue Jun 2, 2024
This was done manually because of a bug in nix
nix-community/home-manager#4692 which is now
fixed.
guibou added a commit to guibou/nixos_config that referenced this issue Jun 3, 2024
This was done manually because of a bug in nix
nix-community/home-manager#4692 which is now
fixed.
@rvl
Copy link
Contributor

rvl commented Jun 6, 2024

This issue can be closed I think, given that it was caused by a nix bug, and that there is a new nix release which fixes the bug.

@oxalica
Copy link
Contributor

oxalica commented Jun 6, 2024

This issue can be closed I think, given that it was caused by a nix bug, and that there is a new nix release which fixes the bug.

The latest Nix including the fix (2.22) does not yet become the default nix in nixpkgs (2.18). It was updated but soon being reverted due to other blocking issues (NixOS/nixpkgs#315858). Not sure encouraging users to use Nix 2.22 is a good idea though.

@hab25
Copy link
Contributor

hab25 commented Jun 27, 2024

Recently-released nix 2.18.3 contains the fix. It is the default nix in nixos-unstable and I expect it will land in nixos-24.05 as the default within the next few days.

@kluen
Copy link

kluen commented Jul 17, 2024

Can anybody confirm this is solved? I still have the issue with nix version 2.18.4 (from nixos-unstable).

@johanneskastl
Copy link

Can anybody confirm this is solved? I still have the issue with nix version 2.18.4 (from nixos-unstable).

I am hitting this on one machine, while on another it works. Not sure why...

@manuelbb-upb
Copy link
Contributor

I have this issue on Ubuntu with a flake-based home-manager setup. Tested with nix-2.19.2 and (after sudo nix upgrade-nix) with nix-2.18.5. I have also updated all the flake inputs, nixpkgs is following nixos-unstable, currently I have the following rev: github:nixos/nixpkgs/cb9a96f23c491c081b38eab96d22fa958043c9fa

@chaoky
Copy link

chaoky commented Dec 17, 2024

following the guide at https://nix.dev/manual/nix/2.24/installation/upgrading worked for me on ubuntu.
this should probably be closed.

@kluen
Copy link

kluen commented Dec 18, 2024

@chaoky Thank you so much for this hint. I wasn't aware of the fact that only updating the version of the nix binary is not enough. I was actually running nix-2.20.2 before. Following the guide using the channel nixos-24.11, I'm now running nix-2.24.10. Everything now works as expected for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug triage Issues or feature request that have not been triaged yet
Projects
None yet
Development

No branches or pull requests