add test for lvm example

This commit is contained in:
Jörg Thalheim 2022-09-04 12:44:38 +02:00
parent 3e48d1fd85
commit 65bd5a97f8
2 changed files with 72 additions and 56 deletions

View File

@ -1,67 +1,74 @@
# usage: nix-instantiate --eval --json --strict example/config.nix | jq . # usage: nix-instantiate --eval --json --strict example/config.nix | jq .
{ {
type = "devices"; lvm_vg = {
content = { pool = {
sda = { type = "lvm_vg";
type = "table"; lvs = {
format = "gpt"; root = {
partitions = [ type = "lv";
{ size = "10G";
type = "partition";
part-type = "ESP";
start = "1MiB";
end = "1024MiB";
fs-type = "fat32";
bootable = true;
content = { content = {
type = "filesystem"; type = "filesystem";
format = "vfat"; format = "ext4";
mountpoint = "/boot"; mountpoint = "/";
}; };
} };
{ home = {
type = "partition"; type = "lv";
part-type = "primary"; size = "10G";
start = "1024MiB";
end = "100%";
flags = [ "bios_grub" ];
content = { content = {
type = "luks"; type = "filesystem";
algo = "aes-xts..."; format = "ext4";
name = "crypted"; mountpoint = "/home";
keyfile = "/tmp/secret.key"; };
extraArgs = [ };
"--hash sha512" };
"--iter-time 5000" };
]; };
disk = {
sda = {
device = "/dev/sda";
content = {
type = "table";
format = "gpt";
partitions = [
{
name = "boot";
type = "partition";
part-type = "ESP";
start = "1MiB";
end = "1024MiB";
fs-type = "fat32";
bootable = true;
content = { content = {
type = "lvm"; type = "filesystem";
name = "pool"; format = "vfat";
lvs = { mountpoint = "/boot";
root = { };
type = "lv"; }
size = "10G"; {
mountpoint = "/"; name = "crypt_root";
content = { type = "partition";
type = "filesystem"; part-type = "primary";
format = "ext4"; start = "1024MiB";
mountpoint = "/"; end = "100%";
}; flags = ["bios_grub"];
}; content = {
home = { type = "luks";
type = "lv"; name = "crypted";
size = "10G"; keyFile = "/tmp/secret.key";
content = { extraArgs = [
type = "filesystem"; "--hash sha512"
format = "ext4"; "--iter-time 5000"
mountpoint = "/home"; ];
}; content = {
}; type = "lvm_pv";
vg = "pool";
}; };
}; };
}; }
} ];
]; };
}; };
}; };
} }

View File

@ -4,6 +4,14 @@
let let
lib = pkgs.lib; lib = pkgs.lib;
makeDiskoTest = (pkgs.callPackage ./lib.nix { inherit makeTest; }).makeDiskoTest; makeDiskoTest = (pkgs.callPackage ./lib.nix { inherit makeTest; }).makeDiskoTest;
evalTest = name: configFile: let
disko-config = import configFile;
in {
"${name}-tsp-create" = pkgs.writeScript "create" ((pkgs.callPackage ../. { }).create disko-config);
"${name}-tsp-mount" = pkgs.writeScript "mount" ((pkgs.callPackage ../. { }).mount disko-config);
};
allTestFilenames = allTestFilenames =
builtins.map (lib.removeSuffix ".nix") ( builtins.map (lib.removeSuffix ".nix") (
builtins.filter builtins.filter
@ -11,6 +19,7 @@ let
(lib.attrNames (builtins.readDir ./.)) (lib.attrNames (builtins.readDir ./.))
); );
allTests = lib.genAttrs (allTestFilenames) (test: import (./. + "/${test}.nix") { inherit makeDiskoTest; }); allTests = lib.genAttrs (allTestFilenames) (test: import (./. + "/${test}.nix") { inherit makeDiskoTest; }) //
evalTest "lvm-luks-example" ../example/config.nix;
in in
allTests allTests