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 run is switched off, whether today’s attempt already happened, whether another shell holds this checkout, and whether the two files carry uncommitted edits. The lock and the stamp live 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.
SWITCH_VAR
The operator’s own off switch, 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.
in_ci
Whether a CI variable is set to anything but an explicit no.
switched_off
Whether the operator switched the sync off with RK_DEVSHELL_SYNC=0.
today
Today, as the first ten characters of the UTC clock.
two_files_dirty
Whether flake.nix or flake.lock carries uncommitted edits.
write_stamp
Stamp today’s attempt for one checkout, before the attempt.