diff options
author | lassulus <lassulus@lassul.us> | 2018-08-05 11:45:15 +0200 |
---|---|---|
committer | lassulus <lassulus@lassul.us> | 2018-08-05 11:45:15 +0200 |
commit | 88f56a0b644dd7bfa8438409bea5377adef6aef4 (patch) | |
tree | 1fbfb44fea3825e4040088617e640b7735d03fe6 /tests | |
parent | fab04d2a5ec073b8ddf9bd02b39be33e483837d3 (diff) |
add nixos test
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test.nix | 97 |
1 files changed, 97 insertions, 0 deletions
diff --git a/tests/test.nix b/tests/test.nix new file mode 100644 index 0000000..0f875e6 --- /dev/null +++ b/tests/test.nix @@ -0,0 +1,97 @@ +import <nixpkgs/nixos/tests/make-test.nix> ({ pkgs, ... }: let + + disko-config = { + type = "devices"; + content = { + vdb = { + type = "table"; + format = "gpt"; + partitions = [ + { + type = "partition"; + part-type = "ESP"; + start = "1MiB"; + end = "100MiB"; + fs-type = "FAT32"; + bootable = true; + content = { + type = "filesystem"; + format = "vfat"; + mountpoint = "/boot"; + options = [ + "defaults" + ]; + }; + } + { + type = "partition"; + part-type = "primary"; + start = "100MiB"; + end = "100%"; + content = { + type = "luks"; + algo = "aes-xts..."; + name = "crypted"; + keyfile = "/tmp/secret.key"; + extraArgs = [ + "--hash sha512" + "--iter-time 5000" + ]; + content = { + type = "lvm"; + name = "pool"; + lvs = { + root = { + type = "lv"; + size = "100M"; + mountpoint = "/"; + content = { + type = "filesystem"; + format = "ext4"; + mountpoint = "/"; + options = [ + "defaults" + ]; + }; + }; + home = { + type = "lv"; + size = "100M"; + content = { + type = "filesystem"; + format = "ext4"; + mountpoint = "/home"; + }; + }; + }; + }; + }; + } + ]; + }; + }; + }; + +in { + name = "disko"; + + machine = + { config, pkgs, ... }: + + { + imports = [ + <nixpkgs/nixos/modules/profiles/installation-device.nix> + <nixpkgs/nixos/modules/profiles/base.nix> + ]; + + virtualisation.emptyDiskImages = [ 512 ]; + }; + + testScript = + '' + $machine->succeed("echo 'secret' > /tmp/secret.key"); + $machine->succeed("${pkgs.writeScript "create" ((import ../lib).create disko-config)}"); + $machine->succeed("${pkgs.writeScript "mount" ((import ../lib).mount disko-config)}"); + ''; + +}) |