-
-
Save grahamc/c0e08f431fbaac0b265b3498b7de24fb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
set -eux | |
export TARGET="$1" | |
export NIX_PATH=nixpkgs="https://github.com/NixOS/nixpkgs-channels/archive/nixos-unstable.tar.gz" | |
export _SSH="ssh -o UserKnownHostsFile=./kn root@${TARGET}" | |
echo "" > kn | |
nix-build \ | |
'<nixpkgs/nixos>' \ | |
-A config.system.build.kexec_tarball \ | |
-I nixos-config=./configuration.nix\ | |
-Q -j 4 | |
while ! [ x`$_SSH "/bin/bash -c 'echo foo'"` = "xfoo" ]; do | |
sleep 1 | |
done | |
rsync result/tarball/nixos-system-x86_64-linux.tar.xz \ | |
-e 'ssh -o UserKnownHostsFile=./kn ' \ | |
root@${TARGET}:~/ | |
$_SSH '/bin/bash -c \ | |
"tar -C / -xf /root/nixos-system-*.tar.xz; /kexec_nixos"' & | |
# Wait for it to go down | |
while [ x`$_SSH "/bin/sh -c 'echo foo'"` = "xfoo" ]; do | |
sleep 1 | |
done | |
echo "" > kn | |
sleep 5 | |
while ! [ x`$_SSH "/bin/sh -c 'echo foo'"` = "xfoo" ]; do | |
sleep 1 | |
done | |
scp -o UserKnownHostsFile=./kn run.sh root@${TARGET}:~/run.sh | |
$_SSH "/bin/bash -c 'chmod +x run.sh; ./run.sh'" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
extracfg() { | |
cat <<EOF | |
{ | |
boot.loader.grub.devices = [ "/dev/sda" "/dev/sdb" ]; | |
services.openssh.enable = true; | |
users.users.root.openssh.authorizedKeys.keys = [ "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDa8JEOIubMB6khJYaY2q7fpco+q5RCo5HHwdUrngR4kGCXvdeou0tNldMrR0mshIDBJ4VoI0rTFUe3Sb8W+7iknxHSsY6+7fzQ2DvW7JYmtprEJrlOheqKWzjtLgR1hERDugM1LvFGUUpUj5mZpC2yzJnOuc/jlZ1KWjcK44YyJveqxo128Kv3Xqiz85Bt+nAD69cDs8LzOzvH6YI7RcPmzo04h01eJqcGY3lbOmbfJFvJyB8RhJx7phIALmo3BWITKcc00Hyw52tu86WzMPQuSEn5e9Fel6SL/sdLpxT4V9e8v64TrsNPQrGEw+C2MRYHLE5gqKDLMy/ZK8dA5TMF gchristensen@Lrr.local" ]; | |
} | |
EOF | |
} | |
# partition | |
mdadm --stop /dev/md12{6,7} | |
mdadm --create --verbose /dev/md0 --level=0 --raid-devices=4 /dev/sd{c,d,e,f} | |
mkfs.ext4 /dev/md0 | |
nixos-generate-config --root /mnt | |
sed -i "s#./hardware-configuration.nix#./hardware-configuration.nix ./extra.nix#" /mnt/etc/nixos/configuration.nix | |
extracfg > /mnt/etc/nixos/extra.nix | |
nixos-install |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment