-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathinstall.sh
executable file
·46 lines (33 loc) · 1.09 KB
/
install.sh
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
#!/usr/bin/env bash
set -e
NIXOS_DIR_NAME=nixcfg
# Check if HOSTNAME is set
if [[ -z "$HOSTNAME" ]]; then
echo "HOSTNAME is not set!"
exit 1
fi
echo "HOSTNAME is set to $HOSTNAME."
# Create directory ~/Code, if it doesn't exist
if [ ! -d ~/Code ]; then
mkdir ~/Code
fi
cd ~/Code
if [ -d ${NIXOS_DIR_NAME} ]; then
echo "Directory ~/Code/${NIXOS_DIR_NAME} already exists!"
exit 1
fi
echo ""
echo "Cloning nixcfg and copying initial config..."
nix-shell -p git --run 'git clone --recurse-submodules https://github.com/pbek/nixcfg.git ${NIXOS_DIR_NAME}'
cd ${NIXOS_DIR_NAME}
mkdir hosts/${HOSTNAME}
cp /etc/nixos/configuration.nix hosts/${HOSTNAME}
cp /etc/nixos/hardware-configuration.nix hosts/${HOSTNAME}
echo ""
echo "Switching to unstable channel..."
sudo nix-channel --add https://nixos.org/channels/nixos-unstable nixos
echo ""
echo "Switching to ssh git remote..."
nix-shell -p git --run 'git remote set-url origin [email protected]:pbek/nixcfg.git'
echo ""
echo "Now edit 'flakes.nix' and add your host and 'hosts/${HOSTNAME}/configuration.nix' to style it like the rest of the hosts."