Skip to content

Instantly share code, notes, and snippets.

@axelbdt
Created April 11, 2023 14:10
Show Gist options
  • Save axelbdt/0de9f5f9ba8a2100326b793f7bfb8658 to your computer and use it in GitHub Desktop.
Save axelbdt/0de9f5f9ba8a2100326b793f7bfb8658 to your computer and use it in GitHub Desktop.
How to Install asdf with Nix Home-manager

How to Install asdf with Nix Home-manager

  1. First, add asdf to the Nix configuration with the package named asdf-vm. Add the following line to your configuration.nix file:

    environment.systemPackages = with pkgs; [
      asdf-vm
    ];
  2. Next, add the following lines to your .bashrc file:

    . "$HOME/.nix-profile/share/asdf-vm/asdf.sh"
    . "$HOME/.nix-profile/share/bash-completion/completions/asdf.bash"

    These lines will load asdf into your shell.

  3. Reload your .bashrc or open a new terminal to apply the changes.

  4. Verify that asdf is properly installed by running the following command:

    asdf --version

    This should output the version number of asdf.

That's it! Now you can use asdf with Nix.

@milespossing
Copy link

Using home-manager with bash I used something like this to ensure it always looked in the right place:

programs.bash = {
  enable = true;
  # ... other things here
  initExtra = ''
    . "${pkgs.asdf-vm}/share/asdf-vm/asdf.sh"
    . "${pkgs.asdf-vm}/share/asdf-vm/completions/asdf.bash"
  '';
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment