Open cfitz25 opened 7 months ago
hmm, not really. I guess you would need to get the disk data into nix first and then do some detection on it. Another possibility would be to generate multiple different disko configs and execute a different one depending on a script you write yourself. Something like:
environment.systemPackages = [
(pkgs.writeScriptBin "multidisko" ''
device_to_format=$1
if [ $(fdisk -x "$device_to_format" | grep '[0-9]* bytes, | sed 's/ bytes,//') -lt 1000000 ]; then
${nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
{ disko.devices = {
disk = {
device = "$device_to_format"; #not sure if this works, it should in theory
content = {
type = "filesystem";
format = "ext4";
mountpoint = "/";
};
};
};
];
}.config.system.build.diskoScript}
else
${nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
{ disko.devices = {
disk = {
device = "$device_to_format"; #not sure if this works, it should in theory
content = {
type = "filesystem";
format = "xfs";
mountpoint = "/";
};
};
};
];
}.config.system.build.diskoScript}
fi
'')
];
This would become feasible with #789
Would it be possible to set a drive size with a minimum and a maximum value? This would make it easier to use the same disko layout on different drive/partition sizes. eg, for separate /nix partition of 100GB on a 1TB+ drive but 10GB on a smaller VM drive