Skip to main content

Module paths

Module paths 

Source
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:

  1. Testability. Constructing a Pather whose roots all live under a tempfile::TempDir lets every command run end-to-end against a real filesystem without ever touching the user’s actual $HOME. The testing::TempEnvironment builder does exactly this.

  2. Centralisation of OS-shaped policy. The XDG fallback chain, the DOTFILES_ROOT env-var lookup, and (planned, per docs/proposals/macos-paths.lex) the macOS app_support_dir selection all live in one place. The resolver, the symlink handler, and adopt’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() and xdg_config_home() return paths that std::fs::canonicalize resolves to themselves on a real filesystem (they’re real directories, not synthetic constants). This is what makes the /var/private/var macOS equivalence collapse cleanly when both a source and a root are canonicalised before comparison.

  • On the default config (no XDG_CONFIG_HOME set), xdg_config_home() is home_dir().join(".config") — i.e. nested under $HOME. Inference must check the more-specific (XDG) root before HOME so ~/.config/nvim/init.lua matches XDG, not “nested under HOME”. That’s enforced by the inference function, not by Pather, but the nesting shape originates here.

Structs§

XdgPather
XDG-compliant path resolver.
XdgPatherBuilder
Builder for XdgPather.

Traits§

Pather
Provides all path calculations for dodot.