|
78 | 78 | devShells.default = pkgs.mkShell { |
79 | 79 | nativeBuildInputs = withObelisk; |
80 | 80 | }; |
81 | | - devShells.sandbox = pkgs.mkShell { |
82 | | - packages = commonDeps ++ ( with pkgs; [ |
83 | | - codex |
84 | | - gemini-cli |
85 | | - claude-code |
86 | | - bubblewrap |
87 | | - # tools |
88 | | - git |
89 | | - gh |
90 | | - curl |
91 | | - helix |
92 | | - wget |
93 | | - htop |
94 | | - procps |
95 | | - ripgrep |
96 | | - which |
97 | | - less |
98 | | - ]); |
99 | | - shellHook = '' |
100 | | - CURRENT_DIR=$(pwd) |
101 | | -
|
102 | | - # SSL/Network Fixes |
103 | | - export SSL_CERT_FILE="${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt" |
104 | | - export NIX_SSL_CERT_FILE=$SSL_CERT_FILE |
105 | | - REAL_RESOLV=$(realpath /etc/resolv.conf) |
106 | | - REAL_HOSTS=$(realpath /etc/hosts) |
107 | | - REAL_GITCONFIG=$(realpath "$HOME/.gitconfig") |
108 | | -
|
109 | | - # Construct mocked /run/current-system/sw/bin |
110 | | - MOCKED_SYSTEM_BIN=$(mktemp -d) |
111 | | - # Iterate through current PATH and symlink executables. |
112 | | - # We use 'ln -s' without '-f' (force) so that the FIRST entry found |
113 | | - # in the PATH (highest priority) wins, mimicking actual shell behavior. |
114 | | - IFS=':' read -ra PATH_DIRS <<< "$PATH" |
115 | | - for dir in "''${PATH_DIRS[@]}"; do |
116 | | - if [ -d "$dir" ]; then |
117 | | - ln -s "$dir"/* "$MOCKED_SYSTEM_BIN/" 2>/dev/null || true |
118 | | - fi |
119 | | - done |
120 | | -
|
121 | | - BWRAP_CMD=( |
122 | | - ${pkgs.bubblewrap}/bin/bwrap |
123 | | - --unshare-all |
124 | | - --share-net |
125 | | - --die-with-parent |
126 | | - # --- Essential Binds --- |
127 | | - --ro-bind /nix /nix |
128 | | - --proc /proc |
129 | | - --dev /dev |
130 | | - --tmpfs /tmp |
131 | | - # Tools need these to know "who" is running the process |
132 | | - --ro-bind /etc/passwd /etc/passwd |
133 | | - --ro-bind /etc/group /etc/group |
134 | | - # --- Network --- |
135 | | - --ro-bind "$REAL_RESOLV" /etc/resolv.conf |
136 | | - --ro-bind "$REAL_HOSTS" /etc/hosts |
137 | | - # Git |
138 | | - --ro-bind "$REAL_GITCONFIG" /tmp/.gitconfig |
139 | | - # Claude |
140 | | - --bind $HOME/.claude /tmp/.claude |
141 | | - --bind $HOME/.claude.json /tmp/.claude.json |
142 | | - # Cargo |
143 | | - --bind $HOME/.cargo /tmp/.cargo |
144 | | - # --- Project Mount --- |
145 | | - --dir /workspace |
146 | | - --bind "$CURRENT_DIR" /workspace |
147 | | - --chdir /workspace |
148 | | - # --- Mocked System Bin --- |
149 | | - # Create the directory structure in the sandbox |
150 | | - --dir /run/current-system/sw/bin |
151 | | - # Bind our constructed temp folder to it |
152 | | - --ro-bind "$MOCKED_SYSTEM_BIN" /run/current-system/sw/bin |
153 | | - --ro-bind "$MOCKED_SYSTEM_BIN" /usr/bin |
154 | | - # --- Environment --- |
155 | | - --setenv PS1 "[BWRAP] \w> " |
156 | | - --setenv HOME /tmp |
157 | | - --setenv TMPDIR /tmp |
158 | | - --setenv TEMP /tmp |
159 | | - --setenv CARGO_TARGET_DIR target-sandbox |
160 | | - ) |
161 | | - exec "''${BWRAP_CMD[@]}" ${pkgs.bashInteractive}/bin/bash -l +m |
162 | | - ''; |
163 | | - }; |
164 | 81 | devShells.cloudflared = pkgs.mkShell { |
165 | 82 | nativeBuildInputs = withObelisk ++ [ pkgs.cloudflared ]; |
166 | 83 | }; |
|
0 commit comments