New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
nixos-generate-config interacts badly with swapDevices.*.randomEncryption.enable=true #86353
Comments
The logic in the perl script to choose which devices get included in hardware-configuration is pretty rudimentary, it just excludes files and zram devices, and includes everything else. The only robust way I can think of to selectively exclude block devices would be for the nixos derivation to produce a list of devices that should be skipped, instead of trying to decide in the perl script. For example, what if every Since the UUID of randomly encrypted devices is not known at build time, but the |
@buckley310 Sounds good as far as I can tell. I still think it would be simpler to put filesystems and swap in |
This took less effort than i expected. I'm working on it here https://github.com/buckley310/nixpkgs/tree/swap-tracking i think the reason filesystems go in the hardware config is so that its technically possible to have everything except the hardware config shared across multiple machines, but I'm not totally sure. I don't use it that way. |
Thanks for working on that. I'm not currently running the NixOS installation where I encountered that problem, but will keep your WIP in mind if I boot that up again. |
I marked this as stale due to inactivity. → More info |
Describe the bug
My swap devices are encrypted with random keys, using
swapDevices.*.randomEncryption.enable = true
.When I run
nixos-generate-config
, I get something like this inhardware-configuration.nix
:The trouble is, those uuids won't exist on the next boot (I think they're different every time), so NixOS hangs for 90 seconds during boot waiting for them to appear.
I know of three workarounds:
hardware-configuration.nix
to remove them. But I'm not supposed to edit that file, according to the comment at the top.lib.mkForce
inconfiguration.nix
to override theswapDevices
fromhardware-configuration.nix
. But this breakszramSwap
: see zramSwap.enable doesn't work with nixos-rebuild build-vm #86061nixos-generate-config
has a--no-filesystems
option. I haven't tried it yet, but I assume it will fix my problem.To Reproduce
randomEncryption
. For example, myconfiguration.nix
is posted here. To properly reproduce the problem, you should leave outmkForce
from theswapDevices
attribute (I put that in as a workaround.)randomEncryption
enabled, run nixos-generate-config. Observe theswapDevices
entry inhardware-configuration.nix
pointing to ephemeral UUIDs.nixos-rebuild boot
and reboot, and you didn't use themkForce
workaround, then you should see the system hang for 90s on boot waiting for those old ephemeral UUIDs to appear.Expected behavior
nixos-generate-config
should not add the swap devices tohardware-configuration.nix
.(Why do filesystems and swap devices go into
hardware-configuration.nix
rather thanconfiguration.nix
? It seems like it's useful to have those automated the first time I install NixOS, but I can't think of a reason I'd wantnixos-generate-config
to change them on its own later. Havingnixos-generate-config
put them inconfiguration.nix
would achieve the behaviour I want, which is to not mess with them after installation.)Notify maintainers
Picking on two people who authered recent-ish commits in
nixos-generate-config.pl
:@bjornfor
@buckley310
Metadata
Please run
nix-shell -p nix-info --run "nix-info -m"
and paste the result."x86_64-linux"
Linux 5.4.33, NixOS, 20.03.1445.95b9c99f6d0 (Markhor)
yes
yes
nix-env (Nix) 2.3.4
""
"nixos-20.03.1445.95b9c99f6d0"
/nix/var/nix/profiles/per-user/root/channels/nixos
Maintainer information:
The text was updated successfully, but these errors were encountered: