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
|
2017-12-05 22:39:10 -08:00
|
|
|
|
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
|
2019-11-24 18:41:41 -08:00
|
|
|
];
|
2019-08-26 10:18:53 -07:00
|
|
|
}
|
|
|
|
EOF
|
2017-12-05 22:39:10 -08:00
|
|
|
|
2019-11-18 22:36:13 -08:00
|
|
|
nix-channel --add https://nixos.org/channels/nixos-19.09 nixos
|
2019-08-26 10:18:53 -07:00
|
|
|
nix-channel --add https://github.com/rycee/home-manager/archive/master.tar.gz home-manager
|
2019-09-06 21:29:07 -07:00
|
|
|
nix-channel --add https://nixos.org/channels/nixpkgs-unstable nixpkgs-unstable
|
2019-08-26 10:18:53 -07:00
|
|
|
nix-channel --update
|
2017-12-05 22:39:10 -08:00
|
|
|
|
2019-08-26 10:18:53 -07:00
|
|
|
nixos-generate-config --root "$PREFIX"
|
2019-11-18 22:36:13 -08:00
|
|
|
nixos-install --root "$PREFIX" -I "config=$DOTFILES/config"
|