~/.nix-profile existing causes black screen

I’ve been using Nix for a few months now via home-manager and it’s worked well. However yesterday when I rebooted and logged into my user on Kubuntu as per usual, the screen this time was entirely black.

After much debugging I determined that the symlink ~/.nix-profile/nix/var/nix/profiles/per-user/myuser/profile causes this error. Without it the symlink existing I of course cannot access any of my existing Nix packages, so can I get some tips for how to debug what specifically is causing the issue?

PC: Dell XPS 13
OS: Kubuntu 23.10
nix (Nix) 2.13.3

I doubt it’s the symlink existing, it’s more likely that something reads configuration through the symlink, or some autostarted application has its binary in there, and you removing it makes that thing simply not happen. Said thing will be causing the black screen.

Can we get logs from journalctl -t xsession? Ideally you log in, let the black screen happen, then switch to another tty (using e.g. Ctrl+Alt+F3), log in and use:

journalctl -t xsession --boot > xsession.log

And then share the contents of xsession.log with us.

The file only contains -- No entries --.

An error shows up when I log into my user via tty, not sure if it’s relevant:
/home/boss/.nix-profile/bin/manpath: can't set the locale: make sure $LC_* and $LANG are correct. I did some searching and found those two variables seem to be correct in the file I found them in however.

Oh, whoops, sorry, I misread that, thought you were on NixOS. I’m not sure if/where Kubuntu will put your session logs. You can try journalctl --boot without the -t xsession to see the full logs of the current boot, with any luck what’s going wrong would be near the end of the logs. Depending on whether you use X or wayland some files in /var/log/Xorg might be useful too.

Edit: this was only a temporary fix.

I think I fixed the issue. I read on some post that it may be outdated Qt packages interfering with KDE. I’m not sure if it was exactly that but this person suggested running nix-collect-garbage --delete-older-than 7d, which for me got rid of 49GB of old packages.

When copying ~/.nix-profile back into my user it now doesn’t load the black screen and I have access to my Nix packages again. Thanks for your help!

Odd! For context, nix-collect-garbage should be run periodically. Nix will download new versions of your packages into /nix/store, and switch your environment variables/symlinks made by home-manager to point to the new paths, but it will never delete old packages. nix-collect-garbage will go through the store and see if any paths exist that have no references anymore, and delete them if so.

Since there should be no reference to the old packages in your environment variables or directories, though, things in the nix store should be completely unused, and just waste disk space (until you want to roll back to them).

It’s weird to me that a garbage collection fixed your issue. Maybe on a non-NixOS system something cached the absolute location of a graphics lib or something weird like that. Or perhaps you were running low on disk space and KDE needs a little to be able to start something. Glad you’ve managed to resolve it, either way.

Uhh nevermind, after another reboot the issue came back again.

journalctl --boot logs (pastebin).

/var/log/Xorg.0.log (pastebin).