Skip to main content

cybercore/
paths.rs

1//! Canonical filesystem locations, sourced from the schema. Every
2//! project that currently hardcodes `~/.sysops`, `~/.cargo-target`,
3//! or similar should call these instead — one edit to the schema
4//! updates every consuming project on its next build.
5
6use crate::schema;
7use std::path::PathBuf;
8
9fn expand_home(path: &str) -> PathBuf {
10    if let Some(rest) = path.strip_prefix("~/") {
11        let home = std::env::var_os("HOME")
12            .map(PathBuf::from)
13            .unwrap_or_else(|| PathBuf::from("/"));
14        home.join(rest)
15    } else {
16        PathBuf::from(path)
17    }
18}
19
20pub fn sysops_root() -> PathBuf {
21    expand_home(&schema::load().paths.sysops_root)
22}
23
24pub fn cargo_target_root() -> PathBuf {
25    expand_home(&schema::load().paths.cargo_target_root)
26}
27
28pub fn arch_sys_root() -> PathBuf {
29    expand_home(&schema::load().paths.arch_sys_root)
30}
31
32pub fn omarchy_config_root() -> PathBuf {
33    expand_home(&schema::load().paths.omarchy_config_root)
34}