Where is my configuration file after install?

tl;dr: I followed the installation instructions, installed, and now the config file I wrote no longer exists. Where is it/what did I do wrong?

I have a VPS on liteserver, I loaded minimal NixOS iso, and then followed the NixOS manual installation guide. The system is legacy so I followed the ’ Legacy Boot (MBR)’ partitioning section – I just ran the commands exactly as printed in the manual, except that I substituted sda, sda1 etc. for vda, vda1 etc, because I’m on a VPS. Similarly for formatting: I ran mkfs.ext4 -L nixos /dev/vda1 then mkswap -L swap /dev/vda2. Then I ran mount /dev/disk/by-label/nixos /mnt and swapon /dev/vda2.

I created a config file with nixos-generate-config --root /mnt, edited it, and then ran the installation. After installation and reboot:

  • the file at /etc/nixos/configuration.nix is not the config file I wrote. It is the same as the file which was there during the installation, the contents are:
    { config, pkgs, ... };
    
    {
     imports = [ <nixpkgs/nixos/modules/installer/cd-dvd/installation-cd-minimal.nix> ];
    
    }
    
  • the file which I edited during the installation process does not exist either. It was at /mnt/etc/nixos/configuration.nix (as described in the manual). /mnt/ is now empty (the directory exists, but there’s nothing in it).

What happened to the configuration file I wrote? I’m happy to go through the installation process again—should I have copied/moved it?

TIA!

It kind of sounds like you might have rebooted back into the install image rather than your installed system. Is that possible?

/mnt would be empty in that case until you remounted /dev/disk/by-label/nixos again. And it’s the only reason that I’d expect you the config file to be the one from the installer.

1 Like

It kind of sounds like you might have rebooted back into the install image rather than your installed system. Is that possible?

Yes, I think this is what’s happening. I ran through the same process again, with all the same steps as before, and checked what the grub boot menu gave me. There’s no new option entry in the boot menu – all the options are just the defaults for the install image.

Give that:

  • the nixos-install process did finish (and prompted me for a password, as it should)
  • /dev/disk/by-label/nixos still contains what I put there before (i.e. the config file I wrote during the installation process)

I think the issue is with creating/setting up a new grub entry. Do you think this could be right?

The nixos-install man page says:

It installs the GRUB boot loader on the device specified in the option boot.loader.grub.device (unless –no-bootloader is specified), and generates a GRUB configuration file that boots into the NixOS configuration just installed.

So I think that something is wrong with the grub settings in my configuration.nix. At the moment I have:

boot.leader.grub.enable = true;
boot.leader.grub.version = 2;
boot.leader.grub.device = "/dev/vda";

and nothing else. Liteserver’s VPSs are legacy/non-efi systems, so this looks right to me. Could anything here be causing the problem?

Note for self or other users: this might be a useful resource, as well as this.

SOLUTION: My problem was that I hadn’t switched away from the installer ISO. I wrote up a guide on the whole installation process here.