@@ -24,6 +24,7 @@ outputs = { self, nixpkgs, ... }:
2424 unzip
2525
2626 # Build tools
27+ bazelisk
2728 go
2829 python3
2930 python3Packages . pip
@@ -36,54 +37,12 @@ outputs = { self, nixpkgs, ... }:
3637 libusb1
3738 libftdi1
3839 openssl
40+ libp11
3941 ncurses5
4042 udev
4143 stdenv . cc . cc . lib
4244 ] ;
4345
44- # Create a wrapped bazelisk that handles all the environment and sandbox issues
45- bazelisk-wrapped = let
46- # GCC specific library paths (both shared and static)
47- gccLibPath = "${ pkgs . stdenv . cc . cc . lib } /lib" ;
48- in pkgs . writeShellScriptBin "bazelisk" ''
49- export NIX_LIBS="${ pkgs . lib . makeLibraryPath sharedTools } :$gccLibPath"
50- export NIX_INTERPRETER="${ pkgs . stdenv . cc . libc } /lib/ld-linux-x86-64.so.2"
51-
52- # Final Force: Create a local directory in the workspace and COPY the libraries
53- # This ensures the sandbox MUST see them.
54- mkdir -p .nix-libs
55- cp -f $gccLibPath/libgcc_s.so* .nix-libs/ 2>/dev/null
56-
57- # Find libgcc.a in multiple locations and copy it
58- # 1. From Nix GCC
59- find ${ pkgs . stdenv . cc . cc } -name "libgcc.a" -exec cp -f {} .nix-libs/ \; 2>/dev/null
60- # 2. From Host GCC (Ubuntu 24.04)
61- find /usr/lib/gcc -name "libgcc.a" -exec cp -f {} .nix-libs/ \; 2>/dev/null
62-
63- # Create a local bazelrc for nix-specific settings
64- cat > .bazelrc-nix <<EOF
65- # Point to our local physically injected libraries
66- build --linkopt=-L\$PWD/.nix-libs
67- build --action_env=RUSTFLAGS="-L\$PWD/.nix-libs"
68-
69- # Environment variables for actions
70- build --action_env=LD_LIBRARY_PATH="$NIX_LIBS"
71- build --host_action_env=LD_LIBRARY_PATH="$NIX_LIBS"
72- build --action_env=LIBRARY_PATH="$NIX_LIBS"
73- build --host_action_env=LIBRARY_PATH="$NIX_LIBS"
74-
75- # Sandbox mounts
76- build --sandbox_add_mount_pair=/nix:/nix
77- build --sandbox_add_mount_pair=/usr/lib:/usr/lib
78- build --sandbox_add_mount_pair=/lib:/lib
79- build --sandbox_add_mount_pair=/lib64:/lib64
80- EOF
81-
82- export LD_LIBRARY_PATH="$NIX_LIBS:$LD_LIBRARY_PATH"
83- export LIBRARY_PATH="$NIX_LIBS:$LIBRARY_PATH"
84-
85- exec ${ pkgs . bazelisk } /bin/bazelisk --bazelrc=.bazelrc-nix "$@"
86- '' ;
8746 in
8847 {
8948 # 1. For bare-metal deployment (future)
9655
9756 # 2. For developers and Hybrid CI (current)
9857 devShells . ${ system } . default = pkgs . mkShell {
99- buildInputs = sharedTools ++ [ bazelisk-wrapped ] ;
58+ buildInputs = sharedTools ;
10059
10160 shellHook = ''
10261 echo "OpenTitan Provisioning Development Environment"
10362 export OT_PROV_SHELL=1
10463
105- # Set defaults for other tools (like go or python)
64+ # Configure OpenSSL to find the pkcs11 engine provided by libp11
65+ export OPENSSL_ENGINES="${ pkgs . libp11 } /lib/engines"
66+
67+ # Basic LD paths to ensure tools run correctly in the shell
10668 export LD_LIBRARY_PATH="${ pkgs . lib . makeLibraryPath sharedTools } :$LD_LIBRARY_PATH"
10769 export NIX_LD_LIBRARY_PATH="${ pkgs . lib . makeLibraryPath sharedTools } "
10870 export NIX_LD="${ pkgs . stdenv . cc . libc } /lib/ld-linux-x86-64.so.2"
10971 '' ;
11072 } ;
11173
74+
11275 } ;
11376}
0 commit comments