-
-
Notifications
You must be signed in to change notification settings - Fork 99
/
install.zsh
executable file
·38 lines (33 loc) · 1.05 KB
/
install.zsh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/env zsh
# Deploy and install this nixos system.
zparseopts -E -F -D -- -flake=flake \
-user=user \
-host=host \
-dest=dest \
-root=root || exit 1
local root="${root[2]:-/mnt}"
local flake="${flake[2]:-$root/etc/dotfiles}"
local host="${host[2]:-$HOST}"
local user="${user[2]:-hlissner}"
local dest="${dest[2]:-$root/home/$user/.config/dotfiles}"
if [[ "$USER" == nixos ]]; then
>&2 echo "Error: not in the nixos installer"
exit 1
elif [[ -z "$host" ]]; then
>&2 echo "Error: no --host set"
exit 2
fi
set -e
if [[ ! -d "$flake" ]]; then
local url=https://github.com/hlissner/dotfiles
[[ "$user" == hlissner ]] && url="[email protected]:hlissner/dotfiles.git"
rm -rf "$flake"
git clone --recursive "$url" "$flake"
chown "$user:users" -R "$flake"
fi
export HEYENV="{\"user\":\"$user\",\"host\":\"$host\",\"path\":\"${flake#$root}\",\"theme\":\"$THEME\"}"
nixos-install \
--impure \
--show-trace \
--root "$root" \
--flake "${flake}#${host}"