KiaraGrouwstra / nix-config

my NixOS configuration
15 stars 1 forks source link

/nix on HDD (arch) #138

Open KiaraGrouwstra opened 5 years ago

KiaraGrouwstra commented 5 years ago

How to put your /nix directory on a separate device

KiaraGrouwstra commented 4 years ago

for new path /run/media/tycho/meltan/nix:

sudo rm -rf /run/media/tycho/meltan/nix
sudo systemctl stop nix-daemon.socket
sudo rsync --recursive --links /nix/ /run/media/tycho/meltan/nix/
sudo rm -rf /nix
sudo ln -s /run/media/tycho/meltan/nix /nix
sudo systemctl start nix-daemon.socket
sudo systemctl daemon-reload
KiaraGrouwstra commented 4 years ago

well, I think I gained some SSD space, but I'm still unable to use Nix as per #143.

KiaraGrouwstra commented 4 years ago

hm, guess not!

KiaraGrouwstra commented 4 years ago

so chroot/proot make nix only work from special shells; --store /run/media/tycho/meltan/ seems to require specifying on each command (is there a setting to set this as default somewhere?), but also still has the files refer to interpreters back at the old /nix/store, so making it work also still requires the symlink e.g. sudo ln -s /run/media/tycho/meltan/nix /nix.

KiaraGrouwstra commented 4 years ago

As per the wiki, default -> vim ~/.config/nix/nix.conf: store = /run/media/tycho/meltan.

Basically though I'm just getting into this big frustrating mess of users and permissions:

$ nix build nixpkgs.lolcat
error: creating directory '/run/media/tycho/meltan/nix/var/nix/profiles/per-user/tycho': Permission denied
$ sudo nix build nixpkgs.lolcat
error: the path '/nix' is a symlink; this is not allowed for the Nix store and its parent directories
$ sudo mkdir /root/.config/nix/
$ sudo vim /root/.config/nix/nix.conf
$ sudo nix build nixpkgs.lolcat
error: attribute 'nixpkgs' in selection path 'nixpkgs.lolcat' not found
$ sudo nix build lolcat
error: attribute 'lolcat' in selection path 'lolcat' not found
$ nix build lolcat
error: creating directory '/run/media/tycho/meltan/nix/var/nix/profiles/per-user/tycho': Permission denied
$ ls /run/media/tycho/meltan/nix/var/nix/profiles/per-user/tycho
ls: cannot access '/run/media/tycho/meltan/nix/var/nix/profiles/per-user/tycho': No such file or directory
$ ls /run/media/tycho/meltan/nix/var/nix/profiles/per-user/
root/
$ ls /run/media/tycho/meltan/nix/var/nix/profiles/per-user/root/
channels@  channels-1-link@
$ sudo mkdir /run/media/tycho/meltan/nix/var/nix/profiles/per-user/tycho
$ nix build lolcat
error: changing permissions of directory '/run/media/tycho/meltan/nix/var/nix/profiles/per-user/tycho': Operation not permitted
$ nix-channel --update
error: changing permissions of directory '/run/media/tycho/meltan/nix/var/nix/profiles/per-user/tycho': Operation not permitted
$ sudo nix-channel --update
unpacking channels...
error: path '/run/media/tycho/meltan/nix/store/f38j6wlhhalcdv9wj6i8b57n5yssq93m-nixexprs.tar.xz' is not in the Nix store, at (string):1:84
(use '--show-trace' to show detailed location information)
error: program '/nix/store/6chjfy4j6hjwj5f8zcbbdg02i21x1qsi-nix-2.3.1/bin/nix-env' failed with exit code 1
KiaraGrouwstra commented 4 years ago

I guess this kinda brings me back to the blog post linked up, which requires a separate partition for a Nix installation off the SSD...

It's that or bcachefs again. :neutral_face:

KiaraGrouwstra commented 4 years ago

aaaand Nix install sh <(curl https://nixos.org/nix/install) --daemon fails too now. ¯\_(ツ)_/¯ I should maybe try doing without Nix for the moment...

KiaraGrouwstra commented 4 years ago

I maybe got this working for a while, but without auto-mount accidentally had it accumulate a /nix on my SSD again... Reinstall fails again:

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo HOME=/root /nix/store/ddmmzn4ggz1f66lwxjy64n89864yj9w9-nix-2.3.3/bin/nix-env -i /nix/store/ddmmzn4ggz1f66lwxjy64n89864yj9w9-nix-2.3.3

to installing a bootstrapping Nix in to the default Profile

installing 'nix-2.3.3'
error: while setting up the build environment: unable to bind mount '/nix/store/pgdgr848xbfqkp8ckxziv88vs73hnm17-user-environment.drv.chroot': Permission denied

... and evidently, no hits online.

edit: I'm pretty sure that's due to first moving partition, then installing... looks like it should be install first, move second.

sudo systemctl stop nix-daemon.socket
sudo systemctl stop nix-daemon.service
nix-shell -p nix-info --run "nix-info -m"