Refactor libdemo and flakeref for nix run commands

[?]
Mar 23, 2023, 9:12 PM
W2G433QU3JDG72JL6GYR6E5HMAHFP3OF2DLFB3O42245XTE6VGZQC

Dependencies

Change contents

  • edit in libdemo/libdemo.sh at line 206
    [7.465][7.2333:2359](),[7.2359][2.1221:1259](),[2.1259][7.7:120](),[7.2387][7.7:120](),[7.120][6.5:126](),[6.126][7.253:303](),[7.191][7.253:303](),[7.253][7.253:303](),[7.303][2.1260:1313](),[2.1313][7.335:444](),[7.335][7.335:444](),[7.444][7.2584:2597](),[7.2584][7.2584:2597](),[7.2597][7.271:345](),[7.345][7.2597:2618](),[7.2597][7.2597:2618](),[7.2618][7.346:357]()
    }
    pygmentize() {
    if __libdemo_use_colour; then
    if type nix >/dev/null; then
    # Hack around missing mainProgram attribute in pygments
    COLORTERM="" TERM="" nix run github:sfrijters/nixpkgs/pygments-mainprogram#python3Packages.pygments "$@"
    elif type pygmentize >/dev/null; then
    COLORTERM="" TERM="" pygmentize "$@"
    else
    echo "pygmentize command not found"
    return 1
    fi
    else
    while [ $# -gt 1 ]; do
    shift
    done
    cat "$@"
    fi
  • edit in libdemo/libdemo.sh at line 207
    [7.3605][7.4:17](),[7.17][2.1314:1352](),[2.1352][7.45:334](),[7.45][7.45:334](),[7.334][3.224:306](),[3.306][7.334:351](),[7.334][7.334:351]()
    tiv() {
    if __libdemo_use_colour; then
    if type nix > /dev/null; then
    nix run github:sfrijters/nixpkgs/tiv-add-wrapper#tiv -- "$@"
    elif type tiv >/dev/null; then
    tiv "$@"
    else
    echo "tiv command not found"
    return 1
    fi
    else
    echo "no colour output available, use your imagination!"
    fi
    }
  • replacement in demo-full.sh at line 5
    [7.43][7.60:119]()
    source "$(dirname "${BASH_SOURCE[0]}")/libdemo/libdemo.sh"
    [7.43]
    [7.99]
    source "$(dirname "${BASH_SOURCE[0]}")/bash/nix-container-demo-helper.sh"
  • replacement in demo-full.sh at line 8
    [7.10][7.193:319]()
    local -r shellcheck_cmd="nix run github:nixos/nixpkgs/008ce261a7e3c532e792cb8e39482f2cc1b192f5#shellcheck -- -S style -x"
    [7.10]
    [7.1]
    local -r shellcheck_cmd="nix run ${NIXPKGS_FLAKEREF}#shellcheck -- -S style -x"
  • replacement in demo-full.sh at line 11
    [7.374][7.120:181](),[7.108][7.120:181](),[7.181][7.375:461]()
    echo "$(dirname "${BASH_SOURCE[0]}")/libdemo/libdemo.sh"
    ${shellcheck_cmd} "$(dirname "${BASH_SOURCE[0]}")/libdemo/libdemo.sh" || return 1
    [7.374]
    [7.273]
    echo "$(dirname "${BASH_SOURCE[0]}")/bash/nix-container-demo-helper.sh"
    ${shellcheck_cmd} "$(dirname "${BASH_SOURCE[0]}")/bash/nix-container-demo-helper.sh" || return 1
  • file addition: bash (d--r------)
    [7.2]
  • file addition: nix-container-demo-helper.sh (----------)
    [0.350]
    # -*- sh-shell: bash -*-
    # shellcheck shell=bash
    if [ -z ${_NIX_CONTAINER_DEMO_HELPER_INC+x} ]; then
    _NIX_CONTAINER_DEMO_HELPER_INC=true
    source "$(dirname "${BASH_SOURCE[0]}")/../libdemo/libdemo.sh"
    export NIXPKGS_FLAKEREF=github:nixos/nixpkgs/008ce261a7e3c532e792cb8e39482f2cc1b192f5
    pygmentize() {
    if __libdemo_use_colour; then
    if type nix >/dev/null; then
    # Hack around missing mainProgram attribute in pygments
    # TODO: use nixpkgs_flakeref when this fix is merged
    COLORTERM="" TERM="" nix run github:sfrijters/nixpkgs/pygments-mainprogram#python3Packages.pygments -- "$@"
    elif type pygmentize >/dev/null; then
    COLORTERM="" TERM="" pygmentize "$@"
    else
    echo "pygmentize command not found"
    return 1
    fi
    else
    while [ $# -gt 1 ]; do
    shift
    done
    cat "$@"
    fi
    }
    tiv() {
    if __libdemo_use_colour; then
    if type nix > /dev/null; then
    # Hack around missing imagemagick
    # TODO: use nixpkgs_flakeref when this fix is merged
    nix run github:sfrijters/nixpkgs/tiv-add-wrapper#tiv -- "$@"
    elif type tiv >/dev/null; then
    tiv "$@"
    else
    echo "tiv command not found"
    return 1
    fi
    else
    echo "no colour output available, use your imagination!"
    fi
    }
    file() {
    if type nix > /dev/null; then
    nix run "${NIXPKGS_FLAKEREF}#file" -- "$@"
    elif type file >/dev/null; then
    file "$@"
    else
    echo "file command not found"
    return 1
    fi
    }
    fi
  • replacement in 06-windows-wine/demo.sh at line 7
    [5.413583][5.413583:413621]()
    source "${dir}/../libdemo/libdemo.sh"
    [5.413583]
    [5.413621]
    source "${dir}/../bash/nix-container-demo-helper.sh"
  • edit in 06-windows-wine/demo.sh at line 9
    [5.413622][5.413622:413709]()
    file_cmd="nix run github:nixos/nixpkgs/008ce261a7e3c532e792cb8e39482f2cc1b192f5#file"
  • replacement in 06-windows-wine/demo.sh at line 22
    [5.414333][5.414333:414366]()
    x nix build "${dir}#mingwW64" -L
    [5.414333]
    [5.414366]
    x nix build "${dir}#mingwW64"
  • replacement in 06-windows-wine/demo.sh at line 25
    [5.414401][5.414401:414445]()
    x "${file_cmd}" ./result/bin/wttr-delft.exe
    [5.414401]
    [5.414445]
    x file ./result/bin/wttr-delft.exe
  • replacement in 06-windows-wine/demo.sh at line 28
    [5.414475][5.414475:414633]()
    x "WINEPREFIX=$(readlink -f "${dir}/wttr-delft") nix run github:nixos/nixpkgs/008ce261a7e3c532e792cb8e39482f2cc1b192f5#wine64 -- ./result/bin/wttr-delft.exe"
    [5.414475]
    x "WINEPREFIX=$(readlink -f "${dir}/wttr-delft") nix run ${NIXPKGS_FLAKEREF}#wine64 -- ./result/bin/wttr-delft.exe"
  • replacement in 05-static-container/demo.sh at line 7
    [7.5763][7.5763:5801]()
    source "${dir}/../libdemo/libdemo.sh"
    [7.5763]
    [7.5801]
    source "${dir}/../bash/nix-container-demo-helper.sh"
  • replacement in 05-static-container/demo-inside-nix-develop.sh at line 7
    [7.6315][7.6315:6353]()
    source "${dir}/../libdemo/libdemo.sh"
    [7.6315]
    [7.6353]
    source "${dir}/../bash/nix-container-demo-helper.sh"
  • edit in 04-cmake-and-cross/demo.sh at line 6
    [4.979][7.863:902](),[7.863][7.863:902]()
    source "${dir}/../libdemo/libdemo.sh"
  • replacement in 04-cmake-and-cross/demo.sh at line 7
    [7.17][7.17:103]()
    file_cmd="nix run github:nixos/nixpkgs/008ce261a7e3c532e792cb8e39482f2cc1b192f5#file"
    [7.17]
    [7.902]
    source "${dir}/../bash/nix-container-demo-helper.sh"
  • replacement in 04-cmake-and-cross/demo.sh at line 26
    [4.1621][7.511:551](),[7.511][7.511:551]()
    x "${file_cmd}" ./result/bin/wttr-delft
    [4.1621]
    [7.1610]
    x file ./result/bin/wttr-delft
  • replacement in 04-cmake-and-cross/demo.sh at line 36
    [4.1908][7.711:751](),[7.711][7.711:751]()
    x "${file_cmd}" ./result/bin/wttr-delft
    [4.1908]
    [7.751]
    x file ./result/bin/wttr-delft
  • replacement in 04-cmake-and-cross/demo.sh at line 42
    [4.2019][7.1102:1142](),[7.1102][7.1102:1142]()
    x "${file_cmd}" ./result/bin/wttr-delft
    [4.2019]
    [7.1142]
    x file ./result/bin/wttr-delft
  • replacement in 04-cmake-and-cross/demo.sh at line 48
    [7.1346][7.1346:1386]()
    x "${file_cmd}" ./result/bin/wttr-delft
    [7.1346]
    [7.1386]
    x file ./result/bin/wttr-delft
  • replacement in 04-cmake-and-cross/demo.sh at line 59
    [7.2107][7.145:185]()
    x "${file_cmd}" ./result/bin/wttr-delft
    [7.2107]
    [7.2138]
    x file ./result/bin/wttr-delft
  • replacement in 03-nix-container/demo.sh at line 7
    [7.5197][7.5197:5235]()
    source "${dir}/../libdemo/libdemo.sh"
    [7.5197]
    [7.5235]
    source "${dir}/../bash/nix-container-demo-helper.sh"
  • replacement in 03-nix-container/demo-inside-nix-develop.sh at line 7
    [7.5817][7.5817:5855]()
    source "${dir}/../libdemo/libdemo.sh"
    [7.5817]
    [7.5855]
    source "${dir}/../bash/nix-container-demo-helper.sh"
  • replacement in 02-nix-build/demo.sh at line 7
    [7.4179][7.523:561]()
    source "${dir}/../libdemo/libdemo.sh"
    [7.4179]
    [7.4238]
    source "${dir}/../bash/nix-container-demo-helper.sh"
  • replacement in 02-nix-build/demo-inside-nix-develop.sh at line 7
    [7.865][7.563:601]()
    source "${dir}/../libdemo/libdemo.sh"
    [7.865]
    [7.547]
    source "${dir}/../bash/nix-container-demo-helper.sh"
  • replacement in 01-nix-run/demo.sh at line 7
    [7.1025][7.903:941]()
    source "${dir}/../libdemo/libdemo.sh"
    [7.1025]
    [7.3888]
    source "${dir}/../bash/nix-container-demo-helper.sh"
  • replacement in 01-nix-run/demo.sh at line 12
    [4.5918][7.1061:1101](),[7.565][7.1061:1101]()
    i nix run nixpkgs#curl -- wttr.in/Delft
    [4.5918]
    [7.147]
    i "nix run nixpkgs#curl -- wttr.in/Delft"
  • replacement in 01-nix-run/demo.sh at line 17
    [4.6048][7.4132:4144](),[7.4132][7.4132:4144]()
    x type curl
    [4.6048]
    [7.4144]
    x "type curl"
  • replacement in 01-nix-run/demo.sh at line 20
    [4.6131][7.4178:4192](),[7.4178][7.4178:4192](),[7.4192][7.227:322]()
    f type cowsay
    x nix run github:nixos/nixpkgs/008ce261a7e3c532e792cb8e39482f2cc1b192f5#cowsay -- -f tux hello
    [4.6131]
    [7.322]
    f "type cowsay"
    x "nix run ${NIXPKGS_FLAKEREF}#cowsay -- -f tux hello"