about summary refs log tree commit diff
diff options
context:
space:
mode:
authorsternenseemann <0rpkxez4ksa01gb3typccl0i@systemli.org>2021-03-17 16:12:07 +0100
committersternenseemann <0rpkxez4ksa01gb3typccl0i@systemli.org>2021-03-17 16:12:07 +0100
commit06b78c72027ed680f9e8e1e59814dc300b83f8c3 (patch)
treed2353d1c0719b4a1a3cd45c8e0a52f2c90ebce82
parent7e64a1ee0e1bb4ac8ca859abf696339f0eb9290d (diff)
machines/sternenseemann: add bonk shell function
Shared by adisbladis in #nixos-chat this is a very stupid fish function
which bonks a nixpkgs package into the PATH in the current shell. This
is often useful if you need a package ad-hoc and opening a nix-shell is
too much hassle or you find yourself perpetually opening and closing a
nix-shell. Extremely racy with the garbage collector, but this is yolo
ops territory anyways.
-rw-r--r--machines/sternenseemann/base.nix9
1 files changed, 9 insertions, 0 deletions
diff --git a/machines/sternenseemann/base.nix b/machines/sternenseemann/base.nix
index 952526e8..93e8f4a8 100644
--- a/machines/sternenseemann/base.nix
+++ b/machines/sternenseemann/base.nix
@@ -42,6 +42,15 @@ in {
       };
       shellInit = ''
         set -x fish_greeting ""
+
+        # an adisbladis original
+        function bonk
+          for arg in $argv
+            set -l store_path (string unescape (nix-instantiate --eval --expr "with (import <nixpkgs> {}); builtins.toString (lib.getBin $arg)"))
+            nix-store --realise "$store_path"
+            set PATH "$store_path/bin" $PATH
+          end
+        end
       '';
     };