1

I have a USB disk with a nix store (to be more precise, the nix-store.squashfs file from the NixOS installation ISO) mounted at /mnt/foobar. So that when I do ls /mnt/foobar, I see the familiar subdirs, looking like:

kipnv4i3njqc3hjunp8nv23o2io3-somepackage-0.0.1
...etc...etc...

Now, (how) can I import stuff from that nix store into my regular /nix/store? (Ideally, with dependencies...) Or is this impossible?... :/ feels so close, but I really don't know what to do next... :( Tried e.g. NIX_STORE=/mnt/foobar nix-store -qR /mnt/foobar/*-somepackage-* but I'm getting an error. I'm afraid to just copy dirs between stores, because I don't know if that won't break something; also, no idea how to find out the dependencies then...

  • This sounds like it may be a good job for a shell script that goes through the contents of your /mnt/foobar directory, and then loops through and checks if the file exists in /nix/store. If it doesn't exist, it copies it over. I would use cp -i just to have that extra level of protection in case something does exist and you don't want to overwrite it. This does sound like it could get kind of dangerous, though. Make sure you have a backup in place before attempting this. If it's a VM, just take a snapshot. – rubynorails Nov 20 '15 at 2:22
  • One of the problems is that I'm not sure if a dumb copy is enough for Nix system to properly recognize and accept the new directories as full packages. Another problem is that apparently the target filesystem is readonly, reportedly specifically to prevent copying stuff into there. Unfortunately, it's not as simple as just writing a bash script with a few cp calls. – akavel Nov 21 '15 at 19:04
1

Hm; I've tried something based on the wiki (section "Large files"), i.e.:

sudo unshare -m bash
mount -o remount,rw /nix/store
cd /mnt/foobar
tar c kipnv4i3njqc3hjunp8nv23o2io3-somepackage-0.0.1 | tar x -C /nix/store
printf "kipnv4i3njqc3hjunp8nv23o2io3-somepackage-0.0.1\n\n0\n" | nix-store --register-validity --reregister
exit

and nix-env -qa now seems to show this package as -P- (this is installed? or not?); not 100% sure if that's all OK now though...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.