summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlassulus <lassulus@lassul.us>2022-11-23 13:28:52 +0100
committerlassulus <lassulus@lassul.us>2022-11-25 17:36:40 +0100
commit9cf4f170aefaf85d01cb1710c192f9f5b56ab694 (patch)
treedbbd68657463767ef2b7f273849d87c37ccbf9a0
parent417ad31ca5c149ff85bd5a4f61c81253e4906b65 (diff)
add zapCreateMount script for idempodents install from iso/kexec
-rw-r--r--cli.nix2
-rw-r--r--default.nix4
-rwxr-xr-xdisko4
-rw-r--r--types.nix20
4 files changed, 28 insertions, 2 deletions
diff --git a/cli.nix b/cli.nix
index e29b340..72a1c3c 100644
--- a/cli.nix
+++ b/cli.nix
@@ -16,6 +16,8 @@ let
disko.createScript diskFormat pkgs
else if (mode == "mount") then
disko.mountScript diskFormat pkgs
+ else if (mode = "zap_create_mount") then
+ disko.zapCreateMount diskFormat pkgs
else
builtins.abort "invalid mode"
;
diff --git a/default.nix b/default.nix
index 8d91e7c..03a6833 100644
--- a/default.nix
+++ b/default.nix
@@ -24,6 +24,10 @@ in {
export PATH=${lib.makeBinPath (types.diskoLib.packages (eval cfg).config.devices pkgs)}
${types.diskoLib.mount (eval cfg).config.devices}
'';
+ zapCreateMount = cfg: pkgs: pkgs.writeScript "disko-zap-create-mount" ''
+ export PATH=${lib.makeBinPath (types.diskoLib.packages (eval cfg).config.devices pkgs)}
+ ${types.diskoLib.zapCreateMount (eval cfg).config.devices}
+ '';
config = cfg: { imports = types.diskoLib.config (eval cfg).config.devices; };
packages = cfg: types.diskoLib.packages (eval cfg).config.devices;
}
diff --git a/disko b/disko
index d641304..a48907f 100755
--- a/disko
+++ b/disko
@@ -87,8 +87,8 @@ while [[ $# -gt 0 ]]; do
shift
done
-if ! ([[ $mode = "create" ]] || [[ $mode = "mount" ]]); then
- abort "mode must be either create or mount"
+if ! ([[ $mode = "create" ]] || [[ $mode = "mount" ]] || [[ $mode = "zap_create_mount" ]]); then
+ abort "mode must be either create, mount or zap_create_mount"
fi
if [[ ! -z "${flake+x}" ]]; then
diff --git a/types.nix b/types.nix
index e09ca9d..92f11fb 100644
--- a/types.nix
+++ b/types.nix
@@ -146,6 +146,26 @@ rec {
# ensures that "/" is processed before "/foo" etc.
${concatStrings (attrValues fsMounts)}
'';
+ /* takes a disko device specification and returns a string which unmounts, destroys all disks and then runs create and mount
+
+ zapCreateMount :: types.devices -> str
+ */
+ zapCreateMount = devices: ''
+ set -efux
+ # print existing disks
+ lsblk
+
+ # TODO get zap the same way we get create
+ # make partitioning idempotent by dismounting already mounted filesystems
+ if findmnt /mnt; then
+ umount -Rlv /mnt
+ fi
+
+ echo 'creating partitions...'
+ ${diskoLib.create devices}
+ echo 'mounting partitions...'
+ ${diskoLib.mount devices}
+ '';
/* Takes a disko device specification and returns a nixos configuration
config :: types.devices -> nixosConfig