Skip to main content

Module guard

Module guard 

Source
Expand description

The gates around the devshell transaction, so the .envrc line is safe on every directory entry.

Each gate answers one question before anything fetches or spawns: whether the check is switched off, whether a sync runs inside an .envrc evaluation, whether another shell holds this checkout, and whether the two files carry uncommitted edits. The lock lives under the state root, keyed per checkout — not in the target, where an untracked file is noise, and not in .git/, which belongs to git.

Structs§

Lock
The held single-writer lock; removed on drop.

Enums§

Acquired
What acquisition found.

Constants§

CI_VARS
The variables a CI runner exports; any of them switches the sync off.
IN_ENVRC_VAR
The variable direnv’s stdlib exports while it evaluates an .envrc, and leaves out of the environment it exports afterward.
SWITCH_VAR
The operator’s own off switch for the version check, read from the environment .envrc.local exports.

Functions§

acquire
Take the checkout’s lock, atomically through O_EXCL. A lock whose owner is provably gone — or, where procfs cannot judge, older than the grace period — is removed and the take retried once.
files_dirty
Whether any of the named files carries uncommitted edits: the flake pair for the flake manager, the one manager file otherwise.
in_ci
Whether a CI variable is set to anything but an explicit no.
in_envrc
Whether this run is inside an .envrc evaluation, where a pin move would be automatic rather than the operator’s act.
switched_off
Whether the operator switched the sync off with RK_DEVSHELL_SYNC=0.