mirror of
https://github.com/elitak/nixos-infect
synced 2024-11-10 05:54:20 +00:00
Support for Vultr
This commit is contained in:
parent
20853bf8d8
commit
5596ad166a
2 changed files with 41 additions and 7 deletions
37
README.md
37
README.md
|
@ -1,15 +1,25 @@
|
||||||
This script aims to install NixOS on Digital Ocean droplets
|
This script aims to install NixOS on Digital Ocean droplets, Vultr servers, or
|
||||||
(starting from one of the distros that Digital Ocean supports out of the box)
|
OVH Virtual Private Servers (starting from distros that these services upports
|
||||||
|
out of the box)
|
||||||
|
|
||||||
These are the only supported Digital Ocean images:
|
## Source Distros
|
||||||
|
|
||||||
|
This script has been tested and can install NixOS from the following source distros:
|
||||||
|
|
||||||
|
On Digital Ocean:
|
||||||
- Fedora 24 x64
|
- Fedora 24 x64
|
||||||
- Ubuntu 16.04 x64
|
- Ubuntu 16.04 x64
|
||||||
|
|
||||||
It has also been successfully tested on OVH Virtual Private Servers (with debian)
|
On Vultr:
|
||||||
|
- Ubuntu 18.10 x64
|
||||||
|
|
||||||
|
On OVH Virtual Private Servers (experimental):
|
||||||
|
- Debian
|
||||||
|
|
||||||
YMMV with any other hoster + image combination.
|
YMMV with any other hoster + image combination.
|
||||||
|
|
||||||
|
## Considerations
|
||||||
|
|
||||||
nixos-infect is so named because of the high likelihood of rendering a system
|
nixos-infect is so named because of the high likelihood of rendering a system
|
||||||
inoperable. Use with caution and preferably only on newly-provisioned
|
inoperable. Use with caution and preferably only on newly-provisioned
|
||||||
systems.
|
systems.
|
||||||
|
@ -20,6 +30,8 @@ runs to completion. Any errors halt execution. It's advised to run with
|
||||||
inconsistent state, requiring a rebuild (in DigitalOcean panel: Droplet
|
inconsistent state, requiring a rebuild (in DigitalOcean panel: Droplet
|
||||||
Settings -> "Destroy" -> "Rebuild from original").
|
Settings -> "Destroy" -> "Rebuild from original").
|
||||||
|
|
||||||
|
## Digital Ocean
|
||||||
|
|
||||||
*TO USE:*
|
*TO USE:*
|
||||||
- Add any custom config you want (see notes below)
|
- Add any custom config you want (see notes below)
|
||||||
- Deploy the droplet indicated at the top of the file, enable ipv6, add your ssh key
|
- Deploy the droplet indicated at the top of the file, enable ipv6, add your ssh key
|
||||||
|
@ -32,7 +44,7 @@ cat and EOF in the Digital Ocean Web UI (or HTTP API):
|
||||||
#cloud-config
|
#cloud-config
|
||||||
|
|
||||||
runcmd:
|
runcmd:
|
||||||
- curl https://raw.githubusercontent.com/elitak/nixos-infect/master/nixos-infect | NIX_CHANNEL=nixos-18.09 bash 2>&1 | tee /tmp/infect.log
|
- curl https://raw.githubusercontent.com/elitak/nixos-infect/master/nixos-infect | PROVIDER=digitalocean NIX_CHANNEL=nixos-18.09 bash 2>&1 | tee /tmp/infect.log
|
||||||
```
|
```
|
||||||
Potential tweaks:
|
Potential tweaks:
|
||||||
- `/etc/nixos/{,hardware-}configuration.nix`: rudimentary mostly static config
|
- `/etc/nixos/{,hardware-}configuration.nix`: rudimentary mostly static config
|
||||||
|
@ -50,10 +62,23 @@ write_files:
|
||||||
environment.systemPackages = with pkgs; [ vim ];
|
environment.systemPackages = with pkgs; [ vim ];
|
||||||
}
|
}
|
||||||
runcmd:
|
runcmd:
|
||||||
- curl https://raw.githubusercontent.com/elitak/nixos-infect/master/nixos-infect | NIXOS_IMPORT=./host.nix NIX_CHANNEL=nixos-18.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-18.09 bash 2>&1 | tee /tmp/infect.log
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Vultr
|
||||||
|
|
||||||
|
From a Vultr server, log into the box and invoke the following command:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
curl https://raw.githubusercontent.com/elitak/nixos-infect/master/nixos-infect | PROVIDER=vultr NIX_CHANNEL=nixos-18.09 bash
|
||||||
|
```
|
||||||
|
|
||||||
|
(One ought to be able to use a "Startup Script" for this but it seems like the
|
||||||
|
installation around the time Nix gets installed for some reason.)
|
||||||
|
|
||||||
|
## Motivation
|
||||||
|
|
||||||
Motivation for this script: nixos-assimilate should supplant this script
|
Motivation for this script: nixos-assimilate should supplant this script
|
||||||
entirely, if it's ever completed. nixos-in-place was quite broken when I
|
entirely, if it's ever completed. nixos-in-place was quite broken when I
|
||||||
tried it, and also took a pretty janky approach that was substantially more
|
tried it, and also took a pretty janky approach that was substantially more
|
||||||
|
|
11
nixos-infect
11
nixos-infect
|
@ -10,11 +10,14 @@ makeConf() {
|
||||||
# NB <<"EOF" quotes / $ ` in heredocs, <<EOF does not
|
# NB <<"EOF" quotes / $ ` in heredocs, <<EOF does not
|
||||||
mkdir -p /etc/nixos
|
mkdir -p /etc/nixos
|
||||||
local IFS=$'\n'; keys=($(grep -vE '^[[:space:]]*(#|$)' /root/.ssh/authorized_keys))
|
local IFS=$'\n'; keys=($(grep -vE '^[[:space:]]*(#|$)' /root/.ssh/authorized_keys))
|
||||||
|
local network_import=""
|
||||||
|
|
||||||
|
[ "$PROVIDER" = "digitalocean" ] && network_import="./networking.nix # generated at runtime by nixos-infect"
|
||||||
cat > /etc/nixos/configuration.nix << EOF
|
cat > /etc/nixos/configuration.nix << EOF
|
||||||
{ ... }: {
|
{ ... }: {
|
||||||
imports = [
|
imports = [
|
||||||
./hardware-configuration.nix
|
./hardware-configuration.nix
|
||||||
./networking.nix # generated at runtime by nixos-infect
|
$network_import
|
||||||
$NIXOS_IMPORT
|
$NIXOS_IMPORT
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -37,6 +40,10 @@ EOF
|
||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
[ "$PROVIDER" = "digitalocean" ] && makeNetworkingConf
|
||||||
|
}
|
||||||
|
|
||||||
|
makeNetworkingConf() {
|
||||||
# XXX It'd be better if we used procfs for all this...
|
# XXX It'd be better if we used procfs for all this...
|
||||||
local IFS=$'\n'
|
local IFS=$'\n'
|
||||||
eth0_name=$(ip address show | grep '^2:' | awk -F': ' '{print $2}')
|
eth0_name=$(ip address show | grep '^2:' | awk -F': ' '{print $2}')
|
||||||
|
@ -238,6 +245,8 @@ infect() {
|
||||||
/nix/var/nix/profiles/system/bin/switch-to-configuration boot
|
/nix/var/nix/profiles/system/bin/switch-to-configuration boot
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[ -z "$PROVIDER" ] && PROVIDER="digitalocean" # you may also prepend PROVIDER=vultr to your call instead
|
||||||
|
|
||||||
prepareEnv
|
prepareEnv
|
||||||
checkEnv
|
checkEnv
|
||||||
makeConf
|
makeConf
|
||||||
|
|
Loading…
Reference in a new issue