System hangs at "loading graphical session", chroot fails

I have weird issues on my Chromebook, current and previous generations fail to boot, while a Live USB succeeds.

I moved a bunch of files over and then tried a chroot to fix it. The system uses flakes and encrypted BTRFS, so the docs are not complete there.

[root@nixos:/home/nixos]# cryptsetup open /dev/mmcblk1p2 chromebook
Enter passphrase for /dev/mmcblk1p2:

[root@nixos:/home/nixos]# mount /dev/mapper/chromebook /mnt/

[root@nixos:/home/nixos]# nixos-enter
ln: failed to create symbolic link '/bin/.sh.tmp': No space left on device
mv: cannot stat '/bin/.sh.tmp': No such file or directory
Activation script snippet 'binsh' failed (1)
write_file '/var/lib/nixos/.tempWYLdM' - sysopen: No space left on device at /nix/store/dyx8qsmgnsz2csfzwn723gbd2jvp0j7g-update-users-groups.pl line 23.
Activation script snippet 'users' failed (28)
setting up /etc...
Died at /nix/store/rg5rf512szdxmnj9qal3wfdnpfsx38qi-setup-etc.pl line 27.
Activation script snippet 'etc' failed (28)
ln: failed to create symbolic link '/usr/bin/.env.tmp': No space left on device
mv: cannot stat '/usr/bin/.env.tmp': No such file or directory
Activation script snippet 'usrbinenv' failed (1)

I will try to reboot and try again

Tried again, with and without sudo or root, same result.

Trying to chroot manually fails at the chroot step

[root@nixos:/home/nixos]# chroot /mnt /nix/var/nix/profiles/system/activate
ln: failed to create symbolic link '/bin/.sh.tmp': No space left on device
mv: cannot stat '/bin/.sh.tmp': No such file or directory
Activation script snippet 'binsh' failed (1)
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
        LANGUAGE = (unset),
        LC_ALL = (unset),
        LC_CTYPE = (unset),
        LC_NUMERIC = (unset),
        LC_COLLATE = (unset),
        LC_TIME = (unset),
        LC_MESSAGES = (unset),
        LC_MONETARY = (unset),
        LC_ADDRESS = (unset),
        LC_IDENTIFICATION = (unset),
        LC_MEASUREMENT = (unset),
        LC_PAPER = (unset),
        LC_TELEPHONE = (unset),
        LC_NAME = (unset),
        LANG = "en_US.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
write_file '/var/lib/nixos/.tempwLncG' - sysopen: No space left on device at /nix/store/dyx8qsmgnsz2csfzwn723gbd2jvp0j7g-update-users-groups.pl line 23.
Activation script snippet 'users' failed (28)
setting up /etc...
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
        LANGUAGE = (unset),
        LC_ALL = (unset),
        LC_CTYPE = (unset),
        LC_NUMERIC = (unset),
        LC_COLLATE = (unset),
        LC_TIME = (unset),
        LC_MESSAGES = (unset),
        LC_MONETARY = (unset),
        LC_ADDRESS = (unset),
        LC_IDENTIFICATION = (unset),
        LC_MEASUREMENT = (unset),
        LC_PAPER = (unset),
        LC_TELEPHONE = (unset),
        LC_NAME = (unset),
        LANG = "en_US.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
Died at /nix/store/rg5rf512szdxmnj9qal3wfdnpfsx38qi-setup-etc.pl line 27.
Activation script snippet 'etc' failed (28)
ln: failed to create symbolic link '/usr/bin/.env.tmp': No space left on device
mv: cannot stat '/usr/bin/.env.tmp': No such file or directory
Activation script snippet 'usrbinenv' failed (1)

Uhm, checking storage, is this thing simply full? Will delete some files lol

Solved, kinda

Somehow my nix store had grown to over 100GB filling up my entire system

Needed to delete some large user files, then chrooting worked as expected.

Now I am doing a nh clean all

If you have other suggestions on how to prune the store, please tell me!

I already used this update.nix


{ ... }:
{
	system.autoUpgrade = {
		enable = true;
		dates = "23:00";
		randomizedDelaySec = "45min";
		runGarbageCollection = true;
		operation = "boot";
		allowReboot = true;
		rebootWindow = {
			lower = "03:00";
			upper = "07:00";
		};
	};

	# service overrides
	systemd.services.nixos-upgrade.postStop = ''
		# delete generations older than 3
		nix-env --delete-generations +3
		# garbage collect unused things
		nix-store --gc

		lib.getExe dash -c "lib.getExe flatpak update -y && lib.getExe flatpak remove --delete-data --unused -y"
	'';
}

But apparently it didnt work, and something blew up my store

I use the following tools to clean up the Nix store:

You still do need to run fast-nix-gc manually, at least in my config, because when I had it running automatically, it decided to run in the middle of an update and eating stuff that wasn’t gcrooted yet due to build failures with some packages I had and needed to fix.