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

nix-store does not obey NIX_IGNORE_SYMLINK_STORE #374

Open
rrnewton opened this issue Oct 17, 2014 · 12 comments
Open

nix-store does not obey NIX_IGNORE_SYMLINK_STORE #374

rrnewton opened this issue Oct 17, 2014 · 12 comments
Labels

Comments

@rrnewton
Copy link

When /nix is a symlink into a network file system, the current installer fails. Down inside its install script, this is what happens:

+ /nix/store/clnpynyac3hx3a6z5lsy893p7b4rwnyf-nix-1.7/bin/nix-store --init
error: `/nix' is not a directory

It would be nice if nix-store would also obey the NIX_IGNORE_SYMLINK_STORE flag, and tolerate this symlink.

Or..... perhaps this is unintended, and the current behavior is just a bug. Maybe it just should have followed the symlink when checking the file type. For example:

$ file /nix
/nix: symbolic link to `/nfs/wherever'
$ file /nix/
/nix/: directory
@wmertens
Copy link
Contributor

Why not mount the NFS mount directly over /nix?
Alternatively, consider proot if what you want is user installs.

On Fri, Oct 17, 2014 at 5:00 PM, Ryan Newton notifications@github.com
wrote:

When /nix is a symlink into a network file system, the current installer
fails. Down inside its install script, this is what happens:

  • /nix/store/clnpynyac3hx3a6z5lsy893p7b4rwnyf-nix-1.7/bin/nix-store --init
    error: `/nix' is not a directory

It would be nice if nix-store would also obey the NIX_IGNORE_SYMLINK_STORE
flag, and tolerate this symlink.

Or..... perhaps this is unintended, and the current behavior is just a
bug. Maybe it just should have followed the symlink when checking the file
type. For example:

$ file /nix
/nix: symbolic link to `/nfs/wherever'$ file /nix/
/nix/: directory


Reply to this email directly or view it on GitHub
#374.

@rrnewton
Copy link
Author

Well, much like in #324 we are not using this on personal machines or ones where we have root.

We want to use nix precisely for reproducibility across wide-flung machines with different configurations -- for us this means various supercomputers and our university shared linux systems. In the latter cases I convinced our sysadmins to symlink /nix, but it is laborious to ask them for more. proot sounds like an interesting option.

Still, it seems like this particular "bug" should be an easy fix, and would enable this symlinked mode of installation.

@edolstra
Copy link
Member

I can't reproduce this. This works:

$ file /tmp/root/nix
/tmp/root/nix: symbolic link to `/tmp/root/nix2'

$ file /tmp/root/nix/
/tmp/root/nix/: directory

$ NIX_IGNORE_SYMLINK_STORE=1 NIX_REMOTE= NIX_STATE_DIR=/tmp/root/db NIX_STORE_DIR=/tmp/root/nix/store nix-store --init

@rrnewton
Copy link
Author

Huh, this is surprising. If I run the "install" shell script:

$ ./nix-binary-tarball-unpack/nix-1.7-x86_64-linux/install
....
....
+ echo 'initialising Nix database...'
initialising Nix database...
+ /nix/store/clnpynyac3hx3a6z5lsy893p7b4rwnyf-nix-1.7/bin/nix-store --init
error: `/nix' is not a directory
+ echo './nix-binary-tarball-unpack/nix-1.7-x86_64-linux/install: failed to initialize the Nix database'
./nix-binary-tarball-unpack/nix-1.7-x86_64-linux/install: failed to initialize the Nix database
+ exit 1

And then I can repeat that failed command myself till my heart's content and I still see the error:

$ /nix/store/clnpynyac3hx3a6z5lsy893p7b4rwnyf-nix-1.7/bin/nix-store --init
error: `/nix' is not a directory

Then I can add in these env vars one-by-one and still get the error:

$ NIX_IGNORE_SYMLINK_STORE=1  /nix/store/clnpynyac3hx3a6z5lsy893p7b4rwnyf-nix-1.7/bin/nix-store --init
error: `/nix' is not a directory

$ NIX_IGNORE_SYMLINK_STORE=1 NIX_REMOTE= /nix/store/clnpynyac3hx3a6z5lsy893p7b4rwnyf-nix-1.7/bin/nix-store --init
error: `/nix' is not a directory

Finally, it's NIX_STATE_DIR that seems to make it work:

$ NIX_IGNORE_SYMLINK_STORE=1 NIX_REMOTE= NIX_STATE_DIR=/tmp/root/db /nix/store/clnpynyac3hx3a6z5lsy893p7b4rwnyf-nix-1.7/bin/nix-store --init

@rrnewton
Copy link
Author

Oh, however, that only works when NIX_STATE_DIR is outside the symlinked dir. If I set it to /nix/var/nix I still get the error:

$ NIX_IGNORE_SYMLINK_STORE=1 NIX_REMOTE= NIX_STATE_DIR=/nix/var/nix /nix/store/clnpynyac3hx3a6z5lsy893p7b4rwnyf-nix-1.7/bin/nix-store --init
error: `/nix' is not a directory

$ NIX_IGNORE_SYMLINK_STORE=1 NIX_REMOTE= NIX_STATE_DIR=/nix/var/nix NIX_STORE_DIR=/nix/store /nix/store/clnpynyac3hx3a6z5lsy893p7b4rwnyf-nix-1.7/bin/nix-store --init
error: `/nix' is not a directory

@wmertens
Copy link
Contributor

What throws that error? It's not https://github.com/NixOS/nix/blob/master/src/libstore/local-store.cc#L217-L219 since the message is different...

@edolstra edolstra added the bug label Nov 6, 2014
@rrnewton
Copy link
Author

Btw, the work-around that I'm using on some machines is to create a /nix dir, install, and then move the contents of it somewhere else, then symlink it. But if it requires going through a sysadmin for those steps thats a pain. I'll probably just instead create a tarball capturing the installed state, and reproduce the rest of the install script that sets up ~/.nix-profile/.

@knedlsepp
Copy link
Member

knedlsepp commented Nov 28, 2016

I have a symlink /nix to a different filesystem. This works fine if I install things in the binary cache. Building things locally however always fails because of this impurity even though i set NIX_IGNORE_SYMLINK_STORE, as described in the docs.

@rrnewton
Copy link
Author

rrnewton commented Nov 28, 2016

Ok, so does that amount o a failure to reproduce? I'll give it a try again now that a couple years have passed.

@gilligan
Copy link
Contributor

gilligan commented Mar 6, 2020

@rrnewton is this still a problem / still relevant or can this issue be closed?

@stale
Copy link

stale bot commented Feb 15, 2021

I marked this as stale due to inactivity. → More info

@stale stale bot added the stale label Feb 15, 2021
@stale
Copy link

stale bot commented Apr 30, 2022

I closed this issue due to inactivity. → More info

@stale stale bot closed this as completed Apr 30, 2022
@thufschmitt thufschmitt reopened this Feb 24, 2023
zolodev pushed a commit to zolodev/nix that referenced this issue Jan 1, 2024
@edolstra edolstra removed their assignment Apr 26, 2024
@stale stale bot removed the stale label Apr 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

8 participants