1 { stdenv, lib, fetchFromGitHub, makeWrapper, installShellFiles, bash, curl, git, writeScript }:
4 asdfReshimFile = writeScript "asdf-reshim" ''
7 # asdf-vm create "shim" file like this:
9 # exec $ASDF_DIR/bin/asdf exec "node" "$@"
11 # So we should reshim all installed versions every time shell initialized,
12 # because $out always change
14 asdfDir="''${ASDF_DIR:-$HOME/.asdf}"
15 asdfDataDir="''${ASDF_DATA_DIR:-$HOME/.asdf}"
17 prevAsdfDirFilePath="$asdfDataDir/.nix-prev-asdf-dir-path"
19 if [ -r "$prevAsdfDirFilePath" ]; then
20 prevAsdfDir="$(cat "$prevAsdfDirFilePath")"
25 if [ "$prevAsdfDir" != "$asdfDir" ]; then
26 rm -rf "$asdfDataDir"/shims
27 "$asdfDir"/bin/asdf reshim
28 echo "$asdfDir" > "$prevAsdfDirFilePath"
32 asdfPrepareFile = writeScript "asdf-prepare" ''
35 source "$ASDF_DIR/asdf.sh"
38 in stdenv.mkDerivation rec {
42 src = fetchFromGitHub {
46 sha256 = "sha256-1dacsAoZVwoQv8+V4FrjRLa7awLIZchlhkuET0wTO7w=";
61 mkdir -p $out/share/asdf-vm
62 cp -r . $out/share/asdf-vm
64 mkdir -p $out/etc/profile.d
65 substitute ${asdfPrepareFile} $out/etc/profile.d/asdf-prepare.sh \
66 --replace "@asdfDir@" "$out/share/asdf-vm"
69 makeWrapper $out/share/asdf-vm/bin/asdf $out/bin/asdf \
70 --set ASDF_DIR $out/share/asdf-vm
72 installShellCompletion --cmd asdf \
73 --zsh completions/_asdf \
74 --fish completions/asdf.fish \
75 --bash completions/asdf.bash
79 description = "Extendable version manager with support for Ruby, Node.js, Erlang & more";
80 homepage = "https://asdf-vm.com/";
81 license = licenses.mit;
82 maintainers = [ maintainers.c4605 ];
84 platforms = platforms.unix;