Yeah, nix isn't for me yet.

Sun, 25 Jun 2023 22:40:31 -0500

author
Meredith Howard <mhoward@roomag.org>
date
Sun, 25 Jun 2023 22:40:31 -0500
changeset 1119
84cd2286f0bf
parent 1118
d5558693c508
child 1120
8f8a93daa98c

Yeah, nix isn't for me yet.

.lib/sh/stubexec.sh file | annotate | diff | comparison | revisions
.lib/stubs/direnv file | annotate | diff | comparison | revisions
.lib/stubs/fzf file | annotate | diff | comparison | revisions
.lib/stubs/just file | annotate | diff | comparison | revisions
.lib/stubs/stow file | annotate | diff | comparison | revisions
.lib/stubs/task file | annotate | diff | comparison | revisions
.lib/stubs/tectonic file | annotate | diff | comparison | revisions
--- a/.lib/sh/stubexec.sh
+++ b/.lib/sh/stubexec.sh
@@ -1,27 +1,23 @@
 cache="${XDG_CACHE_HOME:-$HOME/.cache}/stubexec"
 
 stubexec() {
+  mkdir -p "$cache"
+
   local real_bin="$(realbin "$0")"
   if [ ! -x "$real_bin" ] || age_check $0; then
-    try_nix "$@" ||
-      try_install_callback
+    install_it
     touch_checktime "$0"
     stubexec "$@"
   fi
   exec "$real_bin" "$@"
 }
 
-db() {
-  mkdir -p "$cache"
-  kv "$cache/db" "$@"
-}
-
 touch_checktime() {
-  db touch "$(basename $1)"
+  kv "$cache/db" touch "$(basename $1)"
 }
 
 age_check() {
-  db age_days_gt "$(basename $1)" "${age_limit:-90}"
+  kv "$cache/db" age_days_gt "$(basename $1)" "${age_limit:-90}"
 }
 
 realpath() {
@@ -57,23 +53,6 @@ has() {
   type "$1" >/dev/null 2>&1
 }
 
-try_nix() {
-  [ "${nix_ref:-}" ] && has nix || return 1
-
-  local installed_slot="$(
-    nix profile list | perl -anE 'BEGIN { $m = shift =~ s/#/#.+/r } say $F[0] if $F[1] =~ $m' "$nix_ref"
-  )"
-  if [ "$installed_slot" ]; then
-    nix profile upgrade "$installed_slot"
-  else
-    nix profile install "$nix_ref"
-  fi
-}
-
-try_install_callback() {
-  install_it
-}
-
 bina_install() {
   local github_repo="$1"
   mkdir -p ~/.local/bin
--- a/.lib/stubs/direnv
+++ b/.lib/stubs/direnv
@@ -1,8 +1,6 @@
 #!/bin/sh
 set -eu
 
-nix_ref='nixpkgs#direnv'
-
 install_it() {
   mkdir -p ~/.local/bin
   curl -fsSL https://direnv.net/install.sh |
--- a/.lib/stubs/fzf
+++ b/.lib/stubs/fzf
@@ -1,8 +1,6 @@
 #!/bin/sh
 set -eu
 
-nix_ref='nixpkgs#fzf'
-
 install_it() {
   bina_install "junegunn/fzf"
 }
--- a/.lib/stubs/just
+++ b/.lib/stubs/just
@@ -1,8 +1,6 @@
 #!/bin/sh
 set -eu
 
-nix_ref='nixpkgs#just'
-
 install_it() {
   bina_install "casey/just"
   # cargo install just
--- a/.lib/stubs/stow
+++ b/.lib/stubs/stow
@@ -1,8 +1,6 @@
 #!/bin/sh
 set -eu
 
-nix_ref='nixpkgs#stow'
-
 install_it() {
   cpanm -n Stow
   asdf reshim perl || :
--- a/.lib/stubs/task
+++ b/.lib/stubs/task
@@ -1,8 +1,6 @@
 #!/bin/sh
 set -eu
 
-nix_ref='nixpkgs#go-task'
-
 install_it() {
   bina_install "go-task/task"
 }
--- a/.lib/stubs/tectonic
+++ b/.lib/stubs/tectonic
@@ -2,7 +2,6 @@
 set -eu
 
 age_limit=30
-nix_ref='nixpkgs#tectonic'
 
 install_it() {
   mkdir -p ~/.local/bin

mercurial