Sudo nixos-rebuild switch does nothing

Hi!

I installed NixOS in qemu today as i was intrigued by the declarative approach to package management and configuration.

Now that I’m inside the machine I uncommented

environment.system.Packages = with pkgs; [
  wget vim screen git tmux
];

As a test to see how it works. But rebuilding nix does nothing other than “building Nix, building the system configuration” and then nothing.

I have 2 configuration enties in grub. My understanding is that nix should rework the entirety of my OS from this configuration, but nothing at all happens.

1 Like

How exactly are you rebuilding?

nixos-rebuild switch should not only build but also switch to the new generation, nixos-rebuild boot will create a boot entry for it and make it the default for the next boot, but not actually activate it, nixos-rebuild build will build it and create a symlint result at your current working dir, but not activatae it or create a boot entry.

Hi!

I was using the nixos-rebuild switch, with the -v flag flag I saw it going through a lot of nix files. So it does something at least.

So, do you have binaries from the packages available in your PATH now?

If you remove a package and rebuild, does that binary vanish then?

Nixos-rebuild won’t do much if your system already is as declared.

The picture below should show the issues I’m seeing, I might just reinstall as this is is just a QEMU VM. But it would be interesting to know why the system doesn’t do as predicted.

What commands would you suggest for troubleshooting information that i could share?

This is weird.

And I remember that some other user had some similar problems in VirtualBox. They kept rebuilding but the system didn’t change, though it only happened after beeing able to rebuild a couple of times… I can’t find the thread though now…

Can you please tell us what your NIX_PATH looks like? printenv NIX_PATH

$ printenv NIX_PATH
/home/lillecarl/.nix-defexpr/channels:nixpkgs=/nix/var/nix/profiles/per-user/root/channels/nixos:nixos-config=/etc/nixos/configuration.nix:/nix/var/nix/profiles/per-user/root/channels

I have no idea what this is supposed to look like, but there it is :slight_smile: Thanks for your patience!

That entry looks fine…

As a user though you might see warnings about duplicate nixpkgs. For now I think we can ignore that.

Can you please tell us what printenv PATH shows?

Also please check if /run/current-system/sw/bin/{chromium,git,tmux}, etc are available.

$ printenv PATH
/run/wrappers/bin:/home/lillecarl/.nix-profile/bin:/etc/profiles/per-user/lillecarl/bin:/nix/var/nix/profiles/default/bin:/run/current-system/sw/bin

/run/current-system/sw/bin/ does not contain chromium, which is a package i didn’t install with the nix-env command.

If it would be of use i could isolate this VM in it’s own VRF and NAT ssh to it (in case this is to be considered a bug and someone wants to check out root cause) (or i could upload the QEMU image somewhere too).

Thanks :slight_smile:

I am having this issue as well, did you ever resolve this?

nixos-rebuild only does something if either the packages (from a channel), or configuration changed.

Most likely you’ll need to do:

sudo nix-channel --update # fetch latest packages
sudo nixos-rebuild {switch,boot} # apply configuration based on new packages

if nothing happens, then you’re likely to be on the latest release for that channel

This is after updating the configuration.

  environment.systemPackages = with pkgs; [ fish zsh bat ];

as well as enabling ZNC service, however nothing happens when I rebuild unless I remove a semicolon, then it tells me my config is incorrect.

EDIT: my configuration
https://gist.github.com/Fuzen-py/b8ed878e3d1a479004f5f2b0e94c2284

I reinstalled my NixOS VM and am now tracking unstable. Sadly I can’t offer a solution.

Remember to check your nix channels (sudo nix-channel --list)

I know this is rather late but I found this thread when experiencing similar issues with nixos-rebuild not doing anything.

I ended up running strace on nixos-rebuild and realized that it was exiting with a 137 (out of memory error) during evaluation. So it would error out early while evaluating your files if it saw an issue (messing with the semicolons as mentioned here).

If it doesn’t error out early on your own configuration it seems like it ends up running out of memory while evaluating nixpkgs. I solved this by upgrading the RAM on my server, but since this sent my head spinning for a while I just wanted to log down the solution I found somewhere.

5 Likes

@nixy thanks, you saved so much time. I run exactly into the same memory issue.

how much ram did you have?

how much free ram did you have?

it’s quite possible there should add warnings if you less than X GB’s in your system.

how much ram did you have?
how much free ram did you have?

In this case I have a small vps server with 2GB of ram. Usually it uses only 400M , but as it turns out the remaining space may not be enough to update the system. I suspect that most ram is used for doc generation (needs to be more carefully profiled).

it’s quite possible there should add warnings if you less than X GB’s in your system

I would say it should clearly report the reason of failure and thats it. Right now it just exists silently and it is not right, of cause.

1 Like