From 06b78c72027ed680f9e8e1e59814dc300b83f8c3 Mon Sep 17 00:00:00 2001 From: sternenseemann <0rpkxez4ksa01gb3typccl0i@systemli.org> Date: Wed, 17 Mar 2021 16:12:07 +0100 Subject: 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. --- machines/sternenseemann/base.nix | 9 +++++++++ 1 file changed, 9 insertions(+) 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 {}); builtins.toString (lib.getBin $arg)")) + nix-store --realise "$store_path" + set PATH "$store_path/bin" $PATH + end + end ''; }; -- cgit 1.4.1