Optionally prevent relevant nix store paths from being GC'ed
[?]
Mar 24, 2023, 9:35 AM
WNFTZY3MQBNYY2V6XEI2DHZEZGRUMVWK23IN34YW3OISLSJHGFYQCDependencies
- [2]
4A2DSMIMClean up nix-container-demo-helper.sh - [3]
EINBKIWAUpdate README - [4]
AG72J7RHAdd .gitlab-ci.yml - [5]
52F4Q6CJUpdate README - [6]
P34QQPLUPin shellcheck / pygmentize - [7]
JGZ7GBCLAdd linting - [8]
VXZ5QMIEFix CI - [9]
63ZV3FMRTweak CI - [10]
UWWBKZ4RImprove README - [11]
W2G433QURefactor libdemo and flakeref for nix run commands - [12]
SNO57YN4Move libdemo and fix linting - [13]
M5U5PAX7Add wrapper script, improve libdemo - [14]
HCY72TQRImprove linting - [*]
7AUC4NKIInitial commit
Change contents
- edit in demo-full.sh at line 9[4.165]→[4.1:30](∅→∅),[4.319]→[4.1:30](∅→∅),[4.10]→[4.1:30](∅→∅),[4.30]→[4.320:374](∅→∅),[4.374]→[4.166:343](∅→∅)
echo "${BASH_SOURCE[0]}"${shellcheck_cmd} "${BASH_SOURCE[0]}" || return 1echo "$(dirname "${BASH_SOURCE[0]}")/bash/nix-container-demo-helper.sh"${shellcheck_cmd} "$(dirname "${BASH_SOURCE[0]}")/bash/nix-container-demo-helper.sh" || return 1 - replacement in demo-full.sh at line 10
for f in $(find "$(dirname "${BASH_SOURCE[0]}")" -name 'demo*.sh' | sort); dofor f in $(find "$(dirname "${BASH_SOURCE[0]}")" -name '*.sh' | sort); do - edit in demo-full.sh at line 29
echo " -l|--lint: run linter on shell files"echo " -a|--auto: run in automatic mode (no pausing)" - edit in demo-full.sh at line 30
echo " -a|--auto: run in automatic mode (no pausing)"echo " -g|--gcroots: create Nix garbage collector roots for nix build/run/develop outputs"echo " -l|--lint: run linter on shell files" - edit in demo-full.sh at line 37
do_nix_make_gcroots=0 - replacement in demo-full.sh at line 41
-l|--lint)do_lint=1-a|--auto)do_interactive=0 - replacement in demo-full.sh at line 45
-a|--auto)do_interactive=0-g|--gcroots)do_nix_make_gcroots=1 - edit in demo-full.sh at line 52
;;-l|--lint)do_lint=1shift - replacement in demo-full.sh at line 62
POSITIONAL_ARGS+=("$1") # save positional argPOSITIONAL_ARGS+=("$1") - replacement in demo-full.sh at line 71
LIBDEMO_INTERACTIVE="${do_interactive}" runWRAP_NIX_MAKE_GCROOTS="${do_nix_make_gcroots}" LIBDEMO_INTERACTIVE="${do_interactive}" run - edit in bash/nix-container-demo-helper.sh at line 35
}__nix_make_gcroot() {local -r storepath="${1}"echo "Preventing GC for '${storepath}'"local -r gcroot="/nix/var/nix/gcroots/per-user/${USER}/nix-container-demo-$(basename "${storepath}")"rm -f "${gcroot}"ln -s "${storepath}" "${gcroot}"}nix() {if [ "${WRAP_NIX_MAKE_GCROOTS:-0}" = 0 ]; thencommand nix "$@"elselocal -r action=$1shiftlocal nix_args=()local args=()local __encountered_dashes=0while [ $# -gt 0 ]; doif [ "$1" == "--" ]; then__encountered_dashes=1elif [ "${__encountered_dashes}" = 1 ]; thenargs+=("$1")elsenix_args+=("$1")fishiftdonelocal storepathif [ "${action}" = run ]; thencommand nix run "${nix_args[@]}" -- "${args[@]}"for storepath in $(command nix build "${nix_args[@]}" --no-link --print-out-paths); do__nix_make_gcroot "${storepath}"doneelif [ "${action}" = build ]; thencommand nix build "${nix_args[@]}"for storepath in $(command nix build "${nix_args[@]}" --no-link --print-out-paths); do__nix_make_gcroot "${storepath}"doneelif [ "${action}" = develop ]; then# shellcheck disable=SC2016storepath="$(command nix develop "${nix_args[0]}" --command bash -c 'echo ${NIX_GCROOT}' 2>/dev/null)"__nix_make_gcroot "${storepath}"command nix develop "${nix_args[@]}"elsecommand nix "${action}" "${nix_args[@]}"fifi - replacement in README.md at line 50[3.1893]→[4.581:620](∅→∅),[4.581]→[4.581:620](∅→∅),[4.620]→[3.1894:1942](∅→∅),[3.1942]→[4.655:682](∅→∅),[4.655]→[4.655:682](∅→∅)
-l|--lint: run linter on shell files-a|--auto: run in automatic mode (no pausing)-h|--help|-?: Show usage-h|--help|-?: Show usage"-a|--auto: run in automatic mode (no pausing)"-g|--gcroots: create Nix garbage collector roots for nix build/run/develop outputs"-l|--lint: run linter on shell files" - edit in README.md at line 56
⚠ The garbage collector roots are of the form `/nix/var/nix/gcroots/per-user/${USER}/nix-container-demo-*`, you may want to clean them if this demo changes. - edit in README.md at line 63
* `WRAP_NIX_MAKE_GCROOTS`: enable (1) or disable (0, default) creation of Nix garbage collector roots for nix build/run/develop outputs. - replacement in .gitlab-ci.yml at line 13
- CLICOLOR_FORCE=1 ./demo-full.sh -a- export USER="$(whoami)"- rm -f /nix/var/nix/gcroots/per-user/${USER}/nix-container-demo-*- CLICOLOR_FORCE=1 ./demo-full.sh --auto --gcroots- ls -1dtr /nix/var/nix/gcroots/per-user/${USER}/nix-container-demo-*