-
Notifications
You must be signed in to change notification settings - Fork 0
/
bootstrap.sh
executable file
·44 lines (34 loc) · 1.01 KB
/
bootstrap.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
#!/usr/bin/env bash
set -euxo pipefail
run_as() {
local owner
owner=$(stat -c '%U' "$1")
if [ "$owner" = "root" ]; then
echo "sudo"
fi
}
# Symlink a folder, if it doesn't exist
symlink() {
local run_as
run_as=$(run_as "$2")
if [ -f "$2" ] && [ ! -L "$2" ]; then
$run_as mv "$2" "$2.orig"
fi
[ ! -f "$2" ] && $run_as ln -s "$1" "$2"
}
bootstrap_nixos() {
echo "Bootstrapping NixOS..."
symlink "$HOME"/config/nixos/configuration.nix /etc/nixos/configuration.nix
# TODO: prompt for optional hostname to link, falling back to lukex as the
# default
sudo nix-channel --add https://nixos.org/channels/nixos-unstable nixos
sudo nix-channel --add http://nixos.org/channels/nixpkgs-unstable nixpkgs-unstable
sudo nix-channel --update
sudo nixos-rebuild switch --upgrade
}
apply_preferences() {
xdg-settings set default-web-browser chromium.desktop
}
# TODO: Add macOs/Linux support using home-manager
bootstrap_nixos
echo "Bootstrap Complete!"