36 stubexec() { |
36 stubexec() { |
37 local real_bin="$(realbin "$0" | age_check)" |
37 local real_bin="$(realbin "$0" | age_check)" |
38 if [ -x "$real_bin" ]; then |
38 if [ -x "$real_bin" ]; then |
39 exec "$real_bin" "$@" |
39 exec "$real_bin" "$@" |
40 fi |
40 fi |
|
41 try_nix_run "$@" |
41 install_it |
42 install_it |
42 touch "$(realbin "$0")" # In case of no updates |
43 touch "$(realbin "$0")" # In case of no updates |
43 stubexec "$@" |
44 stubexec "$@" |
|
45 } |
|
46 |
|
47 has() { |
|
48 type "$1" >/dev/null 2>&1 |
|
49 } |
|
50 |
|
51 try_nix_run() { |
|
52 if [ "${nix_ref:-}" ] && has nix; then |
|
53 # FIXME: this can be GC'd and doesn't allow running alternate commands |
|
54 exec nix run "$nix_ref" -- "$@" |
|
55 fi |
44 } |
56 } |
45 |
57 |
46 bina_install() { |
58 bina_install() { |
47 local github_repo="$1" |
59 local github_repo="$1" |
48 mkdir -p ~/.local/bin |
60 mkdir -p ~/.local/bin |