feat: added mounts in config file

This commit is contained in:
robcholz
2026-02-07 15:41:10 -05:00
parent 57798d2647
commit b3ac485ccf
4 changed files with 38 additions and 15 deletions
+1 -1
View File
@@ -45,7 +45,7 @@
8. [ ] setup cli commands.
1. [x] Organize all the params.
2. [x] Remove old cli.
3. [ ] add an actual config file.
3. [x] add an actual config file.
4. [ ] set up the cli.
9. [ ] fix ui overlap, and consistency issue.
10. [ ] intensive integration test.
+19 -1
View File
@@ -41,7 +41,7 @@ impl Default for BoxConfig {
Self {
cpu_count: default_cpu_count(),
ram_mb: default_ram_mb(),
mounts: Vec::new(),
mounts: default_mounts(),
}
}
}
@@ -71,6 +71,24 @@ fn default_auto_shutdown_ms() -> u64 {
DEFAULT_AUTO_SHUTDOWN_MS
}
fn default_mounts() -> Vec<String> {
let home = match std::env::var("HOME") {
Ok(home) => PathBuf::from(home),
Err(_) => return Vec::new(),
};
let mut mounts = Vec::new();
let codex_host = home.join(".codex");
if codex_host.exists() {
mounts.push("~/.codex:/usr/local/codex:read-write".to_string());
}
let claude_host = home.join(".claude");
if claude_host.exists() {
mounts.push("~/.claude:/usr/local/claude:read-write".to_string());
}
mounts
}
pub fn config_path(project_root: &Path) -> PathBuf {
project_root.join(CONFIG_FILENAME)
}
+14 -12
View File
@@ -83,7 +83,7 @@ impl DirectoryShare {
if parts.len() < 2 || parts.len() > 3 {
return Err(format!("Invalid mount spec: {spec}").into());
}
let host = PathBuf::from(parts[0]);
let host = expand_tilde_path(parts[0]);
let guest = PathBuf::from(parts[1]);
let read_only = if parts.len() == 3 {
match parts[2] {
@@ -117,6 +117,19 @@ impl DirectoryShare {
}
}
fn expand_tilde_path(value: &str) -> PathBuf {
if let Some(stripped) = value.strip_prefix("~/") {
if let Ok(home) = env::var("HOME") {
return PathBuf::from(home).join(stripped);
}
} else if value == "~" {
if let Ok(home) = env::var("HOME") {
return PathBuf::from(home);
}
}
PathBuf::from(value)
}
pub struct VmArg {
pub cpu_count: usize,
pub ram_bytes: u64,
@@ -206,17 +219,6 @@ where
);
directory_shares.push(mise_directory_share);
// Add default shares, if they exist
for share in [
DirectoryShare::new(home.join(".codex"), "/usr/local/codex".into(), false),
DirectoryShare::new(home.join(".claude"), "/usr/local/claude".into(), false),
]
.into_iter()
.flatten()
{
directory_shares.push(share)
}
}
directory_shares.extend(extra_directory_shares);
+4 -1
View File
@@ -1,7 +1,10 @@
[box]
cpu_count = 2
ram_mb = 2048
mounts = []
mounts = [
"~/.codex:/usr/local/codex:read-write",
"~/.claude:/usr/local/claude:read-write",
]
[supervisor]
auto_shutdown_ms = 20000