Tweak --gcroots

[?]
Apr 3, 2023, 7:44 PM
U6EHWR7YKTWFC3OLM42N22EP6WUNLFJD5O62JSVWWIF4AUY7FNXAC

Dependencies

  • [2] ZSVCCJBX Fixes for CI
  • [3] 4A2DSMIM Clean up nix-container-demo-helper.sh
  • [4] HCY72TQR Improve linting
  • [5] AG72J7RH Add .gitlab-ci.yml
  • [6] 52F4Q6CJ Update README
  • [7] EINBKIWA Update README
  • [8] W2G433QU Refactor libdemo and flakeref for nix run commands
  • [9] WNFTZY3M Optionally prevent relevant nix store paths from being GC'ed
  • [*] M5U5PAX7 Add wrapper script, improve libdemo
  • [*] 7AUC4NKI Initial commit

Change contents

  • replacement in demo-full.sh at line 34
    [3.144][3.144:240]()
    echo " -g|--gcroots: create Nix garbage collector roots for nix build/run/develop outputs"
    [3.144]
    [3.240]
    echo " -g|--gcroots <create|delete|recreate|print>: (re)create, delete, or print Nix garbage collector roots for nix build/run/develop outputs"
  • replacement in demo-full.sh at line 40
    [3.609][3.291:313]()
    do_nix_make_gcroots=0
    [3.609]
    [3.609]
    nix_gcroots_action=
  • replacement in demo-full.sh at line 49
    [3.379][3.379:411]()
    do_nix_make_gcroots=1
    [3.379]
    [3.758]
    if [ "${2:-}" = create ] || [ "${2:-}" = delete ] || [ "${2:-}" = recreate ] || [ "${2:-}" = print ]; then
    nix_gcroots_action=$2
    else
    echo "Unknown or missing --gcroots option '$2'"
    exit 1
    fi
  • edit in demo-full.sh at line 56
    [3.774]
    [3.774]
    shift
  • edit in demo-full.sh at line 80
    [3.1090]
    [3.514]
    do_nix_make_gcroots=0
    if [ "${nix_gcroots_action}" = delete ]; then
    __nix_clean_gcroots
    exit 0
    elif [ "${nix_gcroots_action}" = print ]; then
    __nix_print_gcroots
    exit 0
    elif [ "${nix_gcroots_action}" = recreate ]; then
    __nix_clean_gcroots
    do_nix_make_gcroots=1
    elif [ "${nix_gcroots_action}" = create ]; then
    do_nix_make_gcroots=1
    fi
  • edit in demo-full.sh at line 94
    [3.609]
    [3.1138]
    if [ "${nix_gcroots_action}" = create ] || [ "${nix_gcroots_action}" = recreate ]; then
    __nix_print_gcroots
    fi
  • edit in bash/nix-container-demo-helper.sh at line 32
    [3.623]
    [3.623]
    __nix_gcroot_dir="/nix/var/nix/gcroots/per-user/${USER}"
    __nix_gcroot_prefix=nix-container-demo
  • replacement in bash/nix-container-demo-helper.sh at line 39
    [3.732][3.732:842]()
    local -r gcroot="/nix/var/nix/gcroots/per-user/${USER}/nix-container-demo-$(basename "${storepath}")"
    [3.732]
    [3.842]
    local -r gcroot="${__nix_gcroot_dir}/${__nix_gcroot_prefix}-$(basename "${storepath}")"
  • edit in bash/nix-container-demo-helper.sh at line 42
    [3.909]
    [3.909]
    }
    __nix_print_gcroots() {
    echo "Printing existing GC roots"
    find "${__nix_gcroot_dir}" -name "${__nix_gcroot_prefix}-*" -print | sed "s|${__nix_gcroot_dir}/||"
    }
    __nix_clean_gcroots() {
    echo "Removing existing GC roots"
    __nix_print_gcroots
    find "${__nix_gcroot_dir}" -name "${__nix_gcroot_prefix}-*" -delete
  • replacement in README.md at line 55
    [3.2585][3.2585:2671]()
    -g|--gcroots: create Nix garbage collector roots for nix build/run/develop outputs"
    [3.2585]
    [3.2671]
    -g|--gcroots <create|delete|recreate|print>: (re)create, delete, or print Nix garbage collector roots for nix build/run/develop outputs"
  • replacement in .gitlab-ci.yml at line 13
    [3.3074][2.451:522](),[2.522][3.3146:3201](),[3.3146][3.3146:3201](),[3.3201][2.523:631]()
    - rm -f /nix/var/nix/gcroots/per-user/${USER}/nix-container-demo-*
    - CLICOLOR_FORCE=1 ./demo-full.sh --auto --gcroots
    - for f in $(ls -1dtr /nix/var/nix/gcroots/per-user/${USER}/nix-container-demo-*); do basename $f; done
    [3.3074]
    [3.151]
    - CLICOLOR_FORCE=1 ./demo-full.sh --auto --gcroots recreate