-
Notifications
You must be signed in to change notification settings - Fork 49
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·739 lines (640 loc) · 20.6 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·739 lines (640 loc) · 20.6 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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
#!/usr/bin/env bash
set -eu
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# Global variables
SINGLE_USER_MODE=false
# Logging functions
log_info() {
echo -e "${BLUE}[INFO]${NC} $1"
}
log_success() {
echo -e "${GREEN}[SUCCESS]${NC} $1"
}
log_warning() {
echo -e "${YELLOW}[WARNING]${NC} $1"
}
log_error() {
echo -e "${RED}[ERROR]${NC} $1"
}
# Detect OS
detect_os() {
if [[ -f /etc/NIXOS ]]; then
echo "nixos"
elif [[ -d /nix/store ]] && command_exists nix; then
echo "nixos-container"
elif [[ -f /etc/arch-release ]]; then
echo "arch"
elif [[ -f /etc/debian_version ]]; then
echo "debian"
elif [[ -f /etc/redhat-release ]]; then
echo "redhat"
else
echo "unknown"
fi
}
# Check if command exists
command_exists() {
command -v "$1" >/dev/null 2>&1
}
# Show help information
show_help() {
echo "Usage: $0 [OPTIONS]"
echo ""
echo "OPTIONS:"
echo " --single Install Nix in single-user mode (no daemon)"
echo " --uninstall Completely uninstall Nix and remove dead symlinks"
echo " --help, -h Show this help message"
echo ""
echo "Default behavior (no options):"
echo " Set up Nix environment for flake-based configurations (multi-user mode)"
echo ""
echo "Examples:"
echo " $0 # Setup Nix environment (multi-user)"
echo " $0 --single # Setup Nix environment (single-user)"
echo " $0 --uninstall # Uninstall Nix and cleanup"
echo " $0 --help # Show this help"
echo ""
echo "Single-user mode is recommended for:"
echo " • Docker containers"
echo " • Development environments"
echo " • Systems without systemd"
echo " • Non-root installations"
}
# Remove dead symlinks
remove_dead_symlinks() {
local directories=("$@")
log_info "Removing dead symlinks from home directories..."
for dir in "${directories[@]}"; do
if [[ -d "$dir" ]]; then
log_info "Checking for dead symlinks in: $dir"
# Find and remove dead symlinks
local dead_links
dead_links=$(find "$dir" -type l ! -exec test -e {} \; -print 2>/dev/null || true)
if [[ -n "$dead_links" ]]; then
echo "$dead_links" | while IFS= read -r link; do
if [[ -n "$link" ]]; then
log_info "Removing dead symlink: $link"
rm -f "$link"
fi
done
log_success "Dead symlinks removed from $dir"
else
log_info "No dead symlinks found in $dir"
fi
else
log_info "Directory does not exist: $dir"
fi
done
}
# Uninstall Nix (multi-user)
uninstall_nix_multiuser() {
log_info "Uninstalling Nix (multi-user mode)..."
# Try to use nix-installer uninstall if available
if [[ -x /nix/nix-installer ]]; then
log_info "Using nix-installer for clean uninstall..."
if sudo /nix/nix-installer uninstall; then
log_success "Nix uninstalled successfully using nix-installer"
return 0
else
log_warning "nix-installer failed, falling back to manual method"
fi
fi
# Manual multi-user uninstall
log_info "Performing manual multi-user uninstall..."
# Stop daemon
if systemctl is-active --quiet nix-daemon 2>/dev/null; then
sudo systemctl stop nix-daemon
sudo systemctl disable nix-daemon
log_success "Nix daemon stopped and disabled"
fi
# Remove systemd files
sudo rm -f /etc/systemd/system/nix-daemon.service
sudo rm -f /etc/systemd/system/nix-daemon.socket
sudo rm -f /etc/systemd/system/multi-user.target.wants/nix-daemon.service
sudo systemctl daemon-reload
# Remove nixbld users
for i in $(seq 1 32); do
if id "nixbld$i" &>/dev/null; then
sudo userdel "nixbld$i"
log_info "Removed user nixbld$i"
fi
done
if getent group nixbld &>/dev/null; then
sudo groupdel nixbld
log_success "Removed group nixbld"
fi
# Remove Nix store
sudo rm -rf /nix
log_success "Nix store removed"
# Clean system profiles
local system_profiles=(
"/etc/bashrc"
"/etc/profile.d/nix.sh"
"/etc/zshrc"
"/etc/bash.bashrc"
"/etc/zsh/zshrc"
)
for profile in "${system_profiles[@]}"; do
if [[ -f "$profile" ]]; then
sudo sed -i.bak-before-nix-removal '/nix/d' "$profile" 2>/dev/null || true
log_info "Cleaned $profile"
fi
done
# Remove backup files
sudo rm -f /etc/bash.bashrc.backup-before-nix
sudo rm -f /etc/bashrc.backup-before-nix
sudo rm -f /etc/profile.backup-before-nix
sudo rm -f /etc/zsh/zshrc.backup-before-nix
sudo rm -f /etc/zshrc.backup-before-nix
}
# Uninstall Nix (single-user)
uninstall_nix_singleuser() {
log_info "Uninstalling Nix (single-user mode)..."
# Remove Nix store (user-owned)
rm -rf /nix 2>/dev/null || {
log_warning "Could not remove /nix (may need sudo for some files)"
sudo rm -rf /nix
}
log_success "Nix store removed"
}
# Common user cleanup for both modes
cleanup_user_files() {
log_info "Cleaning up user-specific Nix files..."
# User profiles
local user_profiles=(
"$HOME/.bash_profile"
"$HOME/.bashrc"
"$HOME/.profile"
"$HOME/.zshrc"
)
for profile in "${user_profiles[@]}"; do
if [[ -f "$profile" ]]; then
sed -i.bak-before-nix-removal '/nix/d' "$profile" 2>/dev/null || true
log_info "Cleaned $profile"
fi
done
# User Nix files
rm -rf "$HOME/.nix-channels" 2>/dev/null || true
rm -rf "$HOME/.nix-defexpr" 2>/dev/null || true
rm -rf "$HOME/.nix-profile" 2>/dev/null || true
rm -rf "$HOME/.config/nix" 2>/dev/null || true
rm -rf "$HOME/.config/nixpkgs" 2>/dev/null || true
rm -rf "$HOME/.cache/nix" 2>/dev/null || true
rm -rf "$HOME/.local/state/nix" 2>/dev/null || true
log_success "User Nix files removed"
}
# Complete uninstall
complete_uninstall() {
log_info "Starting complete Nix uninstallation and cleanup..."
# Detect installation mode
if [[ -f /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh ]] || systemctl list-unit-files | grep -q nix-daemon; then
log_info "Detected multi-user Nix installation"
uninstall_nix_multiuser
elif [[ -d /nix ]] && [[ -O /nix ]] 2>/dev/null; then
log_info "Detected single-user Nix installation"
uninstall_nix_singleuser
elif [[ -d /nix ]]; then
log_warning "Nix installation detected but mode unclear, trying both methods"
uninstall_nix_multiuser 2>/dev/null || uninstall_nix_singleuser
else
log_info "No Nix installation detected"
fi
# Common cleanup
cleanup_user_files
# Remove dead symlinks
log_info "Cleaning up dead symlinks..."
remove_dead_symlinks "$HOME" "$HOME/.config"
log_success "Complete uninstallation finished!"
log_info "All Nix components and dead symlinks have been removed."
log_info "You may want to restart your shell or logout/login to complete the cleanup."
}
# Clean install of Nix (multi-user)
clean_install_nix_multiuser() {
log_info "Performing clean Nix installation (multi-user mode)..."
# Install Nix with daemon
log_info "Running Nix installer with daemon..."
if sh <(curl -L https://nixos.org/nix/install) --daemon; then
log_success "Nix installed successfully (multi-user)"
# Source the profile for current session
if [[ -f /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh ]]; then
source /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh
log_info "Nix profile sourced for current session"
fi
# Verify installation
if command_exists nix; then
nix --version
log_success "Nix installation verified"
else
log_error "Nix installation completed but nix command not found"
log_info "You may need to restart your shell"
return 1
fi
else
log_error "Nix installation failed"
return 1
fi
}
# Clean install of Nix (single-user)
clean_install_nix_singleuser() {
log_info "Performing clean Nix installation (single-user mode)..."
# Install Nix without daemon
log_info "Running Nix installer without daemon..."
if sh <(curl -L https://nixos.org/nix/install) --no-daemon; then
log_success "Nix installed successfully (single-user)"
# Create initial profile if it doesn't exist
if [[ ! -e "$HOME/.nix-profile" ]]; then
log_info "Creating initial Nix profile..."
/nix/var/nix/profiles/default/bin/nix-env -i
log_info "Initial profile created"
fi
# Source the profile for current session
if [[ -f "$HOME/.nix-profile/etc/profile.d/nix.sh" ]]; then
source "$HOME/.nix-profile/etc/profile.d/nix.sh"
log_info "Nix profile sourced for current session"
else
log_error "Nix profile not found at $HOME/.nix-profile/etc/profile.d/nix.sh"
log_error "Initial profile creation may have failed"
return 1
fi
# Add to shell profiles if not already there
local shell_profiles=("$HOME/.bashrc" "$HOME/.zshrc" "$HOME/.profile")
local nix_source_line='if [ -e ~/.nix-profile/etc/profile.d/nix.sh ]; then . ~/.nix-profile/etc/profile.d/nix.sh; fi'
for profile in "${shell_profiles[@]}"; do
if [[ -f "$profile" ]] && ! grep -q "nix-profile/etc/profile.d/nix.sh" "$profile"; then
echo "$nix_source_line" >>"$profile"
log_info "Added Nix sourcing to $profile"
fi
done
# Verify installation
if command_exists nix; then
nix --version
log_success "Nix installation verified"
else
log_error "Nix installation completed but nix command not found"
log_info "You may need to restart your shell or run: source ~/.nix-profile/etc/profile.d/nix.sh"
return 1
fi
else
log_error "Nix installation failed"
return 1
fi
}
# Install Nix (for non-NixOS systems)
install_nix() {
log_info "Setting up Nix..."
# Check if Nix is already installed
if command_exists nix; then
log_info "Nix is already installed ($(nix --version))"
# Ask user if they want to reinstall
if [[ -t 0 ]]; then
read -p "Would you like to reinstall Nix for a clean setup? (y/N): " -n 1 -r
echo
else
log_info "Non-interactive session detected; keeping existing Nix installation"
REPLY="n"
fi
if [[ $REPLY =~ ^[Yy]$ ]]; then
complete_uninstall
if [[ "$SINGLE_USER_MODE" == "true" ]]; then
clean_install_nix_singleuser
else
clean_install_nix_multiuser
fi
else
log_info "Using existing Nix installation"
if [[ "$SINGLE_USER_MODE" == "false" ]]; then
# For multi-user, ensure daemon is running
if ! systemctl is-active --quiet nix-daemon 2>/dev/null; then
log_info "Starting nix-daemon..."
sudo systemctl start nix-daemon 2>/dev/null || true
fi
# Source profile
if [[ -f /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh ]]; then
source /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh
log_info "Nix profile sourced for current session"
fi
else
# For single-user, just source profile
if [[ -f "$HOME/.nix-profile/etc/profile.d/nix.sh" ]]; then
source "$HOME/.nix-profile/etc/profile.d/nix.sh"
log_info "Nix profile sourced for current session"
fi
fi
fi
else
# Fresh installation
if [[ "$SINGLE_USER_MODE" == "true" ]]; then
clean_install_nix_singleuser
else
clean_install_nix_multiuser
fi
fi
}
# Enable Nix flakes
enable_flakes() {
log_info "Enabling Nix flakes..."
# Create config directory
mkdir -p ~/.config/nix
# Enable experimental features
if ! grep -q "experimental-features" ~/.config/nix/nix.conf 2>/dev/null; then
echo "experimental-features = nix-command flakes" >>~/.config/nix/nix.conf
log_success "Flakes enabled in user config"
else
log_warning "Flakes already enabled in user config"
fi
# For multi-user mode, also enable system-wide if possible
if [[ "$SINGLE_USER_MODE" == "false" ]] && ([[ -w /etc/nix ]] || sudo -n true 2>/dev/null); then
sudo mkdir -p /etc/nix
if ! sudo grep -q "experimental-features" /etc/nix/nix.conf 2>/dev/null; then
echo "experimental-features = nix-command flakes" | sudo tee -a /etc/nix/nix.conf >/dev/null
log_success "Flakes enabled system-wide"
else
log_warning "Flakes already enabled system-wide"
fi
fi
}
# Install Home Manager (standalone)
install_home_manager_standalone() {
log_info "Installing Home Manager (standalone)..."
# Check if Home Manager is already installed
if command_exists home-manager; then
log_warning "Home Manager is already installed"
home-manager --version
# Update channels anyway
log_info "Updating existing Home Manager channels..."
nix-channel --update home-manager 2>/dev/null || true
return 0
fi
# Add Home Manager channel if not exists
if ! nix-channel --list | grep -q home-manager; then
log_info "Adding Home Manager channel..."
nix-channel --add https://github.com/nix-community/home-manager/archive/master.tar.gz home-manager
log_success "Home Manager channel added"
else
log_warning "Home Manager channel already exists"
fi
# Update channels
log_info "Updating Nix channels..."
nix-channel --update
# Install Home Manager
log_info "Installing Home Manager..."
if nix-shell '<home-manager>' -A install; then
log_success "Home Manager installed successfully"
# Verify installation
if command_exists home-manager; then
home-manager --version
log_success "Home Manager installation verified"
else
log_warning "Home Manager installation completed but command not found"
log_info "You may need to restart your shell or source the profile"
fi
else
log_error "Home Manager installation failed"
return 1
fi
}
# Setup for NixOS
setup_nixos() {
log_info "Setting up Nix environment for NixOS..."
if [[ "$SINGLE_USER_MODE" == "true" ]]; then
log_warning "Single-user mode is not typical for NixOS systems"
log_info "NixOS usually uses multi-user Nix installation"
fi
# Enable flakes
enable_flakes
# Check if flake.nix is valid
log_info "Validating flake configuration..."
if nix flake check --no-build 2>/dev/null; then
log_success "Flake configuration is valid"
else
log_warning "Flake configuration has issues (this might be normal)"
fi
# Show available configurations
log_info "Available NixOS configurations:"
nix flake show 2>/dev/null | grep -E "nixosConfigurations" -A 10 || log_warning "Could not display configurations"
log_success "NixOS environment setup complete!"
}
# Setup for NixOS container (nixos/nix Docker image)
setup_nixos_container() {
log_info "Setting up Nix environment for NixOS container..."
# In containers, Nix is already installed and configured
# We just need to enable flakes and validate configuration
# Enable flakes
enable_flakes
# Skip Home Manager installation in container mode - not needed for testing
log_info "Skipping Home Manager installation in container mode"
# Check if flake.nix is valid
log_info "Validating flake configuration..."
if nix flake check --no-build 2>/dev/null; then
log_success "Flake configuration is valid"
else
log_warning "Flake configuration has issues (this might be normal)"
fi
# Show available configurations
log_info "Available configurations:"
nix flake show 2>/dev/null || log_warning "Could not display configurations"
install_home_manager_standalone
log_success "NixOS container environment setup complete!"
}
# Setup for non-NixOS systems
setup_standalone() {
local os_type="$1"
if [[ "$SINGLE_USER_MODE" == "true" ]]; then
log_info "Setting up Nix environment for $os_type (single-user mode)..."
else
log_info "Setting up Nix environment for $os_type (multi-user mode)..."
fi
# Install Nix if not present
install_nix
# Enable flakes
enable_flakes
# Install Home Manager
install_home_manager_standalone
# Check if flake.nix is valid
log_info "Validating flake configuration..."
if nix flake check --no-build 2>/dev/null; then
log_success "Flake configuration is valid"
else
log_warning "Flake configuration has issues (this might be normal)"
fi
# Show available configurations
log_info "Available Home Manager configurations:"
nix flake show 2>/dev/null | grep -E "homeConfigurations" -A 10 || log_warning "Could not display configurations"
if [[ "$SINGLE_USER_MODE" == "true" ]]; then
log_success "Standalone Nix environment setup complete (single-user mode)!"
else
log_success "Standalone Nix environment setup complete (multi-user mode)!"
fi
}
# Display usage instructions
show_usage_instructions() {
local os_type="$1"
local hostname=${HOSTNAME}
log_info ""
log_info "=== Next Steps ==="
case "$os_type" in
"nixos")
log_info "For NixOS system configuration:"
log_info " sudo nixos-rebuild switch --flake .#$hostname"
log_info ""
log_info "To link dotfiles (first run; afterwards just 'mise dotfiles apply'):"
log_info " mise trust .config/mise/config.toml"
log_info " MISE_GLOBAL_CONFIG_FILE=\$PWD/.config/mise/config.toml mise dotfiles apply"
log_info ""
log_info "To install CLI tools and zsh completions:"
log_info " mise install"
log_info " mise run zsh-completions-sync"
log_info ""
log_info "To see available configurations:"
log_info " nix flake show"
log_info ""
log_info "To update flake inputs:"
log_info " nix flake update"
;;
*)
log_info "For Home Manager configuration:"
log_info " # Default user:"
log_info " home-manager switch --flake .#$hostname"
log_info ""
log_info " # Custom username:"
log_info " NIX_USERNAME=your_username home-manager switch --impure --flake .#$hostname"
log_info ""
log_info "To link dotfiles (first run; afterwards just 'mise dotfiles apply'):"
log_info " mise trust .config/mise/config.toml"
log_info " MISE_GLOBAL_CONFIG_FILE=\$PWD/.config/mise/config.toml mise dotfiles apply"
log_info ""
log_info "To install CLI tools and zsh completions:"
log_info " mise install"
log_info " mise run zsh-completions-sync"
log_info ""
log_info "To see available configurations:"
log_info " nix flake show"
log_info ""
log_info "To update flake inputs:"
log_info " nix flake update"
log_info ""
log_info "Useful commands:"
log_info " home-manager generations # Show previous generations"
log_info " nix-collect-garbage -d # Clean up old packages"
;;
esac
log_info ""
if [[ "$SINGLE_USER_MODE" == "true" ]]; then
log_info "If you encounter 'command not found' errors, try:"
log_info " source ~/.nix-profile/etc/profile.d/nix.sh"
else
log_info "If you encounter 'command not found' errors, try:"
log_info " source ~/.nix-profile/etc/profile.d/hm-session-vars.sh"
fi
log_info "Or restart your terminal session."
}
# Main function
main() {
# Parse command line arguments
case "${1:-}" in
--single)
SINGLE_USER_MODE=true
log_info "Single-user mode selected"
;;
--uninstall)
log_info "Uninstall mode selected"
# Show what will be uninstalled
log_info ""
log_info "=== UNINSTALL CONFIRMATION ==="
log_info "This will completely remove:"
log_info "• Nix package manager and all its components"
log_info "• All Nix store contents (/nix directory)"
log_info "• Nix daemon and systemd services (if multi-user)"
log_info "• nixbld users and group (if multi-user)"
log_info "• Nix-related shell profile modifications"
log_info "• User-specific Nix files and caches"
log_info "• Dead symlinks in ~ and ~/.config directories"
log_info ""
log_warning "This action cannot be undone!"
log_info ""
# Confirm uninstallation
if [[ -t 0 ]]; then
read -p "Do you really want to proceed with complete Nix uninstallation? (y/N): " -n 1 -r
echo
else
log_warning "Non-interactive session detected; run interactively to confirm uninstallation"
REPLY="n"
fi
if [[ $REPLY =~ ^[Yy]$ ]]; then
log_info "Proceeding with uninstallation..."
complete_uninstall
else
log_info "Uninstallation cancelled by user"
log_info "No changes were made to your system"
fi
exit 0
;;
--help | -h)
show_help
exit 0
;;
"")
# Default behavior - setup (multi-user)
;;
*)
log_error "Unknown option: $1"
show_help
exit 1
;;
esac
log_info "Starting Nix environment setup..."
# Detect OS
local os_type
os_type="$(detect_os)"
log_info "Detected OS: $os_type"
# Change to script directory
cd "$(dirname "$0")"
# Check if flake.nix exists
if [[ ! -f "flake.nix" ]]; then
log_error "flake.nix not found in current directory"
exit 1
fi
case "$os_type" in
"nixos")
if setup_nixos; then
show_usage_instructions "$os_type"
log_success "Nix environment setup completed successfully!"
log_info "You can now apply your configurations using the commands shown above."
else
log_error "NixOS setup failed"
exit 1
fi
;;
"nixos-container")
if setup_nixos_container; then
show_usage_instructions "nixos"
log_success "Nix environment setup completed successfully!"
log_info "Container setup complete - ready for testing."
else
log_error "NixOS container setup failed"
exit 1
fi
;;
"arch" | "debian" | "redhat" | "unknown")
if setup_standalone "$os_type"; then
show_usage_instructions "$os_type"
log_success "Nix environment setup completed successfully!"
log_info "You can now apply your configurations using the commands shown above."
else
log_error "Standalone setup failed"
exit 1
fi
;;
*)
log_error "Unsupported OS: $os_type"
exit 1
;;
esac
}
# Run main function
main "$@"