From 30441b1236a3f5e426b72ecf2ba2f4f91127ca0e Mon Sep 17 00:00:00 2001 From: DavHau Date: Fri, 21 Aug 2020 22:57:57 +0700 Subject: [PATCH] Improve providers fix dns (#58) * remove digitalocean as default; fix digitalocean dns; update channels fixes #53 fixes #49 * fix doNetConf check --- README.md | 6 +++--- nixos-infect | 11 +++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index ded257c..44e585a 100644 --- a/README.md +++ b/README.md @@ -49,7 +49,7 @@ cat and EOF in the Digital Ocean Web UI (or HTTP API): #cloud-config runcmd: - - curl https://raw.githubusercontent.com/elitak/nixos-infect/master/nixos-infect | PROVIDER=digitalocean NIX_CHANNEL=nixos-19.09 bash 2>&1 | tee /tmp/infect.log + - curl https://raw.githubusercontent.com/elitak/nixos-infect/master/nixos-infect | PROVIDER=digitalocean NIX_CHANNEL=nixos-20.03 bash 2>&1 | tee /tmp/infect.log ``` Potential tweaks: - `/etc/nixos/{,hardware-}configuration.nix`: rudimentary mostly static config @@ -67,7 +67,7 @@ write_files: environment.systemPackages = with pkgs; [ vim ]; } runcmd: - - curl https://raw.githubusercontent.com/elitak/nixos-infect/master/nixos-infect | PROVIDER=digitalocean NIXOS_IMPORT=./host.nix NIX_CHANNEL=nixos-19.09 bash 2>&1 | tee /tmp/infect.log + - curl https://raw.githubusercontent.com/elitak/nixos-infect/master/nixos-infect | PROVIDER=digitalocean NIXOS_IMPORT=./host.nix NIX_CHANNEL=nixos-20.03 bash 2>&1 | tee /tmp/infect.log ``` @@ -78,7 +78,7 @@ To set up a NixOS Vultr server, instantiate an Ubuntu box with the following "St ```bash #!/bin/sh -curl https://raw.githubusercontent.com/elitak/nixos-infect/master/nixos-infect | PROVIDER=vultr NIX_CHANNEL=nixos-19.09 bash +curl https://raw.githubusercontent.com/elitak/nixos-infect/master/nixos-infect | NIX_CHANNEL=nixos-20.03 bash ``` Allow for a few minutes over the usual Ubuntu deployment time for NixOS to download & install itself. diff --git a/nixos-infect b/nixos-infect index 960e49a..ae0f21a 100755 --- a/nixos-infect +++ b/nixos-infect @@ -18,7 +18,7 @@ makeConf() { done local network_import="" - [ "$PROVIDER" = "digitalocean" ] && network_import="./networking.nix # generated at runtime by nixos-infect" + [ ! -z "$doNetConf" ] && network_import="./networking.nix # generated at runtime by nixos-infect" cat > /etc/nixos/configuration.nix << EOF { ... }: { imports = [ @@ -46,7 +46,7 @@ EOF } EOF - if [ "$PROVIDER" = "digitalocean" ] + if [ ! -z "$doNetConf" ] then makeNetworkingConf else @@ -95,9 +95,7 @@ EOF # This file was populated at runtime with the networking # details gathered from the active system. networking = { - nameservers = [$(for a in "${nameservers[@]}"; do echo -n " - \"$a\""; done) - ]; + nameservers = [ "8.8.8.8" ]; defaultGateway = "${gateway}"; defaultGateway6 = "${gateway6}"; dhcpcd.enable = false; @@ -268,7 +266,8 @@ infect() { /nix/var/nix/profiles/system/bin/switch-to-configuration boot } -[ -z "$PROVIDER" ] && PROVIDER="digitalocean" # you may also prepend PROVIDER=vultr to your call instead +[ "$PROVIDER" = "digitalocean" ] && doNetConf=y # digitalocean requires detailed network config to be generated + prepareEnv makeSwap # smallest (512MB) droplet needs extra memory!