-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Permission denied error when building symlink derivation #9579
Comments
This issue has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/2023-12-18-nix-team-meeting-minutes-113/37050/1 |
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 |
I tried to reproduce this, but struggled. I wrote a NixOS test for this that shows no problems: # nixos-test.nix
let
nixpkgs = fetchTarball "https://github.com/NixOS/nixpkgs/tarball/d6863cbcbbb80e71cecfc03356db1cda38919523";
pkgs = import nixpkgs {
config = {};
overlays = [];
system = "x86_64-linux";
};
in
pkgs.nixosTest {
name = "test";
skipTypeCheck = true;
nodes.machine = {
environment.etc.nixpkgs.source = nixpkgs;
system.extraDependencies = [
(pkgs.closureInfo {
rootPaths = [ pkgs.stdenvNoCC.drvPath ];
})
];
nix.package = pkgs.nixUnstable;
environment.etc."test-symlink.nix".text = ''
# test-symlink.nix
{ local ? "/etc/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
''';
}
'';
};
testScript = ''
start_all()
machine.succeed('nix-build /etc/test-symlink.nix')
print(machine.succeed('nix-env --version'))
print(machine.succeed('readlink -f result*'))
'';
} Run with
I don't have more time right now, but if somebody could adjust this NixOS test to show the problem, that would be great! |
Here @infinisil, try this one: # nixos-test.nix
let
nixpkgs = fetchTarball "https://github.com/NixOS/nixpkgs/tarball/d6863cbcbbb80e71cecfc03356db1cda38919523";
pkgs = import nixpkgs {
config = {};
overlays = [];
system = "x86_64-linux";
};
user = "alice";
target = "/home/${user}/file";
in
pkgs.nixosTest {
name = "test";
skipTypeCheck = true;
nodes.machine = {
system.extraDependencies = [
(pkgs.closureInfo {
rootPaths = [ pkgs.stdenvNoCC.drvPath ];
})
];
nix.package = pkgs.nixUnstable;
nix.nixPath = ["nixpkgs=${nixpkgs}"];
environment.etc."test-symlink.nix".text = ''
{ pkgs ? import <nixpkgs> {} }: let
direct-symlink = pkgs.runCommand "direct-symlink" {} '''
ln -vs ${target} $out
''';
indirect-symlink = pkgs.runCommand "indirect-symlink" {} '''
ln -vs ''${direct-symlink} $out
''';
in
indirect-symlink
'';
users.users.${user}.isNormalUser = true;
systemd.tmpfiles.rules = ["f ${target} 0644 ${user} ${user} - test"];
};
testScript = ''
start_all()
print(machine.succeed('nix --version'))
machine.succeed("su -l ${user} -c 'nix-build /etc/test-symlink.nix'")
machine.succeed("su -l ${user} -c 'readlink -f result'")
machine.succeed("su -l ${user} -c 'test `readlink -f result` = ${target}'")
'';
} I believe that the three necessary conditions for failure are:
|
When it does work like, what do the references look like? Is it possible the hardlinking was incorrectly following the symlink so we referencing paths not in our closure?! |
Rudimentary workaround/fix #9723 |
This issue has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/2024-01-08-nix-team-meeting-minutes-114/38156/1 |
This is very anti-Nix, but duplicates my old dotfile setup. From here it will be possible to incrementally move configuration into Home Manager. Note that as of today, this requires using nix version 2.18, which can be installed with `sudo nix-env -i nix-2.18.1`. It may also be necessary to explicitly restart the nix-daemon service with `sudo systemctl daemon-reload` and `sudo systemctl restart nix-daemon.service`. This is needed due to NixOS/nix#9579, which unfortunately is also not fixed in nix 2.20.5, which is the new version in nixpkgs. It looks like NixOS/nix#9723 will fix this and will hopefully land before nix 2.21.
Still working around nix-community/home-manager#4692 & NixOS/nix#9579
This issue has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/an-additional-nix-installed-by-home-manager/42298/1 |
I was just wondering: is this bug not considered a breaking change critical enough to be prioritized? Stable nix releases > 2.18 breaks home-manager users as per this bug. Does the behavior being relied upon by home-manager not come under stability guarantees? Asking because the discourse report marked this as |
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 <otavio@ossystems.com.br>
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 <otavio@ossystems.com.br>
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 <otavio@ossystems.com.br>
For me personally, it's a critical issue because my home-manager config which used to work nicely is now broken. However I think home-manager could work around the issue by building symlinks within a nix store path directory, rather than as top-level nix store paths. So from that perspective it's "annoying but not critical." For stability guarantees I guess we would need to know which behaviours (if not all) should be stable, and what does correct behaviour look like. Perhaps this is the more important issue. What is the meaning of a symlink at the top level of a nix store? |
Not only does this lead to "permission denied" errors when the symlink target is not accessible to the build user, it also introduces a huge impurity when it is. |
I don't know but impermanence is pretty broken for me right now and by being in a |
NixOS/nix#9579 is still unresolved, as the offending commit (NixOS/nix@622191c) is only present starting version 2.19.0, we can update to 2.18.x; this way we can remove the insecure package rule. Signed-off-by: Roosembert Palacios <roosemberth@posteo.ch>
Bind-mounting symlinks is apparently not possible, which is why the thing was failing. Fortunately, symlinks are small, so we can fallback to copy them at no cost. Fix NixOS#9579
Regression test for NixOS#9579
…o a symlink out of the store Bind-mounting symlinks is apparently not possible, which is why the thing was failing. Fortunately, symlinks are small, so we can fallback to copy them at no cost. Fix NixOS#9579 Co-authored-by: Artturin <Artturin@artturin.com>
Regression test for NixOS#9579 (cherry picked from commit 872d93e)
…o a symlink out of the store Bind-mounting symlinks is apparently not possible, which is why the thing was failing. Fortunately, symlinks are small, so we can fallback to copy them at no cost. Fix NixOS#9579 Co-authored-by: Artturin <Artturin@artturin.com> (cherry picked from commit 913db9f)
Regression test for NixOS#9579 (cherry picked from commit 872d93e)
…o a symlink out of the store Bind-mounting symlinks is apparently not possible, which is why the thing was failing. Fortunately, symlinks are small, so we can fallback to copy them at no cost. Fix NixOS#9579 Co-authored-by: Artturin <Artturin@artturin.com> (cherry picked from commit 913db9f)
Another attempt to bring ae48df3 while avoiding the Nix symlink bug[1]. [1]: NixOS/nix#9579
Another attempt to bring ae48df3 while avoiding the Nix symlink bug[1]. I guess the bug was triggered by the sbin -> bin symlink in util-linux. [1]: NixOS/nix#9579
Another attempt to bring ae48df3 while avoiding the Nix symlink bug[1]. I guess the bug was triggered by the sbin -> bin symlink in util-linux. [1]: NixOS/nix#9579
Another attempt to bring ae48df3 while avoiding the Nix symlink bug[1]. I guess the bug was triggered by the sbin -> bin symlink in util-linux. [1]: 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.
Steps To Reproduce
The error message is:
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:
nix-env --version
outputThis is the
nixUnstable
package, corresponding to revision 2c7f3c0fb7c08a0814627611d9d7d45ab6d75335 of nixpkgs.Additional context
Introduced by
You might ask, why build such a silly derivation? Well, it's how
mkOutOfStoreSymlink
works under home-manager.See: nix-community/home-manager#4692
Priorities
Add 👍 to issues you find important.
The text was updated successfully, but these errors were encountered: