2022-07-10 10:39:47 +03:00
|
|
|
import <nixpkgs/nixos/tests/make-test-python.nix> ({ pkgs, ... }: let
|
2018-08-05 12:45:15 +03:00
|
|
|
|
|
|
|
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";
|
2022-07-08 14:49:58 +03:00
|
|
|
size = "10M";
|
2018-08-05 12:45:15 +03:00
|
|
|
content = {
|
|
|
|
type = "filesystem";
|
|
|
|
format = "ext4";
|
|
|
|
mountpoint = "/home";
|
|
|
|
};
|
|
|
|
};
|
2022-07-08 14:49:58 +03:00
|
|
|
raw = {
|
|
|
|
type = "lv";
|
|
|
|
size = "10M";
|
|
|
|
content = {
|
|
|
|
type = "noop";
|
|
|
|
};
|
|
|
|
};
|
2018-08-05 12:45:15 +03:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
in {
|
|
|
|
name = "disko";
|
|
|
|
|
2022-07-10 10:39:47 +03:00
|
|
|
nodes.machine =
|
2018-08-05 12:45:15 +03:00
|
|
|
{ config, pkgs, ... }:
|
|
|
|
|
|
|
|
{
|
|
|
|
imports = [
|
|
|
|
<nixpkgs/nixos/modules/profiles/installation-device.nix>
|
|
|
|
<nixpkgs/nixos/modules/profiles/base.nix>
|
|
|
|
];
|
|
|
|
|
|
|
|
virtualisation.emptyDiskImages = [ 512 ];
|
|
|
|
};
|
|
|
|
|
|
|
|
testScript =
|
|
|
|
''
|
2022-07-10 10:39:47 +03:00
|
|
|
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)}");
|
|
|
|
machine.succeed("test -b /dev/mapper/pool-raw");
|
2018-08-05 12:45:15 +03:00
|
|
|
'';
|
|
|
|
|
|
|
|
})
|