Skip to content

Commit a54a9bd

Browse files
costowellMic92
authored andcommitted
feat: add option to set ownership of extraFiles
1 parent e8e5d63 commit a54a9bd

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/nixos-anywhere.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ trap 'rm -rf "$sshKeyDir"' EXIT
6060
mkdir -p "$sshKeyDir"
6161

6262
declare -A diskEncryptionKeys=()
63+
declare -A extraFilesOwnership=()
6364
declare -a nixCopyOptions=()
6465
declare -a sshArgs=()
6566

@@ -256,6 +257,11 @@ parseArgs() {
256257
extraFiles=$2
257258
shift
258259
;;
260+
--chown)
261+
extraFilesOwnership["$2"]="$3"
262+
shift
263+
shift
264+
;;
259265
--disk-encryption-keys)
260266
diskEncryptionKeys["$2"]="$3"
261267
shift
@@ -667,9 +673,15 @@ nixosInstall() {
667673
if [[ -n ${extraFiles} ]]; then
668674
step Copying extra files
669675
tar -C "$extraFiles" -cpf- . | runSsh "tar -C /mnt -xf- --no-same-owner"
676+
670677
runSsh "chmod 755 /mnt" # tar also changes permissions of /mnt
671678
fi
672679
680+
if [[ ${#extraFilesOwnership[@]} -gt 0 ]]; then
681+
# shellcheck disable=SC2016
682+
printf "%s\n" "${!extraFilesOwnership[@]}" "${extraFilesOwnership[@]}" | pr -2t | runSsh 'while read file ownership; do chown -R "$ownership" "/mnt/$file"; done'
683+
fi
684+
673685
step Installing NixOS
674686
runSsh sh <<SSH
675687
set -eu ${enableDebug}

0 commit comments

Comments
 (0)