helm/deploy

38 lines
1 KiB
Plaintext
Raw Normal View History

2019-08-06 10:56:54 -07:00
#!/usr/bin/env bash
set -e
2019-08-06 10:56:54 -07:00
DOTFILES="$(cd $(dirname "${BASH_SOURCE:-${(%):-%x}}") && pwd -P)"
2019-08-26 10:18:53 -07:00
PREFIX="${PREFIX:-/mnt}"
NIXOSPREFIX="${PREFIX}/etc/nixos"
NIXOSFLAGS="-I 'config=$DOTFILES/config' -I 'packages=$DOTFILES/packages'"
2019-08-06 10:56:54 -07:00
HOST=${1:-${HOST:-kuro}}
if [ $EUID -nq 0 ]; then
sudo nix-channel --update
sudo nixos-rebuild $NIXOSFLAGS switch
else
if [ ! -f "$DOTFILES/configuration.$HOST.nix" ]; then
>&2 echo "No configuration exists for host '$HOST'"
exit 1
fi
mkdir -p "$NIXOSPREFIX"
cat << EOF > "$NIXOSPREFIX/configuration.nix"
2019-08-26 10:18:53 -07:00
{ config, ... }:
{
imports = [
../dotfiles/configuration.$HOST.nix
./hardware-configuration.nix
];
2019-08-26 10:18:53 -07:00
}
EOF
nix-channel --add https://nixos.org/channels/nixos-19.09 nixos
2020-01-03 03:42:17 -08:00
nix-channel --add https://github.com/rycee/home-manager/archive/release-19.09.tar.gz home-manager
nix-channel --add https://nixos.org/channels/nixpkgs-unstable nixpkgs-unstable
nix-channel --update
nixos-generate-config --root "$PREFIX"
nixos-install --root "$PREFIX" $NIXOSFLAGS
fi