-
-
Save cleverca22/43f098096007c332a3f1409a8b38bafa to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"customdata": { | |
"cpr_storage": { | |
"disks": [ | |
{ | |
"device": "/dev/sdd", | |
"partitions": [ | |
{ | |
"label": "BIOS", | |
"number": 1, | |
"size": "512M" | |
}, | |
{ | |
"label": "SWAP", | |
"number": 2, | |
"size": "4G" | |
}, | |
{ | |
"label": "POOL", | |
"number": 3, | |
"size": 0 | |
} | |
] | |
} | |
], | |
"filesystems": [ | |
{ | |
"mount": { | |
"create": { | |
"options": [ | |
"32", | |
"-n", | |
"EFI" | |
] | |
}, | |
"device": "/dev/sdd1", | |
"format": "vfat", | |
"point": "/boot" | |
} | |
}, | |
{ | |
"mount": { | |
"create": { | |
"options": [ | |
"-L", | |
"SWAP" | |
] | |
}, | |
"device": "/dev/sdd2", | |
"format": "swap", | |
"point": "none" | |
} | |
} | |
] | |
}, | |
"cpr_zfs": { | |
"datasets": { | |
"tank/home": { | |
"properties": { | |
"mountpoint": "legacy" | |
} | |
}, | |
"tank/nix": { | |
"properties": { | |
"com.sun:auto-snapshot": "false", | |
"mountpoint": "legacy" | |
} | |
}, | |
"tank/root": { | |
"properties": { | |
"mountpoint": "legacy" | |
} | |
}, | |
"tank/var": { | |
"properties": { | |
"mountpoint": "legacy" | |
} | |
} | |
}, | |
"mounts": [ | |
{ | |
"dataset": "tank/root", | |
"point": "/" | |
}, | |
{ | |
"dataset": "tank/nix", | |
"point": "/nix" | |
}, | |
{ | |
"dataset": "tank/var", | |
"point": "/var" | |
}, | |
{ | |
"dataset": "tank/home", | |
"point": "/home" | |
} | |
], | |
"pools": { | |
"tank": { | |
"pool_properties": { | |
"ashift": "12" | |
}, | |
"vdevs": [ | |
{ | |
"disk": [ | |
"/dev/sda", | |
"/dev/sdb", | |
"/dev/sdc", | |
"/dev/sdd3" | |
] | |
} | |
] | |
} | |
} | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
with import <nixpkgs> {}; | |
let | |
createSystem = { disks, vdevs }: { | |
customdata = { | |
cpr_storage = { | |
inherit disks; | |
filesystems = [ | |
{ | |
mount = { | |
device = "/dev/sdd1"; | |
format = "vfat"; | |
point = "/boot"; | |
create.options = [ "32" "-n" "EFI" ]; | |
}; | |
} | |
{ | |
mount = { | |
device = "/dev/sdd2"; | |
format = "swap"; | |
point = "none"; | |
create.options = [ "-L" "SWAP" ]; | |
}; | |
} | |
]; | |
}; | |
cpr_zfs = { | |
pools = { | |
tank = { | |
pool_properties = { | |
ashift = "12"; # 4kbyte block size | |
}; | |
inherit vdevs; | |
}; | |
}; | |
datasets = let | |
common = { | |
properties.mountpoint = "legacy"; | |
}; | |
in { | |
"tank/root" = common; | |
"tank/nix" = lib.recursiveUpdate common { properties."com.sun:auto-snapshot" = "false"; }; | |
"tank/home" = common; | |
"tank/var" = common; | |
}; | |
mounts = let | |
fn = prefix: { dataset = "tank/${prefix}"; point = "/${prefix}"; }; | |
in [ | |
{ dataset = "tank/root"; point = "/"; } | |
(fn "nix") | |
(fn "var") | |
(fn "home") | |
]; | |
}; | |
}; | |
}; | |
mkPrimaryDisk = { efi ? true, legacy ? false, swapSize ? "4G", device }: { | |
device = "/dev/${device}"; | |
partitions = [ | |
{ label = "BIOS"; number = 1; size = "512M"; } | |
{ label = "SWAP"; number = 2; size = swapSize; } | |
{ label = "POOL"; number = 3; size = 0; } | |
]; | |
}; | |
hydra-master = createSystem { | |
disks = [ | |
(mkPrimaryDisk { device = "sdd"; }) | |
]; | |
vdevs = [ | |
{ | |
raidz1 = [ "/dev/sda" "/dev/sdb" "/dev/sdc" "/dev/sdd3" ]; | |
} | |
]; | |
}; | |
hydra-build-machine = createSystem { | |
disks = [ | |
(mkPrimaryDisk { device = "sdd"; }) | |
]; | |
vdevs = [ | |
{ | |
disk = [ "/dev/sda" "/dev/sdb" "/dev/sdc" "/dev/sdd3" ]; | |
} | |
]; | |
}; | |
prettyJSON = object: builtins.toFile "temp.json" (builtins.toJSON object); | |
machines = { | |
inherit hydra-master; | |
build1 = hydra-build-machine; | |
}; | |
generateOutput = machines: let | |
fn = name: obj: "jq . -S < ${prettyJSON obj} > ${name}.json"; | |
scripts = lib.concatStringsSep "\n" (lib.mapAttrsFlatten fn machines); | |
in runCommand "output" { buildInputs = [ jq ]; preferLocalBuild = true; } '' | |
mkdir $out | |
cd $out | |
${scripts} | |
''; | |
in | |
generateOutput machines |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"customdata": { | |
"cpr_storage": { | |
"disks": [ | |
{ | |
"device": "/dev/sdd", | |
"partitions": [ | |
{ | |
"label": "BIOS", | |
"number": 1, | |
"size": "512M" | |
}, | |
{ | |
"label": "SWAP", | |
"number": 2, | |
"size": "4G" | |
}, | |
{ | |
"label": "POOL", | |
"number": 3, | |
"size": 0 | |
} | |
] | |
} | |
], | |
"filesystems": [ | |
{ | |
"mount": { | |
"create": { | |
"options": [ | |
"32", | |
"-n", | |
"EFI" | |
] | |
}, | |
"device": "/dev/sdd1", | |
"format": "vfat", | |
"point": "/boot" | |
} | |
}, | |
{ | |
"mount": { | |
"create": { | |
"options": [ | |
"-L", | |
"SWAP" | |
] | |
}, | |
"device": "/dev/sdd2", | |
"format": "swap", | |
"point": "none" | |
} | |
} | |
] | |
}, | |
"cpr_zfs": { | |
"datasets": { | |
"tank/home": { | |
"properties": { | |
"mountpoint": "legacy" | |
} | |
}, | |
"tank/nix": { | |
"properties": { | |
"com.sun:auto-snapshot": "false", | |
"mountpoint": "legacy" | |
} | |
}, | |
"tank/root": { | |
"properties": { | |
"mountpoint": "legacy" | |
} | |
}, | |
"tank/var": { | |
"properties": { | |
"mountpoint": "legacy" | |
} | |
} | |
}, | |
"mounts": [ | |
{ | |
"dataset": "tank/root", | |
"point": "/" | |
}, | |
{ | |
"dataset": "tank/nix", | |
"point": "/nix" | |
}, | |
{ | |
"dataset": "tank/var", | |
"point": "/var" | |
}, | |
{ | |
"dataset": "tank/home", | |
"point": "/home" | |
} | |
], | |
"pools": { | |
"tank": { | |
"pool_properties": { | |
"ashift": "12" | |
}, | |
"vdevs": [ | |
{ | |
"raidz1": [ | |
"/dev/sda", | |
"/dev/sdb", | |
"/dev/sdc", | |
"/dev/sdd3" | |
] | |
} | |
] | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment