Skip to content

Instantly share code, notes, and snippets.

@Profpatsch
Created Feb 10, 2022
Embed
What would you like to do?
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