From bcb3f2afb5cbbf4f61c6d41d9b0bcc368dfb2edf Mon Sep 17 00:00:00 2001 From: Scott Edlund Date: Tue, 24 Jun 2025 03:08:28 +0800 Subject: [PATCH] make-disk-image: pre/post-format-files copies content of source path --- docs/disko-images.md | 14 +++++++------- lib/make-disk-image.nix | 12 ++++++------ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/docs/disko-images.md b/docs/disko-images.md index 7d1bd5b7..0793307f 100644 --- a/docs/disko-images.md +++ b/docs/disko-images.md @@ -71,15 +71,15 @@ In the this example we create a flake containing a nixos configuration for Options: * --pre-format-files - copies the src to the dst on the VM, before disko is run - This is useful to provide secrets like LUKS keys, or other files you need for formatting + copies the content of path to path on the VM, before disko is run. + This is useful to provide secrets like LUKS keys, or other files you need for formatting. * --post-format-files - copies the src to the dst on the finished image - These end up in the images later and is useful if you want to add some extra stateful files - They will have the same permissions but will be owned by root:root + copies the content of path to path on the finished image. + These end up in the images later and is useful if you want to add some extra stateful files. + They will have the same permissions but will be owned by root:root . * --build-memory - specify the amount of memory in MiB that gets allocated to the build VM - This can be useful if you want to build images with a more involed NixOS config + specify the amount of memory in MiB that gets allocated to the build VM. + This can be useful if you want to build images with a more involed NixOS config. The default is 1024 MiB ``` diff --git a/lib/make-disk-image.nix b/lib/make-disk-image.nix index ef527457..a37ba098 100644 --- a/lib/make-disk-image.nix +++ b/lib/make-disk-image.nix @@ -207,13 +207,13 @@ in --pre-format-files) src=$2 dst=$3 - cp --reflink=auto -r "$src" copy_before_disko/"$(echo "$dst" | base64)" + cp --reflink=auto -rv "$src" copy_before_disko/"$(echo "$dst" | base64)" shift 2 ;; --post-format-files) src=$2 dst=$3 - cp --reflink=auto -r "$src" copy_after_disko/"$(echo "$dst" | base64)" + cp --reflink=auto -rv "$src" copy_after_disko/"$(echo "$dst" | base64)" shift 2 ;; --build-memory) @@ -243,8 +243,8 @@ in for src in /tmp/xchg/copy_before_disko/*; do [ -e "$src" ] || continue dst=$(basename "$src" | base64 -d) - mkdir -p "$(dirname "$dst")" - cp -r "$src" "$dst" + mkdir -p "$dst" + cp -rv "$src"/. "$dst" done set -f ${partitioner} @@ -252,8 +252,8 @@ in for src in /tmp/xchg/copy_after_disko/*; do [ -e "$src" ] || continue dst=/mnt/$(basename "$src" | base64 -d) - mkdir -p "$(dirname "$dst")" - cp -r "$src" "$dst" + mkdir -p "$dst" + cp -rv "$src"/. "$dst" done ${installer} ''}