mirror of
https://github.com/nix-community/disko.git
synced 2026-11-30 13:03:28 +01:00
Add disk.destroy option
This commit is contained in:
1 parent
c7e0b00007
commit
aa5d53aee8
2 files changed
+22
-3
No files matched your search
+17
-3
@@ -875,9 +875,17 @@ let
|
||||
umount -Rv "${rootMountPoint}" || :
|
||||
|
||||
# shellcheck disable=SC2043,2041
|
||||
for dev in ${toString (lib.catAttrs "device" (lib.attrValues devices.disk))}; do
|
||||
for dev in ${
|
||||
toString (
|
||||
lib.catAttrs "device" (
|
||||
lib.attrValues (lib.filterAttrs (name: disk: (disk.destroy or true)) devices.disk)
|
||||
)
|
||||
)
|
||||
};
|
||||
do
|
||||
$BASH ${../disk-deactivate}/disk-deactivate "$dev"
|
||||
done
|
||||
|
||||
'';
|
||||
};
|
||||
_destroy = lib.mkOption {
|
||||
@@ -888,7 +896,9 @@ let
|
||||
'';
|
||||
default =
|
||||
let
|
||||
selectedDisks = lib.escapeShellArgs (lib.catAttrs "device" (lib.attrValues devices.disk));
|
||||
selectedDisks = lib.escapeShellArgs (
|
||||
lib.catAttrs "device" (lib.filterAttrs (name: disk: (disk.destroy or true)) devices.disk)
|
||||
);
|
||||
in
|
||||
''
|
||||
if [ "$1" != "--yes-wipe-all-disks" ]; then
|
||||
@@ -913,7 +923,11 @@ let
|
||||
umount -Rv "${rootMountPoint}" || :
|
||||
|
||||
# shellcheck disable=SC2043,2041
|
||||
for dev in ${selectedDisks}; do
|
||||
for dev in ${
|
||||
toString (
|
||||
lib.catAttrs "device" (lib.filterAttrs (name: disk: (disk.destroy or true)) devices.disk)
|
||||
)
|
||||
}; do
|
||||
$BASH ${../disk-deactivate}/disk-deactivate "$dev"
|
||||
done
|
||||
'';
|
||||
|
||||
@@ -22,6 +22,11 @@
|
||||
type = diskoLib.optionTypes.absolute-pathname; # TODO check if subpath of /dev ? - No! eg: /.swapfile
|
||||
description = "Device path";
|
||||
};
|
||||
destroy = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
default = true;
|
||||
description = "If false, disko will not wipe or destroy this disk's contents during the destroy stage";
|
||||
};
|
||||
imageName = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = config.name;
|
||||
|
||||
Reference in new issue
Block a user