From da8f61d2ff6dcd7e5632c721ea0679b955b85b01 Mon Sep 17 00:00:00 2001 From: Eric Litak Date: Tue, 14 Feb 2017 01:25:42 -0800 Subject: [PATCH] fix depchecking, skip conf regen, no more -x --- nixos-infect | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/nixos-infect b/nixos-infect index fc01455..f2acad3 100755 --- a/nixos-infect +++ b/nixos-infect @@ -13,10 +13,10 @@ # systems. # # WARNING NB This script wipes out the targeted host's root filesystem when it -# runs to completion. Any errors halt execution. set -x is used to help debug, -# as often a failed run leaves the system in an inconsistent state, requiring a -# rebuild (in DigitalOcean panel: Droplet Settings -> "Destroy" -> "Rebuild -# from original"). +# runs to completion. Any errors halt execution. It's advised to run with +# `bash -x` to help debug, as often a failed run leaves the system in an +# inconsistent state, requiring a rebuild (in DigitalOcean panel: Droplet +# Settings -> "Destroy" -> "Rebuild from original"). # # TO USE: # - Add any custom config you want (see notes below) @@ -45,9 +45,11 @@ # simply didn't work for me! (old system was being because grub wasnt properly # reinstalled) -set -ex -o pipefail +set -e -o pipefail makeConf() { + # Skip everything if main config already present + [[ -e /etc/nixos/configuration.nix ]] && return 0 # NB <<"EOF" quotes / $ ` in heredocs, <> /etc/NIXOS_LUSTRATE echo root/.nix-defexpr/channels >> /etc/NIXOS_LUSTRATE - rm -rf /boot.bak && mv -v /boot /boot.bak && \ - /nix/var/nix/profiles/system/bin/switch-to-configuration boot + rm -rf /boot.bak + mv -v /boot /boot.bak + /nix/var/nix/profiles/system/bin/switch-to-configuration boot } prepareEnv