Syntax error, unexpected EOF, expecting semicolon

Hi. I am currently instaling NixOS to virtual machine through SSH, but it still gives me this:

error: syntax error, unexpected end of file, expecting ';'

       at /mnt/etc/nixos/configuration.nix:116:2:

          115|   system.stateVersion = "22.05"; # Did you read the comment?
          116| }
             |  ^
(use '--show-trace' to show detailed location information)

I have done everything right, but it still throws that same error. Can someone help me?

you probably forgot to close an attrset (ie, missing }) somewhere further up.

1 Like

I went through that config file like 10k times and I did not found any mistake.


Still, you certainly overlooked an error. You may want to add the nix LSP to your editor to help you spot syntax issues like this. Otherwise, you could try to run a formatter on it, they may be able to tell you something is wrong when you look at the indentation going bad.

Another option (assuming you cannot share the full file here) is to drop in a semicolon somewhere up from the bottom and notice how the reported error moves. This should help you hone in on where and what the actual error is.

Similar to adding a semicolon is to remove chunks of code until nixos-rebuild dry-build succeeds, and then add them back until it fails and you identify the offending code.