-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathenv.sh
More file actions
executable file
·66 lines (59 loc) · 2.22 KB
/
env.sh
File metadata and controls
executable file
·66 lines (59 loc) · 2.22 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
#!/usr/bin/env bash
set -e
OS="$(uname -s)"
# macOS
if [ "$OS" = "Darwin" ]; then
echo "🍎 macOS detected. Running mac_shell.sh..."
./flows/env/mac_shell.sh
# Linux/WSL
elif [ "$OS" = "Linux" ]; then
echo "Linux/WSL detected. Running nix-shell..."
if ! command -v nix-shell >/dev/null 2>&1; then
echo "❄️ Nix not found. Installing Nix..."
sh <(curl -L https://nixos.org/nix/install) --daemon
echo "✅ Nix installed. Loading environment..."
# Source Nix configuration directly to make it available immediately
if [ -e '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh' ]; then
. '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh'
elif [ -e "$HOME/.nix-profile/etc/profile.d/nix.sh" ]; then
. "$HOME/.nix-profile/etc/profile.d/nix.sh"
fi
fi
# Setup Cachix
if ! command -v cachix >/dev/null 2>&1; then
echo "🔹 Setting up Cachix..."
nix-shell -p cachix --run "cachix use uwasic-eda"
else
echo "✅ Cachix already installed."
fi
echo "🚀 Entering Nix shell..."
# Pass the first argument as the 'type' to shell.nix
# If no argument is provided, auto-detect based on project structure
TYPE_ARG=""
if [ -n "$1" ]; then
TYPE_ARG="--argstr type $1"
else
# Auto-detection logic
HAS_ANALOG=0
HAS_DIGITAL=0
if [ -d "analog" ]; then HAS_ANALOG=1; fi
if [ -d "digital" ]; then HAS_DIGITAL=1; fi
if [ "$HAS_ANALOG" -eq 1 ] && [ "$HAS_DIGITAL" -eq 1 ]; then
echo "🔍 Auto-detected project type: mixed"
TYPE_ARG="--argstr type mixed"
elif [ "$HAS_ANALOG" -eq 1 ]; then
echo "🔍 Auto-detected project type: analog"
TYPE_ARG="--argstr type analog"
elif [ "$HAS_DIGITAL" -eq 1 ]; then
echo "🔍 Auto-detected project type: digital"
TYPE_ARG="--argstr type digital"
else
echo "🔍 No project structure found. Defaulting to: mixed"
TYPE_ARG="--argstr type mixed"
fi
fi
nix-shell flows/env/shell.nix $TYPE_ARG --extra-experimental-features flakes
else
echo "❌ Unsupported OS: $OS"
exit 1
fi