1 { system ? builtins.currentSystem
3 , pkgs ? import ../.. { inherit system config; }
5 , testing ? import ../lib/testing-python.nix { inherit system pkgs; }
9 secret1InStore = pkgs.writeText "topsecret" "iamasecret1";
10 secret2InStore = pkgs.writeText "topsecret" "iamasecret2";
14 name = "initrd-secrets-changing";
16 nodes.machine = { ... }: {
17 virtualisation.useBootLoader = true;
19 boot.loader.grub.device = "/dev/vda";
21 boot.initrd.secrets = {
22 "/test" = secret1InStore;
23 "/run/keys/test" = secret1InStore;
25 boot.initrd.postMountCommands = "cp /test /mnt-root/secret-from-initramfs";
27 specialisation.secrets2System.configuration = {
28 boot.initrd.secrets = lib.mkForce {
29 "/test" = secret2InStore;
30 "/run/keys/test" = secret2InStore;
38 machine.wait_for_unit("multi-user.target")
39 print(machine.succeed("cat /run/keys/test"))
41 "cmp ${secret1InStore} /secret-from-initramfs",
42 "cmp ${secret1InStore} /run/keys/test",
44 # Select the second boot entry corresponding to the specialisation secrets2System.
45 machine.succeed("grub-reboot 1")
48 with subtest("Check that the specialisation's secrets are distinct despite identical kernels"):
49 machine.wait_for_unit("multi-user.target")
50 print(machine.succeed("cat /run/keys/test"))
52 "cmp ${secret2InStore} /secret-from-initramfs",
53 "cmp ${secret2InStore} /run/keys/test",