Expand description
Path resolution for dodot.
Pather is dodot’s single source of truth for every filesystem
coordinate the rest of the codebase touches: $HOME, the dotfiles
repo root, the XDG data/config/cache directories, and per-pack and
per-handler subdirectories. Two reasons it’s a trait, not free
functions:
-
Testability. Constructing a
Patherwhose roots all live under atempfile::TempDirlets every command run end-to-end against a real filesystem without ever touching the user’s actual$HOME. Thetesting::TempEnvironmentbuilder does exactly this. -
Centralisation of OS-shaped policy. The XDG fallback chain, the
DOTFILES_ROOTenv-var lookup, and (planned, perdocs/proposals/macos-paths.lex) the macOSapp_support_dirselection all live in one place. The resolver, the symlink handler, andadopt’s source-path inference all consult the same accessors — drift between them is impossible by construction.
§Adopt source-root invariants
The inference function in commands::adopt::infer needs stable
root strings it can prefix-match against canonicalised source
paths. The accessors exposed here meet two requirements that make
that work safely:
-
home_dir()andxdg_config_home()return paths thatstd::fs::canonicalizeresolves to themselves on a real filesystem (they’re real directories, not synthetic constants). This is what makes the/var↔/private/varmacOS equivalence collapse cleanly when both a source and a root are canonicalised before comparison. -
On the default config (no
XDG_CONFIG_HOMEset),xdg_config_home()ishome_dir().join(".config")— i.e. nested under$HOME. Inference must check the more-specific (XDG) root before HOME so~/.config/nvim/init.luamatches XDG, not “nested under HOME”. That’s enforced by the inference function, not byPather, but the nesting shape originates here.
Structs§
- XdgPather
- XDG-compliant path resolver.
- XdgPather
Builder - Builder for
XdgPather.
Traits§
- Pather
- Provides all path calculations for dodot.