-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·31 lines (23 loc) · 972 Bytes
/
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
#!/bin/bash
set -e
## Install nix ##
if ! type /run/current-system/sw/bin/nix &> /dev/null; then
curl -L https://nixos.org/nix/install | sh -s -- --daemon --yes
fi
## Install brew ##
# Some pkgs aren't available in nixpkgs, but we can manage brew from home-manager
if ! type /opt/homebrew/bin/brew &> /dev/null; then
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
fi
## Build the flake ##
if [ ! -d ./nix/result ]; then
/run/current-system/sw/bin/nix build -o ./nix/result ./nix/.#darwinConfigurations.${1}.system --extra-experimental-features 'nix-command flakes'
fi
## Install the flake system wide ##
./nix/result/sw/bin/darwin-rebuild switch --flake "./nix/#${1}"
## Source nix packages for this shell ##
export PATH=$PATH:/etc/profiles/per-user/${USER}/bin/
## Install asdf plugins and tools ##
cut -d' ' -f1 .tool-versions|xargs -I{} asdf plugin add {}
asdf install
cp ./.tool-versions ~/.tool-versions