Print a warning before formatting disks

This commit is contained in:
Manuel Thalmann 2024-07-06 23:07:18 +02:00
parent 6e9ff465dc
commit 4b42b9d849

View file

@ -49,6 +49,12 @@
internal = true;
};
deviceVariable = mkOption {
type = types.str;
description = "The name of the variable holding the name of the disk";
internal = true;
};
partitions = mkOption {
type = types.attrsOf (types.nullOr partitionType);
description = "The partitions of the disk.";
@ -169,6 +175,7 @@
partitions);
in {
id = if osDisk then "os" else "disk-${name}";
deviceVariable = diskVar;
deviceScript = if osDisk && config.devicePath == null then ''
${diskSelector}
@ -348,6 +355,10 @@
(_: "sudo swapon ${partPath _}")
(builtins.filter (_: _.useSwap) partitions));
in lib.strings.concatLines (
(builtins.map (_: _.deviceScript) disks) ++ lib.optional ((builtins.length disks) > 0) (
''echo "Continuing this script will wipe the contents of '' + (
lib.strings.concatStringsSep ", " (builtins.map (_: "${_.deviceVariable}") disks)
) + (if (builtins.length disks) > 1 then " and " else "") + (lib.lists.last disks).deviceVariable) ++
(builtins.map (_: _.script) disks) ++ [
mountScript
swapScript