Repository navigation
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·165 lines (143 loc) · 4.53 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·165 lines (143 loc) · 4.53 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
#!/usr/bin/env bash
#
# Bootstrap script for nixie dotfiles
# This script sets up a new machine with home-manager and dotfiles configuration
set -e
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# Helper functions
info() {
echo -e "${BLUE}[INFO]${NC} $1"
}
success() {
echo -e "${GREEN}[SUCCESS]${NC} $1"
}
warn() {
echo -e "${YELLOW}[WARN]${NC} $1"
}
error() {
echo -e "${RED}[ERROR]${NC} $1"
exit 1
}
# Get the script directory
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd "$SCRIPT_DIR"
info "Starting nixie dotfiles installation..."
echo
# Step 1: Check for Nix installation
info "Checking for Nix installation..."
if ! command -v nix &> /dev/null; then
error "Nix is not installed. Please install Nix first:"
echo " curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install"
echo " or visit: https://nixos.org/download.html"
fi
success "Nix is installed"
echo
# Step 2: Ensure flakes are enabled
info "Checking Nix configuration..."
mkdir -p ~/.config/nix
if ! grep -q "experimental-features.*flakes" ~/.config/nix/nix.conf 2>/dev/null; then
warn "Enabling Nix flakes and nix-command..."
echo "experimental-features = nix-command flakes" >> ~/.config/nix/nix.conf
fi
success "Nix flakes enabled"
echo
# Step 3: Detect platform
info "Detecting platform..."
if [[ "$OSTYPE" == "darwin"* ]]; then
PLATFORM="darwin"
SYSTEM_ARCH=$(uname -m)
if [[ "$SYSTEM_ARCH" == "arm64" ]]; then
success "Detected macOS (Apple Silicon)"
else
success "Detected macOS (Intel)"
fi
else
PLATFORM="linux"
success "Detected Linux"
fi
echo
# Step 4: Setup private configuration directory
info "Setting up private configuration..."
if [ ! -d "$HOME/.private" ]; then
mkdir -p "$HOME/.private"
# Copy templates
if [ -f ".private.template/.zshrc" ]; then
cp ".private.template/.zshrc" "$HOME/.private/.zshrc"
success "Created ~/.private/.zshrc from template"
fi
if [ -f ".private.template/.gitconfig" ]; then
cp ".private.template/.gitconfig" "$HOME/.private/.gitconfig"
success "Created ~/.private/.gitconfig from template"
fi
warn "IMPORTANT: Edit the files in ~/.private/ to customize your configuration"
warn " - ~/.private/.zshrc: Set WORKSPACE, GITHUB_TOKEN, etc."
warn " - ~/.private/.gitconfig: Set your git user info"
echo
else
info "~/.private/ directory already exists, skipping template copy"
echo
fi
# Step 5: Verify flake.nix
info "Checking flake configuration..."
if [ -f "flake.nix" ]; then
success "flake.nix found"
echo
else
error "flake.nix not found! This file is required for installation."
fi
# Step 6: Update flake lock
info "Updating flake dependencies..."
if nix flake update; then
success "Flake dependencies updated"
else
warn "Failed to update flake (continuing anyway)"
fi
echo
# Step 7: Build and activate home-manager configuration
info "Building home-manager configuration..."
USERNAME=$(whoami)
if [ "$PLATFORM" == "darwin" ]; then
FLAKE_CONFIG="${USERNAME}@darwin"
else
FLAKE_CONFIG="${USERNAME}@workstation"
fi
info "Using configuration: $FLAKE_CONFIG"
echo
# Check if home-manager is available
if command -v home-manager &> /dev/null; then
info "home-manager found, using it directly..."
if home-manager switch --flake ".#$FLAKE_CONFIG"; then
success "home-manager configuration activated!"
else
error "Failed to activate home-manager configuration"
fi
else
info "home-manager not found, building with nix..."
if nix run home-manager/master -- switch --flake ".#$FLAKE_CONFIG"; then
success "home-manager configuration activated!"
else
error "Failed to activate home-manager configuration"
fi
fi
echo
success "============================================"
success "Installation complete!"
success "============================================"
echo
info "Next steps:"
echo " 1. Edit ~/.private/.zshrc and ~/.private/.gitconfig with your personal settings"
echo " 2. Close and reopen your terminal (or run: exec zsh)"
echo " 3. Start tmux - plugins will be installed automatically"
echo " 4. Open nvim - Lazy.nvim will install plugins automatically"
echo
info "To update your configuration in the future:"
echo " cd $SCRIPT_DIR && home-manager switch --flake '.#$FLAKE_CONFIG'"
echo
info "To update dependencies:"
echo " cd $SCRIPT_DIR && nix flake update && home-manager switch --flake '.#$FLAKE_CONFIG'"
echo