Skip to content

Instantly share code, notes, and snippets.

@sizumita
Created July 2, 2024 08:12
Show Gist options
  • Save sizumita/f4200287f09f2b40f53ff74d60a03bb3 to your computer and use it in GitHub Desktop.
Save sizumita/f4200287f09f2b40f53ff74d60a03bb3 to your computer and use it in GitHub Desktop.
The Package Manager "vitm"

vitm

Warning

This Project is under considering.

Virtual Path/Package Manager for Mac/Linux/Windows.

Goals

  1. Install multiple package manager's package in one command.
    • Fast
    • Safely
  2. Create virtual environment by creating config file.
    • Easy to switch env

Motivations

Homebrew can't change install path dynamically.

Homebrew can't change HOMEBREW_PREFIX (we can check it by brew --prefix) because it is set by homebrew bin directory.

This setting can be changed manually by downloading the Homebrew git repository, but it may break some package installations.

Solution

In vitm, we aim to allow the installation destination to be set via environment variables or install config or config files.

[packages]
gcc = {outdir = "~/local/bin"}
$ vitm install gcc --out-dir="~/local/bin"
$ VITM_OUT_DIR="~/local/bin" vitm install gcc

Partitioning virtual environments from the C Library level

There are many projects like nodebrew and volta for Node.js, and pyenv for Python, which create virtual environments for different programming language runtimes.

However, there are no virtual environments available for managing versions of libraries installed via Homebrew (note: the author may be unaware of any existing solutions).

For example, when using Rust on a Mac and needing to set the path for LLVM, you must specify the version of LLVM and appropriately set the environment variables.

Solution

We will enable the creation of virtual environments within a config file. Commands like vitm env llvm14 will allow you to switch virtual environments, automatically setting PATH and versions for Rust and other tools.

# Toplevel packages associated to "default" environment.
[packages]
llvm = "15"

[env.llvm14.languages]
rustup = "1.78-aarch64-apple-darwin"

[env.llvm14.packages]
llvm = "14"

Manage packages from multiple package managers

In vitm, we will enable the management of packages from multiple package managers, such as:

  • vitm's own packages
  • Homebrew packages
  • apt

This will allow users to utilize vitm without having to remove their currently used package managers.

Solution

When installing from existing package managers, a prefix [manager]: will be added to the beginning, for example:

[packages]
"brew:gcc" = "*"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment