From bb455452a10edc9294f4f8e34b62bf01e9906c0a Mon Sep 17 00:00:00 2001 From: Mark Nipper Date: Fri, 3 May 2024 00:24:31 -0700 Subject: Add skip option --- scripts/install-with-disko | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) (limited to 'scripts/install-with-disko') diff --git a/scripts/install-with-disko b/scripts/install-with-disko index 7ae4e8e..a6210b9 100755 --- a/scripts/install-with-disko +++ b/scripts/install-with-disko @@ -1,6 +1,12 @@ #!/usr/bin/env nix-shell #!nix-shell -i zsh --packages rsync zsh +# load module to parse command line arguments +zmodload zsh/zutil + +# parse any possible additional drive declarations +zparseopts -D -E -A opts -- -skip-disko h + setopt ERR_EXIT NO_UNSET PIPE_FAIL DIR="${0:h}" @@ -62,15 +68,22 @@ echo if [[ "${REPLY}" == "y" ]]; then sudo true - sudo nix run github:nix-community/disko \ - --extra-experimental-features "nix-command flakes" \ - --no-write-lock-file \ - -- \ - --mode zap_create_mount \ - "${DIR}/../hosts/${TARGET_HOST}/disks.nix" + + if (( ! ${+opts[--skip-disko]} )); then + sudo nix run github:nix-community/disko \ + --extra-experimental-features "nix-command flakes" \ + --no-write-lock-file \ + -- \ + --mode zap_create_mount \ + "${DIR}/../hosts/${TARGET_HOST}/disks.nix" + fi # rsync NixOS configuration to target host file system and install the system - sudo mkdir -p /mnt/etc/nixos + + if [[ ! -d /mnt/etc/nixos ]]; then + sudo mkdir -p /mnt/etc/nixos + fi + sudo rsync -a --delete --exclude .git "${DIR}/.." /mnt/etc/nixos cd /mnt/etc/nixos sudo nixos-install --flake ".#${TARGET_HOST}" -- cgit v1.2.3