jdx / mise

dev tools, env vars, task runner
https://mise.jdx.dev
MIT License
9.39k stars 263 forks source link

A more generic shell binary manager #953

Open hoshsadiq opened 11 months ago

hoshsadiq commented 11 months ago

Would be cool to have generic binary manager. These often integrate with the shell similar to how rtx activate zsh works, but the difference between those and asdf (and rtx) is that it essentially allows users to define a custom configuration on how to download and set things up. E.g. "download latest release from github releases, and use binary y.

The use-case for these is something like say (go)jq, ripgrep, exa/eza, fzf, etc. The idea being that when you do an update it always gets the latest version (except for when a version is specified).

I currently use zinit to set up my binaries and environment, however, been trying to move away, below is an example with some of the other apps that attempt to address this use-case (though not greatly).

zinit:

zinit ice silent wait as"program" from"gh-r" atload'export FZF_DEFAULT_OPTS="--reverse --exit-0 --border --ansi"'
zinit light junegunn/fzf

afx:

  - name: junegunn/fzf
    owner: junegunn
    repo: fzf
    command:
      build:
        steps:
          - ./install --bin --no-update-rc --no-key-bindings
      link:
        - from: 'bin/fzf'
    plugin:
      sources:
        - shell/completion.zsh
        - shell/key-bindings.zsh
      env:
        FZF_DEFAULT_OPTS: --reverse --exit-0 --border --ansi

bin (untested):

bin install github.com/junegunn/fzf

I've tried a few more out, but I've not been overly happy with the implementations for different reasons.

What I'm proposing here is a generic downloader configured by the user. This should be able to download from different sources (git repo, github/git* releases, http, others?) and furthermore inject some custom stuff into the environment (through rtx activate <shell>). Some preliminary example config I'm thinking of is:

[[package.fzf]]
source = "junegunn/fzf"
from = "gh-r" # or github-release
build = [
  "./install --bin --no-update-rc --no-key-bindings"
]
env = { FZF_DEFAULT_OPTS = "--reverse --exit-0 --border --ansi" }
shell_source = [
    "shell/completion.zsh",
    "shell/key-bindings.zsh"
]
aliases = { fzfa="fzf --no-reverse" }
snippet = """
fzf_doit() {
    fzf "$@"
}
"""

You can imagine that this could become a powerful tool of setting up your dev environment in general. Your repos can specify what tools they need, while users can specify what tools they need on top of those. E.g. I've seen some zinit configurations that set up people's complete shell environments which include neovim + plugins, tmux + plugins, and much more.

hoshsadiq commented 11 months ago

Side note: assuming there's appetite for such a feature, I'd be happy to take a stab at it if I can get some guidance, though I'd need some guidance as I've never developed in Rust before.

Jomik commented 11 months ago

Aren't you pretty much just wanting nix at this point?

hoshsadiq commented 11 months ago

I wouldn't say so no, nix is way overkill for such a task. I just need it to download random archives or binaries and do basic things like linking files or generating completion files.