1 { system ? builtins.currentSystem
3 , pkgs ? import ../.. { inherit system config; }
5 , testing ? import ../lib/testing-python.nix { inherit system pkgs; }
8 secretInStore = pkgs.writeText "topsecret" "iamasecret";
9 testWithCompressor = compressor: testing.makeTest {
10 name = "initrd-secrets-${compressor}";
12 meta.maintainers = [ ];
14 nodes.machine = { ... }: {
15 virtualisation.useBootLoader = true;
16 boot.initrd.secrets = {
17 "/test" = secretInStore;
19 # This should *not* need to be copied in postMountCommands
20 "/run/keys/test" = secretInStore;
22 boot.initrd.postMountCommands = ''
23 cp /test /mnt-root/secret-from-initramfs
25 boot.initrd.compressor = compressor;
26 # zstd compression is only supported from 5.9 onwards. Remove when 5.10 becomes default.
27 boot.kernelPackages = pkgs.linuxPackages_latest;
32 machine.wait_for_unit("multi-user.target")
34 "cmp ${secretInStore} /secret-from-initramfs",
35 "cmp ${secretInStore} /run/keys/test",
39 in lib.flip lib.genAttrs testWithCompressor [
40 "cat" "gzip" "bzip2" "xz" "lzma" "lzop" "pigz" "pixz" "zstd"