Skip to main content

Module path

Module path 

Source
Expand description

Centralized path resolution (normalize, resolve relative, import). Centralized path resolution for the Nix evaluator.

All path operations (normalization, relative resolution, import resolution) go through this module to ensure consistent behavior.

Functions§

canon_abs
Canonicalize an ABSOLUTE path string exactly the way CppNix’s canonPath does — the byte-for-byte semantics of a Nix path value.
dematerialize
REVERSE of materialize for SOURCE POSITIONS: given a REAL on-disk path (a fetcher-cache ~/.cache/sui/inputs/… file that eval actually read from), return the flake input’s /nix/store/<narhash>-source STORE-PATH equivalent (with the same relative subpath appended); returns path unchanged when it is not under any registered input’s cache dir.
dematerialize_str
Convenience: dematerialize a &str path, returning an owned String.
materialize
If path lies under a registered flake-input store-path prefix, rewrite that prefix to the input’s real on-disk read_dir; otherwise return path unchanged. This is a FILESYSTEM-READ-ONLY redirect — callers use the result to touch disk, never to build a value the evaluator observes.
materialize_str
Convenience: materialize a &str path, returning an owned String.
normalize
Normalize a path by removing . components and resolving .. components. Unlike canonicalize(), this doesn’t require the path to exist on disk.
register_fetched_source
Register a builtins.fetch* result directory with the store-path NAME CppNix would give its copied-to-store tree ("source" for fetchGit/fetchTree/fetchTarball). Idempotent per read_dir. Does not affect any string value — only the name a later copy-to-store coercion of this exact path assigns to its store path.
register_input_source
Register a fetched flake-input source tree so subsequent filesystem reads under its /nix/store/<narhash>-source store path resolve to the real on-disk read_dir. Idempotent per store_path. Does not affect any string value — only where reads land on disk.
resolve_import
Resolve an import path.
resolve_relative
Resolve a relative path against a base directory, normalizing the result.
source_name_for_read_dir
Reverse of materialize for the copy-to-store NAMING rule: given a REAL on-disk directory (the fetcher-cache read_dir a materialize already resolved to, then canonicalized), return the store-path BASENAME of the flake input that tree belongs to — i.e. CppNix’s -source name — when real IS that input’s whole tree root.