Skip to content

Instantly share code, notes, and snippets.

@Profpatsch
Created February 10, 2022 08:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Profpatsch/037e4f527e37ecfcf0b6e365b78b917d to your computer and use it in GitHub Desktop.
Save Profpatsch/037e4f527e37ecfcf0b6e365b78b917d to your computer and use it in GitHub Desktop.
Add a package from nixpkgs to your current fish shell
function with --description 'import all arguments as nixpkgs args and put their /bin on PATH'
set arg ( \
printf '
let pkgs = import <nixpkgs> {};
in pkgs.symlinkJoin {
name = "extra-fish-path";
paths = with pkgs; [ %s ];
}
' \
"$argv" \
)
set tmpdir (mktemp -d)
set outLink "$tmpdir/fish-with-nix-gcroot"
# remove gc root on shell exit
trap "rm -r $tmpdir" EXIT
set outPath ( \
nix-build \
--out-link "$outLink" \
-E "$arg" \
)
set --prepend PATH "$outPath/bin"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment