Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions docs/disko-images.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,15 @@ In the this example we create a flake containing a nixos configuration for

Options:
* --pre-format-files <src> <dst>
copies the src to the dst on the VM, before disko is run
copies the content of path <src> to path <dst> 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 <src> <dst>
copies the src to the dst on the finished image
copies the content of path <src> to path <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
* --build-memory <amt>
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
This can be useful if you want to build images with a more involved NixOS config
The default is 1024 MiB
```

Expand Down
18 changes: 9 additions & 9 deletions lib/make-disk-image.nix
Original file line number Diff line number Diff line change
Expand Up @@ -179,15 +179,15 @@ in

Options:
* --pre-format-files <src> <dst>
copies the src to the dst on the VM, before disko is run
copies the content of path <src> to path <dst> 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 <src> <dst>
copies the src to the dst on the finished image
copies the content of path <src> to path <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
* --build-memory <amt>
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
This can be useful if you want to build images with a more involved NixOS config
The default is disko.memSize which defaults to ${builtins.toString options.disko.memSize.default} MiB
USAGE
}
Expand All @@ -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)
Expand Down Expand Up @@ -243,17 +243,17 @@ 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}
set +f
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"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this break if we someone used files instead of directories before? Was this supported even?

Copy link
Contributor Author

@sedlund sedlund Jul 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with a single file with original I get this:

./result --pre-format-files pre/secret.key /tmp
cp: cannot stat 'pre/secret.key': No such file or directory

ll pre/secret.key
.rw-r--r-- 12 sedlund 1 week  pre/secret.key

cp -rv "$src"/. "$dst"
done
${installer}
''}
Expand Down