Skip to content

Fix vm test not respecting disko.tests.extraConfig disko overwrites#1184

Open
BerriJ wants to merge 1 commit intonix-community:masterfrom
BerriJ:master
Open

Fix vm test not respecting disko.tests.extraConfig disko overwrites#1184
BerriJ wants to merge 1 commit intonix-community:masterfrom
BerriJ:master

Conversation

@BerriJ
Copy link
Copy Markdown

@BerriJ BerriJ commented Jan 2, 2026

@Lassulus This should fix cases where users overwrite some disko configurations inside of disko.tests.extraConfig. The docs on this setting state:

Extra NixOS config for your test. Can be used to specify a different luks key for tests.
A dummy key is in /tmp/secret.key

Consider the following setting: You have boot.initrd.systemd.enable = true; (systemd in Stage 1) and you have a disko config with luks like this:

type = "luks";
name = "main";
extraOpenArgs = [ "--allow-discards" ];
passwordFile = lib.mkDefault "/tmp/secret.key";
askPassword = false;
settings = {
  allowDiscards = true;
};

So usually you provide a passwordFile and when booting you just type that password.

However, for VM tests you want to unlock this luks partition non-interactively. So you:

  • Create a systemd service that provides /tmp/secret.key during boot
  • Set settings.keyFile = "/tmp/secret.key so that cryptsetup uses the keyFile to unlock the partition

So I expected this to work:

disko.tests.extraConfig = {
  disko.devices.disk.main.content.partitions.main.content.settings.keyFile = "/tmp/secret.key";
};

While nix repl does show:

nix repl .
Nix 2.31.2+1
Type :? for help.
warning: Git tree '/home/jonathan/git/DSEE/NIXOS/disko-reprex' is dirty
Loading installable 'git+file:///home/jonathan/git/DSEE/NIXOS/disko-reprex#'...
Added 1 variables.
nixosConfigurations
nix-repl> nixosConfigurations.test.config.virtualisation.vmVariantWithDisko.boot.initrd.luks.devices.main.keyFile
"/tmp/secret.key"

Running

❯ nix run github:nix-community/nixos-anywhere -- \
  --flake .#test \
  --vm-test

Will stop at the interactive password prompt.

With this PR, it will respect the keyFile setting correctly and auto-unlock.

See #1185 for a reproducible example.

@Enzime
Copy link
Copy Markdown
Member

Enzime commented Jan 2, 2026

This looks like the same changes I made in #480 however I think the correct approach is #1094 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants