Trace that stateVersion is not set, but it is?

During deploy, I get

trace: warning: system.stateVersion is not set, defaulting to 22.05. Read why this matters on

But it is set in my configuration (as reported trace that stateVersion is not set, but it is? · Issue #191622 · NixOS/nixpkgs · GitHub). I want to re-submit this here because nobody reacted on the issue yet and I don’t know whether this is actually a real issue or whether I can ignore it.

My first question: Are you sure you’re actually importing that file?


nix eval


nix-instantiate --eval '<nixos/nixos>' -A config.system.stateVersion

To see for sure what nixos actually computes the option value to be.

Are you sure you’re actually importing that file?

What file are you referring to?

The one in which you set system.stateVersion. (I’m referencing the file you tailed in the github issue.)

ah, yes. Well that’s also the entry-point of my system configuration, so there’s no way that the relevant file could not be there…

Even so, could you try the command I gave? It will give a useful marker for where this issue is actually stemming from.

$ nix-instantiate --eval '<nixos/nixos>' -A config.system.stateVersion
error: file 'nixos/nixos' was not found in the Nix search path (add it using $NIX_PATH or -I)

$ nix-instantiate --eval '<nixpkgs/nixos>' -A config.system.stateVersion
error: file 'nixos-config' was not found in the Nix search path (add it using $NIX_PATH or -I)

       at /var/src/nixpkgs/nixos/default.nix:1:60:

            1| { configuration ? import ./lib/from-env.nix "NIXOS_CONFIG" <nixos-config>
             |                                                            ^
            2| , system ? builtins.currentSystem
(use '--show-trace' to show detailed location information)

$ echo $NIX_PATH

Ok, how do you run a rebuild, normally?

I use krops for deploying my machines.

Well, I have no idea how that works, so I know no way to verify that what you think is your entry point really is, or that the option is actually being set when evaluated.

krops essentially does rsync the configuration files to the remove machine and then sshing into that machine and nixos-rebuild switching.

Far too general. The issues here are all about specifics, I’m afraid.

I found what you’re looking for, probably:

$ NIXOS_CONFIG=/var/src/nixos-config nix-instantiate --eval '<nixpkgs/nixos>' -A config.system.stateVersion

You’re certainly evaluating some kind of nixos module here, whether it’s the same one krops is using, I still don’t know.

Here’s an idea: change your stateVersion from "21.05" to builtins.trace "yes, we really evaluated this" "21.05" and see if you get that trace output on a normal rebuild of the machine in question.


The fun thing now is: The warning that the stateVersion is not set wasn’t raised now. :frowning_face:

Arg. Heisenbug. :confused:

1 Like

Perhaps you updated to a version of nixpkgs that includes nixos/version: Only warn about unset stateVersion if used · NixOS/nixpkgs@f03c7fb · GitHub between then and now?

Not sure. My current nixos stable channel points to 0938d73bb143f4ae037143572f11f4338c7b2d1c which is from 2022-12-17T16:40:00-05:00.

I will keep a close eye on my rebuilds and report back if I run into the issue again.

If krops runs the builds on the remote machines, mightn’t their version of nixpkgs be relevant? (I hope not. That would be pretty poor design…)

yes, but krops also deploys your channel sources e.g. nixpkgs-stable… whatever you specify. I deploy nixos-22.11 and nixos-unstable for example. The system is built from nixos-22.11 and some packages are installed from nixos-unstable.

Krops is more or less what flakes is today, but krops was available years ago. Also, builds get executed on the target rather than on the host that starts the deploy.

Hosted by Flying Circus.