Hi there,
I just took the flake based example for the NixOS Wiki, but it seems that does not work out of the box. At leasst for my setup which is the following.
under /home/myuser/repos/infrastructure is my checked out git repo with the flake.nix + configuration.nix + hardware-configuration.nix
I do invoke the rebuild like this: nixos-rebuild switch --flake '.#' --sudo
Auto Upgrade part (should be almost exactly as in the wiki)
system.autoUpgrade = {
enable = true;
flake = inputs.self.outPath;
flags = [ "--print-build-logs" ];
dates = "18:10";
};
I have not analysed the error yet, I was under the assumption it would just work. The thing that’s “weird” is that there is no mention of “updating” the flake.lock
My assumption would be that a flake based nixOS upgrade is done by updating the flake’s inputs.
But I might be wrong as this is basically my 2nd or 3rd week into nixOS on my second machine now. Still figuring things out.
Plus it might be related to systemd running the upgrade as root, the flake being located in a directory owned by my user?
Error Output here:
journalctl -u nixos-upgrade.service
Sep 04 18:10:14 rpi-nixos systemd[1]: Starting NixOS Upgrade...
Sep 04 18:10:22 rpi-nixos nixos-upgrade-start[1364]: unpacking 1 channels...
Sep 04 18:11:22 rpi-nixos nixos-upgrade-start[1334]: warning: could not re-exec in a newer version of nixos-rebuild, using current version
Sep 04 18:11:23 rpi-nixos nixos-upgrade-start[1588]: unpacking 1 channels...
Sep 04 18:11:23 rpi-nixos nixos-upgrade-start[1334]: building the system configuration...
Sep 04 18:11:23 rpi-nixos nixos-upgrade-start[1334]: error: your NixOS configuration path seems to be missing essential files.
Sep 04 18:11:23 rpi-nixos nixos-upgrade-start[1334]: To avoid corrupting your current NixOS installation, the activation will abort.
Sep 04 18:11:23 rpi-nixos nixos-upgrade-start[1334]: This could be caused by Nix bug: https://github.com/NixOS/nix/issues/13367.
Sep 04 18:11:23 rpi-nixos nixos-upgrade-start[1334]: This is the evaluated NixOS configuration path: /nix/store/bzc6gvxpjgdzgcppdx3jdrfkvzkgl92j-source.
Sep 04 18:11:23 rpi-nixos nixos-upgrade-start[1334]: Change the directory to somewhere else (e.g., `cd $HOME`) before trying again.
Sep 04 18:11:23 rpi-nixos nixos-upgrade-start[1334]: If you think this is a mistake, you can set the environment variable
Sep 04 18:11:23 rpi-nixos nixos-upgrade-start[1334]: NIXOS_REBUILD_I_UNDERSTAND_THE_CONSEQUENCES_PLEASE_BREAK_MY_SYSTEM to 1
Sep 04 18:11:23 rpi-nixos nixos-upgrade-start[1334]: and re-run the command to continue.
Sep 04 18:11:23 rpi-nixos nixos-upgrade-start[1334]: Please open an issue if this is the case.
Sep 04 18:11:23 rpi-nixos systemd[1]: nixos-upgrade.service: Main process exited, code=exited, status=1/FAILURE