summaryrefslogtreecommitdiff
path: root/hostnix/mojo/packages/claude-code/default.nix
blob: 2e3fd3532db5f05d2ebb11b5534fcec5abc8c6ce (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
{ writeShellScriptBin, claude-code }:

writeShellScriptBin "claude" ''
  if [[ $HOME/ = ''${PWD%/}/* ]]; then
    echo "fatal: refusing to allow access to $PWD" >&2
    exit 1
  fi

  git_dir="$(git rev-parse --absolute-git-dir 2>/dev/null)"
  jj_root="$(jj root --ignore-working-copy 2>/dev/null)"

  exec /usr/bin/sandbox-exec -f ${./claude.sb} \
    -D TARGET_DIR="$(realpath "$PWD")" \
    -D TMP_DIR=/tmp \
    -D HOME_DIR="$HOME" \
    -D CACHE_DIR="$HOME/.cache" \
    -D GIT_DIR="''${git_dir:-$PWD/.git}" \
    -D JJ_DIR="''${jj_root:-$PWD}/.jj" \
    ${claude-code}/bin/claude \
    --allow-dangerously-skip-permissions "$@"
''