How to troubleshoot super slow nix (23 seconds 'nix --version')

Nix is behaving really strange on a laptop that I recently setup with NixOS.
All nix commands takes forever to run, just to give a simple example:

[michel@michel-x1:~]$ time nix --version
nix (Nix) 2.4

real	0m23.751s
user	0m0.042s
sys	0m0.023s
[michel@michel-x1:~]$ time nix-channel --list

real	0m23.479s
user	0m0.044s
sys	0m0.026s

I have been using NixOs for something like 4 years now, and I believe its the first time I experience nix being this crazy slow.

The things that I have tried so far to make nix fast again is:

How do I troubleshoot and fix the problem with nix being so slow?

I don’t mind switching on some of that new fancy ‘flake’-thingy-stuff if that is what it takes (and if someone can guide me on to how to do that)… I have anyways started to familiarize myself a bit with ‘nix flake’ on my work machine on which I sadly have to run Windows but at least with linux in WSL… (nix --version in WSL, runs in ~10 seconds btw)

I don’t consider myself a very advanced NixOs-user, I have mostly just been happy with having a simple declarative configuration file with which I could quickly get a new laptop up and running with all the packages and setup that I like (I’ve done that at least 5-10 times over the past couple of years with no issues)… and then of course the ability to rollback easily and install stuff without worrying about library version problems… Using NixOs up to now has in general been quite enjoyable…

1 Like

Might this be related?

Depending on your DNS configuration, this might cause slowdowns.


In general, strace ( is a good second tool (after usr/bin/time) to try when you have no idea what’s going on.