-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.sh
executable file
·41 lines (31 loc) · 1023 Bytes
/
setup.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
#!/usr/bin/env bash
set -Eeuo pipefail
FLAKE_DIR=~/.dots
create_ccache_dir() {
if [ ! -d /nix/var/cache/ccache ]; then
sudo mkdir -m0770 -p /nix/var/cache/ccache
if [[ "$OSTYPE" == "darwin"* ]]; then
nix-shell -p coreutils --run 'sudo chown --reference=/nix/store /nix/var/cache/ccache'
else
sudo chown --reference=/nix/store /nix/var/cache/ccache
fi
fi
}
flake_args=('--accept-flake-config' "--extra-experimental-features" "nix-command flakes pipe-operators ca-derivations" "$*")
build_flake() {
if [ ! -d "$FLAKE_DIR" ]; then
echo "Cloning jakeschurch/dots"
git clone https://github.com/jakeschurch/dots.git "$FLAKE_DIR"
fi
# use nom if available, otherwise use nix to build package
if command -v nom &>/dev/null; then
NIX_BIN="$(command -v nom)"
else
NIX_BIN="$(command -v nix)"
fi
$NIX_BIN build "$FLAKE_DIR" "${flake_args[@]}" &&
"$FLAKE_DIR"/result/activate-user &&
sudo "$FLAKE_DIR"/result/activate
}
create_ccache_dir
build_flake "$@"