-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshell.nix
More file actions
264 lines (245 loc) · 8.3 KB
/
shell.nix
File metadata and controls
264 lines (245 loc) · 8.3 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
{
pkgs ?
import (builtins.fetchTarball {
url = "https://github.com/NixOS/nixpkgs/archive/nixos-unstable.tar.gz";
sha256 = "sha256:0z423v1f4pyllhqz68jichams2vrgnmply12lzkvj6k4hijkvnaa";
}) {
overlays = [
];
},
}: let
selfBuiltPackages = {
ngspice-shared = pkgs.ngspice.override {
withNgshared = true;
};
netgen = pkgs.stdenv.mkDerivation rec {
name = "netgen";
version = "1.5.305";
src = pkgs.fetchurl {
url = "http://opencircuitdesign.com/netgen/archive/netgen-${version}.tgz";
sha256 = "sha256-U9m/pIydfRSlsEWhLDDFsC8+C0Fn3DgYQrwVDETn4Zg=";
};
nativeBuildInputs = [pkgs.python312];
buildInputs = with pkgs; [
tcl
tk
xorg.libX11
];
enableParallelBuilding = true;
configureFlags = [
"--with-tcl=${pkgs.tcl}"
"--with-tk=${pkgs.tk}"
];
NIX_CFLAGS_COMPILE = "-O2";
postPatch = ''
find . -name "*.sh" -exec patchShebangs {} \; || true
'';
meta = with pkgs.lib; {
description = "LVS netlist comparison tool";
homepage = "http://opencircuitdesign.com/netgen/";
license = licenses.mit;
maintainers = with maintainers; [thoughtpolice];
};
};
xschem = pkgs.stdenv.mkDerivation rec {
name = "xschem";
version = "3.4.7";
src = pkgs.fetchFromGitHub {
owner = "StefanSchippers";
repo = "xschem";
rev = "3.4.7";
sha256 = "sha256-ye97VJQ+2F2UbFLmGrZ8xSK9xFeF+Yies6fJKurPOD0=";
};
nativeBuildInputs =
[
pkgs.bison
pkgs.flex
pkgs.pkg-config
]
++ pkgs.lib.optionals pkgs.stdenv.hostPlatform.isDarwin [
pkgs.fixDarwinDylibNames
];
buildInputs = with pkgs; [
tcl
tk
xorg.libX11
xorg.libXpm
cairo
readline
flex
bison
zlib
];
enableParallelBuilding = true;
NIX_CFLAGS_COMPILE = "-O2";
hardeningDisable = ["format"];
meta = with pkgs.lib; {
description = "Schematic capture and netlisting EDA tool";
longDescription = ''
Xschem is a schematic capture program, it allows creation of
hierarchical representation of circuits with a top down approach.
By focusing on interfaces, hierarchy and instance properties a
complex system can be described in terms of simpler building
blocks. A VHDL or Verilog or Spice netlist can be generated from
the drawn schematic, allowing the simulation of the circuit.
'';
homepage = "https://xschem.sourceforge.io/stefan/";
license = licenses.gpl2Plus;
maintainers = with maintainers; [fbeffa];
};
};
};
in
pkgs.mkShell {
name = "eda-environment-v1.0";
buildInputs = with pkgs; [
# Builds
rustup
cargo
gnumake
git
python312
ccache
# C compilation dependencies
gcc
clang
llvmPackages.libclang
libffi.dev
fftw
libffi.dev
# Digital design
iverilog
iverilog
slang
verilator
yosys
gtkwave
python312Packages.pip
python312Packages.numpy
python312Packages.setuptools
python312Packages.wheel
# Openlane Dependencies
# Openlane Dependencies
ruby
stdenv.cc.cc.lib
expat
swig
swig
zlib
# Analog Design
selfBuiltPackages.xschem
selfBuiltPackages.ngspice-shared
selfBuiltPackages.netgen
ngspice
ngspice
klayout
magic-vlsi
vim
gaw
# Graphics/GUI support
xorg.libX11
xorg.libXpm
xorg.libXt
cairo
xterm
xorg.fontutil
xorg.fontmiscmisc
xorg.fontcursormisc
dejavu_fonts
liberation_ttf
inkscape
];
env = {
NIX_ENFORCE_PURITY = "0";
};
shellHook = ''
export PROJECT_ROOT="$(pwd)"
# === Environment Variables Setup ===
export CC="ccache gcc"
export CXX="ccache g++"
export CCACHE_DIR="$PROJECT_ROOT/.tools/ccache"
# === Rust-Python Build Configuration ===
export LIBCLANG_PATH="${pkgs.llvmPackages.libclang.lib}/lib"
export BINDGEN_EXTRA_CLANG_ARGS="-I${pkgs.glibc.dev}/include -I${selfBuiltPackages.ngspice-shared}/include"
export CPATH="${pkgs.python312}/include/python3.12:${selfBuiltPackages.ngspice-shared}/include:$CPATH"
export NIX_LD_LIBRARY_PATH="${pkgs.python312}/lib:${selfBuiltPackages.ngspice-shared}/lib:$NIX_LD_LIBRARY_PATH"
export PKG_CONFIG_PATH="${selfBuiltPackages.ngspice-shared}/lib/pkgconfig:$PKG_CONFIG_PATH"
# === PDK Configuration ===
export PDK="sky130A"
# === PDK Configuration ===
export PDK="sky130A"
export PDK_VERSION="fa87f8f4bbcc7255b6f0c0fb506960f531ae2392"
export PDK_ROOT="$HOME/.volare"
# === EDA Tools Configuration ===
export PDK_ROOT="$HOME/.volare"
# === EDA Tools Configuration ===
export KLAYOUT_PATH="$PDK_ROOT/$PDK/libs.tech/klayout"
export XSCHEM_USER_LIBRARY_PATH="$PDK_ROOT/$PDK/libs.tech/xschem"
export XSCHEM_LIBRARY_PATH="$PDK_ROOT/$PDK/libs.tech/xschem:${selfBuiltPackages.xschem}/share/xschem/xschem_library"
# === Rust Toolchain Setup ===
export RUSTUP_HOME="$HOME/.rustup"
export CARGO_HOME="$HOME/.cargo"
export PATH="$CARGO_HOME/bin:$PATH"
# === Rust Toolchain Setup ===
export RUSTUP_HOME="$HOME/.rustup"
export CARGO_HOME="$HOME/.cargo"
export PATH="$CARGO_HOME/bin:$PATH"
if ! rustc --version &>/dev/null; then
echo "Installing Rust nightly toolchain..."
rustup install nightly
rustup default nightly
fi
# === Python Dependencies Installation ===
# === Python Dependencies Installation ===
export VENV_DIR="$PROJECT_ROOT/.venv"
if [ -z "$VIRTUAL_ENV" ] || [ "$VIRTUAL_ENV" != "$VENV_DIR" ]; then
if [ ! -d "$VENV_DIR" ]; then
echo "Creating Python virtual environment..."
python3 -m venv "$VENV_DIR"
fi
if [ -z "$VIRTUAL_ENV" ] || [ "$VIRTUAL_ENV" != "$VENV_DIR" ]; then
if [ ! -d "$VENV_DIR" ]; then
echo "Creating Python virtual environment..."
python3 -m venv "$VENV_DIR"
fi
source "$VENV_DIR/bin/activate"
fi
pip install --upgrade pip==24.2 setuptools==75.1.0 wheel==0.44.0
pip install --no-build-isolation -r "$PROJECT_ROOT/requirements.txt"
pip install maturin pytest
for pkg in analog/library/dep_library/gmid analog/library/dep_library/UWASIC-ALG; do
if [ -d "$PROJECT_ROOT/$pkg" ]; then
echo "Installing editable package: $pkg"
python -m pip install -e "$PROJECT_ROOT/$pkg"
fi
done
# === PDK SETUP WITH VOLARE ===
if [ -d "$PDK_ROOT/volare/sky130/versions" ]; then
echo "Cleaning up old PDK versions (keeping $PDK_VERSION)..."
cd "$PDK_ROOT/volare/sky130/versions"
find . -maxdepth 1 -mindepth 1 -type d ! -name "$PDK_VERSION" -exec echo " Removing old version: {}" \; -exec rm -rf {} \;
if [ ! -d "$PDK_ROOT/$PDK" ]; then
echo " Removing potentially invalid cache link: ~/.volare"
rm -rf "$HOME/.volare"
fi
find . -maxdepth 1 -mindepth 1 -type d ! -name "$PDK_VERSION" -exec echo " Removing old version: {}" \; -exec rm -rf {} \;
if [ ! -d "$PDK_ROOT/$PDK" ]; then
echo " Removing potentially invalid cache link: ~/.volare"
rm -rf "$HOME/.volare"
fi
cd "$PROJECT_ROOT"
fi
# Enable the PDK with volare
# Enable the PDK with volare
volare enable --pdk sky130 "$PDK_VERSION"
echo "=== EDA Environment v1.0 ==="
echo ""
echo "System tools available:"
echo " - Python: $(python --version)"
echo " - xschem: $(xschem --version 2>/dev/null || echo 'custom build')"
echo " - yosys: $(yosys -V 2>/dev/null | head -1 || echo 'unknown version')"
echo " - verilator: $(verilator --version 2>/dev/null | head -1 || echo 'unknown version')"
echo " - magic: $(magic --version 2>/dev/null || echo 'custom build ${pkgs.magic-vlsi.version}')"
echo " - PDK: $PDK in $PDK_ROOT"
'';
}