mirror of
https://github.com/nix-community/disko.git
synced 2024-11-04 05:44:29 +03:00
tests: pass lib to examples
This commit is contained in:
parent
c96ccd7d9f
commit
8666475b74
@ -1,4 +1,4 @@
|
|||||||
{ disks ? [ "/dev/vdb" "/dev/vdc" ] }: {
|
{ disks ? [ "/dev/vdb" "/dev/vdc" ], ... }: {
|
||||||
disk = {
|
disk = {
|
||||||
one = {
|
one = {
|
||||||
type = "disk";
|
type = "disk";
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
{ disks ? [ "/dev/vdb" ] }: {
|
{ disks ? [ "/dev/vdb" ], ... }: {
|
||||||
disk = {
|
disk = {
|
||||||
vdb = {
|
vdb = {
|
||||||
type = "disk";
|
type = "disk";
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
{ disks ? [ "/dev/vdb" "/dev/vdc" ] }: {
|
{ disks ? [ "/dev/vdb" "/dev/vdc" ], ... }: {
|
||||||
disk = {
|
disk = {
|
||||||
disk0 = {
|
disk0 = {
|
||||||
type = "disk";
|
type = "disk";
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
# Example to create a bios compatible gpt partition
|
# Example to create a bios compatible gpt partition
|
||||||
{ disks ? [ "/dev/vdb" ] }: {
|
{ disks ? [ "/dev/vdb" ], ... }: {
|
||||||
disk = {
|
disk = {
|
||||||
vdb = {
|
vdb = {
|
||||||
device = builtins.elemAt disks 0;
|
device = builtins.elemAt disks 0;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
{ disks ? [ "/dev/vdb" ] }: {
|
{ disks ? [ "/dev/vdb" ], ... }: {
|
||||||
disk = {
|
disk = {
|
||||||
vdb = {
|
vdb = {
|
||||||
type = "disk";
|
type = "disk";
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
{ disks ? [ "/dev/vdb" "/dev/vdc" ] }: {
|
{ disks ? [ "/dev/vdb" "/dev/vdc" ], ... }: {
|
||||||
disk = {
|
disk = {
|
||||||
one = {
|
one = {
|
||||||
type = "disk";
|
type = "disk";
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
{ disks ? [ "/dev/vdb" "/dev/vdc" ] }: {
|
{ disks ? [ "/dev/vdb" "/dev/vdc" ], ... }: {
|
||||||
disk = {
|
disk = {
|
||||||
vdb = {
|
vdb = {
|
||||||
type = "disk";
|
type = "disk";
|
||||||
|
35
example/with-lib.nix
Normal file
35
example/with-lib.nix
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
# Example to create a bios compatible gpt partition
|
||||||
|
{ disks ? [ "/dev/vdb" ], lib, ... }: {
|
||||||
|
disk = lib.traceValSeq (lib.genAttrs [ (lib.head disks) ] (device: {
|
||||||
|
device = device;
|
||||||
|
type = "disk";
|
||||||
|
content = {
|
||||||
|
type = "table";
|
||||||
|
format = "gpt";
|
||||||
|
partitions = [
|
||||||
|
{
|
||||||
|
name = "boot";
|
||||||
|
type = "partition";
|
||||||
|
start = "0";
|
||||||
|
end = "1M";
|
||||||
|
part-type = "primary";
|
||||||
|
flags = ["bios_grub"];
|
||||||
|
}
|
||||||
|
{
|
||||||
|
name = "root";
|
||||||
|
type = "partition";
|
||||||
|
# leave space for the grub aka BIOS boot
|
||||||
|
start = "1M";
|
||||||
|
end = "100%";
|
||||||
|
part-type = "primary";
|
||||||
|
bootable = true;
|
||||||
|
content = {
|
||||||
|
type = "filesystem";
|
||||||
|
format = "ext4";
|
||||||
|
mountpoint = "/";
|
||||||
|
};
|
||||||
|
}
|
||||||
|
];
|
||||||
|
};
|
||||||
|
}));
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
{ disks ? [ "/dev/vdb" "/dev/vdc" ] }: {
|
{ disks ? [ "/dev/vdb" "/dev/vdc" ], ... }: {
|
||||||
disk = {
|
disk = {
|
||||||
vdb = {
|
vdb = {
|
||||||
type = "disk";
|
type = "disk";
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
{ disks ? [ "/dev/vdb" "/dev/vdc" ] }: {
|
{ disks ? [ "/dev/vdb" "/dev/vdc" ], ... }: {
|
||||||
disk = {
|
disk = {
|
||||||
x = {
|
x = {
|
||||||
type = "disk";
|
type = "disk";
|
||||||
|
@ -21,10 +21,10 @@
|
|||||||
inherit (pkgs) system;
|
inherit (pkgs) system;
|
||||||
};
|
};
|
||||||
disks = [ "/dev/vda" "/dev/vdb" "/dev/vdc" "/dev/vdd" "/dev/vde" "/dev/vdf" ];
|
disks = [ "/dev/vda" "/dev/vdb" "/dev/vdc" "/dev/vdd" "/dev/vde" "/dev/vdf" ];
|
||||||
tsp-create = pkgs.writeScript "create" ((pkgs.callPackage ../. { }).create (disko-config { disks = builtins.tail disks; }));
|
tsp-create = pkgs.writeScript "create" ((pkgs.callPackage ../. { }).create (disko-config { disks = builtins.tail disks; inherit lib; }));
|
||||||
tsp-mount = pkgs.writeScript "mount" ((pkgs.callPackage ../. { }).mount (disko-config { disks = builtins.tail disks; }));
|
tsp-mount = pkgs.writeScript "mount" ((pkgs.callPackage ../. { }).mount (disko-config { disks = builtins.tail disks; inherit lib; }));
|
||||||
tsp-config = (pkgs.callPackage ../. { }).config (disko-config { inherit disks; });
|
tsp-config = (pkgs.callPackage ../. { }).config (disko-config { inherit disks; inherit lib; });
|
||||||
num-disks = builtins.length (lib.attrNames (disko-config {}).disk);
|
num-disks = builtins.length (lib.attrNames (disko-config { inherit lib; }).disk);
|
||||||
installed-system = { modulesPath, ... }: {
|
installed-system = { modulesPath, ... }: {
|
||||||
imports = [
|
imports = [
|
||||||
tsp-config
|
tsp-config
|
||||||
|
11
tests/with-lib.nix
Normal file
11
tests/with-lib.nix
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
{ pkgs ? (import <nixpkgs> { })
|
||||||
|
, makeDiskoTest ? (pkgs.callPackage ./lib.nix { }).makeDiskoTest
|
||||||
|
}:
|
||||||
|
makeDiskoTest {
|
||||||
|
disko-config = import ../example/with-lib.nix;
|
||||||
|
extraTestScript = ''
|
||||||
|
machine.succeed("mountpoint /");
|
||||||
|
'';
|
||||||
|
efi = false;
|
||||||
|
grub-devices = [ "/dev/vdb" ];
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user