Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support system-wide configuration for zigup directory #113

Open
ielm opened this issue Mar 2, 2024 · 0 comments
Open

Support system-wide configuration for zigup directory #113

ielm opened this issue Mar 2, 2024 · 0 comments

Comments

@ielm
Copy link

ielm commented Mar 2, 2024

Issue

Currently, all zig compiler installs through zigup are stored in $HOME/zig by default. I would like to configure that my compilers be stored in $HOME/.zigup/compilers. In the current version of zigup, I need to pass --install-dir $HOME/.zigup/compilers each time I fetch a compiler version. I would like to set a globally configured "install dir" that zigup respects unless explicitly passed an --install-dir argument.

Solutions

There are a couple ways to do this.

1. Environment variables

The simplest way would be to create an environment variable:

# This might store a `$ZIGUP_HOME` env var? 
zigup --set-install-dir $HOME/.zigup 

And subsequent calls to zigup might check for $ZIGUP_HOME existence before proceeding.

2. Use a configuration options file

2.1. A config file in $ZIGUP_HOME

Rustup, the zigup equivalent for rust, has a default $RUSTUP_HOME at $HOME/.rustup which can be overridden by setting the env var. The settings.toml file provides configuration options to set the default toolchain and to allow for project-specific toolchain overrides (configured through the CLI):

default_toolchain = "stable-x86_64-unknown-linux-musl"
profile = "default"
version = 12

[overrides]
"/home/username/d/example_project_using_nightly_build" = "nightly-x86_64-unknown-linux-musl"
"/home/username/d/example_project_using_specific_build" = "1.67-x86_64-unknown-linux-musl"

Zigup might follow a similar convention and have a settings.toml or settings.json file at $ZIGUP_HOME that allows for fine-grained configuration. This also addresses issue #69.

2.2 A known folders search

zls uses a configuration file called zls.json which is stored in a known folder. The known-folders project provides the set of utilities needed for this. zigup can take a similar approach and search for a zigup.json configuration file in known folders. (And for MacOS also look for $HOME/.config/zigup)

Folder Windows xdg MacOS
Roaming Configuration %APPDATA% XDG_CONFIG_HOME HOME/Library/Preferences
Local Configuration %LOCALAPPDATA% XDG_CONFIG_HOME HOME/Library/Application Support

3. A combination of both env vars and a config

In order to accommodate for various config options, zigup might prioritize an env var (e.g., $ZIGUP_HOME) over a config, and if not found, search for a config file, and if not found, use the default.

Discussion

This is obviously my preference, but the actual implementation would require discussion with the community to reach a consensus. Moving the compiler storage dir to $HOME/.zigup/compilers enables storage of other metadata and info in the $HOME/.zigup dir including the index file (allowing for a quick search for available versions), and potentially a settings/config file as specified in 2.1.


Note: my reasoning for this is that I like to store all zig bins in $HOME/.zig/bin. Cargo stores bins in $HOME/.cargo/bin and rustup toolchains are stored in $HOME/.rustup/toolchains

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant