Automagically add --rebuild to nix build commands in interactive mode

[?]
Apr 11, 2023, 9:58 PM
FYBNOJLTCRNCVUO65HCB5KI6OVOBU5AWG5RKMENQEFDPWZYKCVIAC

Dependencies

  • [2] 7KPFEFGS Skip rebuilds in automatic mode
  • [3] U6EHWR7Y Tweak --gcroots
  • [4] VGNXPE5D Only rebuild the vm integration test in interactive mode
  • [5] 3GPSC2KX Add compatibility checks for fancy parts of the demos
  • [6] VUARRVTI Clean up strings
  • [7] ZV5WPO25 Extend 02
  • [8] WNFTZY3M Optionally prevent relevant nix store paths from being GC'ed
  • [9] BH5XPS7C Add 07-vm-integration test
  • [10] TEQJC3HX Add 03-nix-container
  • [11] VXZ5QMIE Fix CI
  • [12] W2G433QU Refactor libdemo and flakeref for nix run commands
  • [*] VMUKZQZR Work on 02-nix-build

Change contents

  • replacement in bash/nix-container-demo-helper.sh at line 37
    [5.650][5.650:732](),[5.732][3.1115:1211](),[3.1211][5.842:909](),[5.842][5.842:909]()
    local -r storepath="${1}"
    echo "Preventing GC for '${storepath}'"
    local -r gcroot="${__nix_gcroot_dir}/${__nix_gcroot_prefix}-$(basename "${storepath}")"
    rm -f "${gcroot}"
    ln -s "${storepath}" "${gcroot}"
    [5.650]
    [3.1212]
    if [ "${WRAP_NIX_MAKE_GCROOTS:-0}" = 1 ]; then
    local -r storepath="${1}"
    echo "Preventing GC for '${storepath}'"
    local -r gcroot="${__nix_gcroot_dir}/${__nix_gcroot_prefix}-$(basename "${storepath}")"
    rm -f "${gcroot}"
    ln -s "${storepath}" "${gcroot}"
    fi
  • replacement in bash/nix-container-demo-helper.sh at line 58
    [5.928][5.928:1074]()
    if [ "${WRAP_NIX_MAKE_GCROOTS:-0}" = 0 ]; then
    command nix "$@"
    else
    local -r action=$1
    shift
    [5.928]
    [5.1074]
    local -r action=$1
    shift
  • replacement in bash/nix-container-demo-helper.sh at line 61
    [5.1075][5.1075:1131]()
    local nix_args=()
    local args=()
    [5.1075]
    [5.1131]
    local nix_args=()
    local args=()
  • replacement in bash/nix-container-demo-helper.sh at line 64
    [5.1132][5.1132:1503]()
    local __encountered_dashes=0
    while [ $# -gt 0 ]; do
    if [ "$1" == "--" ]; then
    __encountered_dashes=1
    elif [ "${__encountered_dashes}" = 1 ]; then
    args+=("$1")
    else
    nix_args+=("$1")
    fi
    shift
    done
    [5.1132]
    [5.1503]
    local __encountered_dashes=0
    while [ $# -gt 0 ]; do
    if [ "$1" == "--" ]; then
    __encountered_dashes=1
    elif [ "${__encountered_dashes}" = 1 ]; then
    args+=("$1")
    else
    nix_args+=("$1")
    fi
    shift
    done
  • replacement in bash/nix-container-demo-helper.sh at line 76
    [5.1504][5.1504:2304]()
    local storepath
    if [ "${action}" = run ]; then
    command nix run "${nix_args[@]}" -- "${args[@]}"
    for storepath in $(command nix build "${nix_args[@]}" --no-link --print-out-paths); do
    __nix_make_gcroot "${storepath}"
    done
    elif [ "${action}" = build ]; then
    command nix build "${nix_args[@]}"
    for storepath in $(command nix build "${nix_args[@]}" --no-link --print-out-paths); do
    __nix_make_gcroot "${storepath}"
    done
    elif [ "${action}" = develop ]; then
    # shellcheck disable=SC2016
    storepath="$(command nix develop "${nix_args[0]}" --command bash -c 'echo ${NIX_GCROOT}' 2>/dev/null)"
    [5.1504]
    [5.2304]
    local storepath
    if [ "${action}" = run ]; then
    command nix run "${nix_args[@]}" -- "${args[@]}"
    for storepath in $(command nix build "${nix_args[@]}" --no-link --print-out-paths); do
  • replacement in bash/nix-container-demo-helper.sh at line 81
    [5.2353][5.2353:2406]()
    command nix develop "${nix_args[@]}"
    [5.2353]
    [5.2406]
    done
    elif [ "${action}" = build ]; then
    if __libdemo_is_interactive && [ -e "$(nix eval --raw "${nix_args[0]}")" ]; then
    command nix build "${nix_args[@]}" --rebuild
  • replacement in bash/nix-container-demo-helper.sh at line 86
    [5.2423][5.2423:2480]()
    command nix "${action}" "${nix_args[@]}"
    [5.2423]
    [5.2480]
    command nix build "${nix_args[@]}"
  • edit in bash/nix-container-demo-helper.sh at line 88
    [5.2495]
    [5.2495]
    for storepath in $(command nix build "${nix_args[@]}" --no-link --print-out-paths); do
    __nix_make_gcroot "${storepath}"
    done
    elif [ "${action}" = develop ]; then
    # shellcheck disable=SC2016
    storepath="$(command nix develop "${nix_args[0]}" --command bash -c 'echo ${NIX_GCROOT}' 2>/dev/null)"
    __nix_make_gcroot "${storepath}"
    command nix develop "${nix_args[@]}"
    else
    command nix "${action}" "${nix_args[@]}"
  • edit in 07-vm-integration-test/demo.sh at line 40
    [5.5940][5.5940:5994](),[5.5994][4.18:52]()
    n "Force a rebuild so we can see what is happening"
    i nix build "${dir}" -L --rebuild
  • edit in 03-nix-container/demo.sh at line 14
    [5.2723][5.5453:5516](),[5.5453][5.5453:5516](),[5.5516][5.2724:2773]()
    x nix build "${dir}#container" -L -o "${dir}/result-container"
    , "Let's rebuild so we can see what happened..."
  • replacement in 03-nix-container/demo.sh at line 15
    [5.2862][2.37:110]()
    i nix build "${dir}#container" -L -o "${dir}/result-container --rebuild"
    [5.2862]
    [5.5590]
    x nix build "${dir}#container" -L -o "${dir}/result-container"
  • edit in 02-nix-build/demo.sh at line 34
    [5.4682]
    [5.552]
    n "If the package was already built and put into the Nix store before this would normally be a no-op,"
    , "but for the purposes of an interactive demo we will rebuild it, so we can see what happens."
  • edit in 02-nix-build/demo.sh at line 39
    [5.516][5.4683:4850](),[5.4850][2.116:150](),[2.150][5.673:674](),[5.611][5.673:674](),[5.673][5.673:674]()
    h "Maybe there was no output; this means that package was already built and put into the Nix store"
    , "Let's build it again so we can see what happens under the hood"
    i nix build "${dir}" -L --rebuild