After updating my system to the latest master branch, I started getting this error when rebuilding my system, and on reboot
Oct 10 08:54:29 nixos systemd\[1\]: Activating swap /swapfile...
Oct 10 08:54:29 nixos swapon\[4880\]: swapon: /swapfile: swap format pagesize does not match.
Oct 10 08:54:29 nixos swapon\[4880\]: swapon: /swapfile: reinitializing the swap.
Oct 10 08:54:29 nixos swapon\[4885\]: swapon: failed to execute mkswap: No such file or directory
Oct 10 08:54:29 nixos systemd\[1\]: swapfile.swap: Swap process exited, code=exited, status=255/EXCEPTION
Oct 10 08:54:29 nixos systemd\[1\]: swapfile.swap: Failed with result 'exit-code'.
Oct 10 08:54:29 nixos systemd\[1\]: Failed to activate swap /swapfile.
Sounds like there’s something wrong with your swapfile and you just need to do mkswap /swapfile again. The swapon command that systemd runs should be doing this itself, but looks like we’ve got a nixos bug where that swapon command can’t find mkswap for itself. Probably worth opening an issue about if there isn’t one already
Well, I’ve already done some experimentation and confirmed there is a NixOS bug here. If swapon determines that it needs to fixup your swapfile with mkswap, it will fail because we don’t have mkswap on the default PATH for .swap systemd units. So that’s intended util-linux behavior that isn’t working on NixOS.
But yes, there’s clearly also an issue in @mg95’s config in terms of how their impermanence setup is creating the swapfile; for some reason it’s creating a swapfile that swapon later thinks needs fixing up.