-
Notifications
You must be signed in to change notification settings - Fork 0
/
bootstrap.sh
executable file
·51 lines (42 loc) · 1.69 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
45
46
47
48
49
50
51
#!/usr/bin/env sh
WD=$(dirname $(realpath $0))
function die() {
echo $1
exit 1
}
test -n "$HOSTNAME" || die "\$HOSTNAME is required"
function bootstrapDarwin() {
which darwin-rebuild || die "nix-darwin is required"
darwin-rebuild switch \
-I "darwin-config=$WD/systems/$HOSTNAME/darwin.nix" \
-I "nix-config=$WD"
}
function bootstrapDarwinHome() {
which home-manager || die "home-manager is required"
NIXPKGS_CONFIG="$WD/nixpkgs.nix" home-manager switch \
-I "darwin-config=$WD/systems/$HOSTNAME/darwin.nix" \
-I "nix-config=$WD" \
-I "nixpkgs-config=$WD/nixpkgs.nix" \
-I "hm-config=$WD/systems/$HOSTNAME/home.nix" \
-I "nixpkgs-overlays=$WD/overlays.nix"
}
function bootstrapNixOS() {
which nixos-rebuild sudo || die "sudo and nixos-rebuild are required"
NIXOS_CONFIG="$WD/systems/$HOSTNAME/nixos.nix" sudo nixos-rebuild switch \
-I "nixos-config=$WD/systems/$HOSTNAME/nixos.nix" \
-I "nix-config=$WD"
}
function bootstrapNixHM() {
which home-manager || (echo "home-manager not found, skipping"; exit 0)
NIXPKGS_CONFIG="$WD/nixpkgs.nix" home-manager switch \
-I "nix-config=$WD" \
-I "nixpkgs-config=$WD/nixpkgs.nix" \
-I "hm-config=$WD/systems/$HOSTNAME/home.nix" \
-I "nixpkgs-overlays=$WD/overlays.nix"
}
# TODO: put nix-env with git + cloning + installing darwin/home-manager here?
case $(uname -a) in
Darwin*) bootstrapDarwin && bootstrapDarwinHome;;
Linux*NixOS*) bootstrapNixOS && bootstrapNixHM;;
Linux) bootstrapNixHM;;
esac