diff --git a/nixos-infect b/nixos-infect index 4e239ae..ed2b928 100755 --- a/nixos-infect +++ b/nixos-infect @@ -18,9 +18,13 @@ # This was last tested with the DigitalOcean Debian 8.3 x64 and Ubuntu 15.10 # x64 images. Different versions and archs (namely i386) should work as well, # but then, there's not much point in selecting something different if you -# intend to wipe out the fs, as this script does. You may need to make minor -# modifications to use in other templates, but basically all that will ever -# need tweaking are already inlined in this file: +# intend to wipe out the fs, as this script does. Some Ubuntu droplets have gpt +# partition tables but only a single ext4 root partition. It's way too much +# effort to try to get nixos to install grub using blocklists, so just avoid +# improperly configured images like those. +# +# You may need to make minor modifications to use in other templates, but +# basically all that will ever need tweaking are already inlined in this file: # /etc/nixos/{,hardware-}configuration.nix : rudimentary mostly static config # /etc/nixos/networking.nix, networking settings determined at runtime # tweak if no ipv6, different number of adapters, etc. @@ -36,11 +40,25 @@ set -ex -# If you have another nixos host in the cloud, add it here to speed up the +# If you have another NixOS host in the cloud, add it here to speed up the # package downloads. Use "ssh -A" with your key loaded to run the script! +# (also ssh-keygen -R the host so that agent forwarding isn't disabled) # This also reduces load on NixOS servers, so please make an effort to use it -# whenever possible. -#nix_options+=" --option ssh-substituter-hosts user@host" +# whenever possible. Better yet, just clone your VPS using snapshots. + +export NIX_CONF_DIR=`mktemp -d` +cat > $NIX_CONF_DIR/nix.conf << EOF +use-ssh-substituter = true +ssh-substituter-hosts = root@159.203.246.187 +EOF + +nixCmdOpts+=" --option use-ssh-substituter true" +nixCmdOpts+=" --option ssh-substituter-hosts root@159.203.246.187" +mkdir -p ~/.ssh; chmod 0700 ~/.ssh +echo StrictHostKeyChecking=no >> .ssh/config + +nixos_channel=nixos-unstable +#nixos_channel=nixos-16.03 makeConf() { # NB <<"EOF" quotes / $ ` in heredocs, <> /etc/resolv.conf; done source /nix/var/nix/profiles/system/etc/profile + # grub/initrd was probably installed incorrectly (using false root device), so we need a final rebuild # TODO see aszlig's comment in issue about not even having to call rebuild, just nix-build system or something; without ever having to use nixos-install either? and separate ext4fs? # man nixos-rebuild mentions this!!: nixos-rebuid build == nix-build /path/to/nixpkgs/nixos -A system -nixos-rebuild boot --install-grub +nixos-rebuild $nixCmdOpts boot --install-grub +#swapoff $swapFile && rm -f $swapFile || true sync echo "You may now Ctrl-C or otherwise terminate this process." reboot -f