-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup
More file actions
61 lines (51 loc) · 1.91 KB
/
setup
File metadata and controls
61 lines (51 loc) · 1.91 KB
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
52
53
54
55
56
57
58
59
60
61
#!/bin/bash
set -euo pipefail
LOCAL_BIN="$HOME/.local/bin"
GPGID=0x03BC4AD253B82986
mkdir -p $LOCAL_BIN
# If $HOME/.local/bin not in path, add it
if [ -d "$LOCAL_BIN" ] && [[ ":$PATH:" != *":$LOCAL_BIN:"* ]]; then
PATH="${PATH:+"$PATH:"}$LOCAL_BIN"
fi
# Setup gpg
gpg --receive-keys $GPGID
# Install and initialize chezmoi in one go
if ! command -v chezmoi > /dev/null; then
sh -c "$(curl -fsLS get.chezmoi.io)" -- -b $LOCAL_BIN init --apply git@github.com:nimser/private-dotfiles-devcontainer.git --exclude=encrypted
echo "🥁 Only non-encrypted files where applied. Please run 'chezmoi apply --include=encrypted' if needed."
fi
# Install nix for dependencies that don't have a binary on github (would use mise otherwise)
# and detect install path from nix feature instead for devcontainers
for f in /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh /etc/profile.d/nix.sh ~/.nix-profile/etc/profile.d/nix.sh; do
if [ -f "$f" ]; then
source "$f"
break
fi
done
# Fallback: check if nix-env is in common locations and add to PATH
if ! command -v nix-env &>/dev/null; then
for d in /nix/var/nix/profiles/default/bin ~/.nix-profile/bin; do
if [ -x "$d/nix-env" ]; then
export PATH="$PATH:$d"
break
fi
done
fi
if ! command -v nix-env &>/dev/null && [ ! -d "/nix" ]; then
echo "🥁 nix-env command not found. Attempting to install Nix..."
sh <(curl -L https://nixos.org/nix/install) --daemon --yes
if [ -f /etc/profile.d/nix.sh ]; then source /etc/profile.d/nix.sh; fi
fi
if [ -f $HOME/.config/nixpkgs/config.nix ]; then
# Set system type if not provided via cli
export SYSTEM_TYPE=${SYSTEM_TYPE:-server}
export NIX_REMOTE=""
# Install all packages defined in config.nix
nix-env -iA nixpkgs.myPackages --impure
else
echo "💥 ERROR: Nix configuration file not found"
echo "Ensure chezmoi has run and deployed it correctly."
exit 1
fi
echo "Finished setting up dotfiles"
exit 0