-
-
Notifications
You must be signed in to change notification settings - Fork 101
/
Copy pathinstall.zsh
executable file
·49 lines (43 loc) · 1.32 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
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/env zsh
# Deploy and install this nixos system.
zparseopts -E -F -D -- -flake=flake \
-user=user \
-host=host \
-dest=dest \
-disk=disk \
-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}"
local disk="${disk[2]}"
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="git@github.com: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\"}"
if [[ -n "$disk" ]]; then
nix run 'github:nix-community/disko/latest#disko-install' -- \
--impure \
--show-trace \
--flake "${flake}#${host}" \
--disk main "${disk}"
else
nixos-install \
--impure \
--show-trace \
--root "$root" \
--flake "${flake}#${host}"
fi