helm/deploy

34 lines
956 B
Plaintext
Raw Normal View History

2019-08-06 10:56:54 -07:00
#!/usr/bin/env bash
DOTFILES="$(cd $(dirname "${BASH_SOURCE:-${(%):-%x}}") && pwd -P)"
2019-08-26 10:18:53 -07:00
PREFIX="${PREFIX:-/mnt}"
NIXOSPREFIX="${PREFIX}/etc/nixos"
2019-08-06 10:56:54 -07:00
HOST=${1:-${HOST:-kuro}}
set -e
if [[ ! -f "$DOTFILES/configuration.$HOST.nix" ]]; then
>&2 echo "No configuration exists for host '$HOST'"
2019-08-26 10:18:53 -07:00
exit 1
elif [[ ! -f "$NIXOSPREFIX/hardware-configuration.nix" ]]; then
>&2 echo "No hardware-configuration.nix file exists in $NIXOSPREFIX"
>&2 echo "Did you forget to set up your partitions?"
2019-08-06 10:56:54 -07:00
exit 2
fi
2019-08-26 10:18:53 -07:00
mkdir -p "$NIXOSPREFIX"
cat << EOF > "$NIXOSPREFIX/configuration.nix"
{ config, ... }:
{
imports = [
../dotfiles/configuration.$HOST.nix
./hardware-configuration.nix
]
}
EOF
2019-08-26 10:18:53 -07:00
nix-channel --add https://nixos.org/channels/nixos-19.03 nixos
nix-channel --add https://github.com/rycee/home-manager/archive/master.tar.gz home-manager
nix-channel --update
2019-08-26 10:18:53 -07:00
nixos-generate-config --root "$PREFIX"
nixos-install --root "$PREFIX" -I "config=$DOTFILES"