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 = {
|
||||
one = {
|
||||
type = "disk";
|
||||
|
@ -1,4 +1,4 @@
|
||||
{ disks ? [ "/dev/vdb" ] }: {
|
||||
{ disks ? [ "/dev/vdb" ], ... }: {
|
||||
disk = {
|
||||
vdb = {
|
||||
type = "disk";
|
||||
|
@ -1,4 +1,4 @@
|
||||
{ disks ? [ "/dev/vdb" "/dev/vdc" ] }: {
|
||||
{ disks ? [ "/dev/vdb" "/dev/vdc" ], ... }: {
|
||||
disk = {
|
||||
disk0 = {
|
||||
type = "disk";
|
||||
|
@ -1,5 +1,5 @@
|
||||
# Example to create a bios compatible gpt partition
|
||||
{ disks ? [ "/dev/vdb" ] }: {
|
||||
{ disks ? [ "/dev/vdb" ], ... }: {
|
||||
disk = {
|
||||
vdb = {
|
||||
device = builtins.elemAt disks 0;
|
||||
|
@ -1,4 +1,4 @@
|
||||
{ disks ? [ "/dev/vdb" ] }: {
|
||||
{ disks ? [ "/dev/vdb" ], ... }: {
|
||||
disk = {
|
||||
vdb = {
|
||||
type = "disk";
|
||||
|
@ -1,4 +1,4 @@
|
||||
{ disks ? [ "/dev/vdb" "/dev/vdc" ] }: {
|
||||
{ disks ? [ "/dev/vdb" "/dev/vdc" ], ... }: {
|
||||
disk = {
|
||||
one = {
|
||||
type = "disk";
|
||||
|
@ -1,4 +1,4 @@
|
||||
{ disks ? [ "/dev/vdb" "/dev/vdc" ] }: {
|
||||
{ disks ? [ "/dev/vdb" "/dev/vdc" ], ... }: {
|
||||
disk = {
|
||||
vdb = {
|
||||
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 = {
|
||||
vdb = {
|
||||
type = "disk";
|
||||
|
@ -1,4 +1,4 @@
|
||||
{ disks ? [ "/dev/vdb" "/dev/vdc" ] }: {
|
||||
{ disks ? [ "/dev/vdb" "/dev/vdc" ], ... }: {
|
||||
disk = {
|
||||
x = {
|
||||
type = "disk";
|
||||
|
@ -21,10 +21,10 @@
|
||||
inherit (pkgs) system;
|
||||
};
|
||||
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-mount = pkgs.writeScript "mount" ((pkgs.callPackage ../. { }).mount (disko-config { disks = builtins.tail disks; }));
|
||||
tsp-config = (pkgs.callPackage ../. { }).config (disko-config { inherit disks; });
|
||||
num-disks = builtins.length (lib.attrNames (disko-config {}).disk);
|
||||
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; inherit lib; }));
|
||||
tsp-config = (pkgs.callPackage ../. { }).config (disko-config { inherit disks; inherit lib; });
|
||||
num-disks = builtins.length (lib.attrNames (disko-config { inherit lib; }).disk);
|
||||
installed-system = { modulesPath, ... }: {
|
||||
imports = [
|
||||
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