lmjtfy.git / tools / devshell-root
devshell-root13 lines · 644 B · raw
1#!/usr/bin/env bash
2# Registers the devshell as a nix garbage-collection root at .dev/devshell.
3# Without a root, `nix-collect-garbage` deletes the shell's packages, and the
4# next `nix develop` rebuilds them (pitchfork compiles from source, which
5# took the dev stack down for ten minutes on 2026-09-30).
6#
7# One out-link, replaced on every run, so no old shell stays rooted. Runs
8# outside `nix develop` on purpose: it is what makes entering it cheap.
9set -euo pipefail
10cd "$(dirname "$0")/.."
11mkdir -p .dev
12system=$(nix eval --raw --impure --expr builtins.currentSystem)
13exec nix build ".#devShells.${system}.owner" --out-link .dev/devshell