Skip to content

Commit 8f72adb

Browse files
committed
feat: mount ~/.codex into local sandboxes for Codex CLI auth
1 parent 7aead13 commit 8f72adb

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

cmd/cw/lima_backend.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,13 @@ func limaCreateCommandArgs(instance *cwconfig.LocalInstance) []string {
177177
strconv.Quote(claudeDir),
178178
)
179179
}
180+
codexDir := filepath.Join(homeDir, ".codex")
181+
if _, err := localOsStat(codexDir); err == nil {
182+
mounts += fmt.Sprintf(
183+
`,{"location":%s,"mountPoint":"/home/{{.User}}.guest/.codex","writable":true}`,
184+
strconv.Quote(codexDir),
185+
)
186+
}
180187

181188
mountSet := ".mounts=[" + mounts + "]"
182189

@@ -294,6 +301,7 @@ func createLocalLimaInstance(instance *cwconfig.LocalInstance) error {
294301
dockerArgs = append(dockerArgs,
295302
"-v", filepath.Join(vmHome, ".config", "gh")+":/home/codewire/.config/gh:ro",
296303
"-v", "/mnt/host-ssh:/home/codewire/.ssh:ro",
304+
"-v", filepath.Join(vmHome, ".codex")+":/home/codewire/.codex",
297305
)
298306
dockerArgs = append(dockerArgs,
299307
"--workdir", "/workspace",

cmd/cw/local_cmd.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -743,6 +743,13 @@ func createLocalIncusInstance(instance *cwconfig.LocalInstance) error {
743743
return err
744744
}
745745
}
746+
codexDir := filepath.Join(homeDir, ".codex")
747+
if _, statErr := localOsStat(codexDir); statErr == nil {
748+
if err := runIncus("config", "device", "add", instance.RuntimeName, "codex-config", "disk",
749+
"source="+codexDir, "path=/home/codewire/.codex"); err != nil {
750+
return err
751+
}
752+
}
746753
}
747754
if err := runIncus("start", instance.RuntimeName); err != nil {
748755
return err
@@ -780,6 +787,10 @@ func createLocalDockerInstance(instance *cwconfig.LocalInstance) error {
780787
if _, err := localOsStat(sshDir); err == nil {
781788
args = append(args, "--volume", sshDir+":/home/codewire/.ssh:ro")
782789
}
790+
codexDir := filepath.Join(homeDir, ".codex")
791+
if _, err := localOsStat(codexDir); err == nil {
792+
args = append(args, "--volume", codexDir+":/home/codewire/.codex")
793+
}
783794
}
784795
if instance.CPU > 0 {
785796
args = append(args, "--cpus", formatDockerCPUs(instance.CPU))

0 commit comments

Comments
 (0)