This program installs Zig and the Zig Language Server (ZLS). You can choose to install both or just one of them.
Note: This program must be run as root. Use sudo when executing the binary.
Platform Support: Linux is fully supported. macOS builds are currently a work in progress.
Before running the program, ensure you have the following dependencies installed:
wget(for downloading Zig binary)git(for downloading ZLS)jq(for parsing version information)minisign(for verifying Zig download)xz(for extracting archives)
- Clone the repository or download the pre-built binary for your platform.
- If downloading the source code, build and install the program:
go installOr use the justfile if available:
just installNote: using
go installdoes not add build metadata like version information. To include that, use the justfile or build with ldflags. See details in "Build-time Configuration" section.
- Run the program with the desired options.
sudo ./zig-install-{platform} [command] [OPTIONS]install: Install Zig and/or ZLS (default if no command specified)version: Show version information about the installerenv: Generate a template .env file
--zig-only: Install only Zig--zls-only: Install only ZLS (Zig Language Server)--verbose: Show detailed output during installation--no-color: Disable colored output--env <file>: Specify a custom environment file (default:.env)--settings: Show current configuration settings--log-file <file>: Specify log file (default:zig-install.log)--enable-log: Enable/disable logging to file (enabled by default)--version, -v <version>: Specify Zig version to install (default: latest master)
This program can be configured in two ways (in order of precedence):
- Command-line flags: Options provided directly when running the program
- Configuration file: Settings in an
.envfile
Before running the program, it will check for required dependencies like wget, git, jq, minisign, and xz. If any are missing, it will inform you so you can install them.
You can create a .env file in the same directory as the executable in two ways:
- Use the
envcommand to create a template:./zig-install-linux-amd64 env
- Use the
--generate-envflag with the install command:sudo ./zig-install-linux-amd64 install --generate-env
You can view your current configuration settings at any time using the --settings flag:
./zig-install-linux-amd64 install --settings# Zig download and verification
ZIG_PUB_KEY=RWSGOq2NVecA2UPNdBUZykf1CCb147pkmdtYxgb3Ti+JO/wCYvhbAb/U
ZIG_DOWN_URL=https://ziglang.org/builds/
ZIG_INDEX_URL=https://ziglang.org/download/index.json
The values override the defaults.
Creating a .env file is optional, but it allows for easy customization without modifying the source code. It allows you to update settings in the event of:
- The upstream Zig project rotates their signing keys and the hardcoded default is outdated
- The upstream Zig project has moved to a new download URL
When building from source, you can also customize some defaults using linker flags:
go build -ldflags="-X 'github.com/exilesprx/zig-install/internal/config.Version=VERSION' 'github.com/exilesprx/zig-install/internal/config.Commit=COMMIT' 'github.com/exilesprx/zig-install/internal/config.BuildDate=DATE'"The justfile in this project automatically sets the ldflags during build and is the recommended way to build.
Install both Zig and ZLS (latest master):
sudo ./zig-install-linux-amd64 installInstall only Zig:
sudo ./zig-install-linux-amd64 install --zig-onlyInstall only ZLS (Zig Language Server): Note: You must have Zig installed in order to compile ZLS.
sudo ./zig-install-linux-amd64 install --zls-onlyInstall a specific version (both Zig and ZLS will be installed at this version):
sudo ./zig-install-linux-amd64 install --version 0.11.0Install only Zig at a specific version:
sudo ./zig-install-linux-amd64 install --zig-only --version 0.11.0Install only ZLS (will use current Zig version regardless of --version):
sudo ./zig-install-linux-amd64 install --zls-only --version 0.11.0 # Note: version will be ignoredInstall with verbose output and custom log file:
sudo ./zig-install-linux-amd64 install --verbose --log-file custom.logDisplay the current settings:
./zig-install-linux-amd64 install --settingsGenerate a template .env file:
./zig-install-linux-amd64 envShow version information:
./zig-install-linux-amd64 versionThe installer manages Zig and ZLS versions in the following way:
- When using
--version, both Zig and ZLS will be installed at the specified version to ensure compatibility - When using
--zig-onlywith--version, only Zig will be installed at the specified version - When using
--zls-onlywith--version, ZLS will be installed matching your current Zig version, ignoring the specified version - If no version is specified, the latest master versions will be used
This versioning strategy ensures that Zig and ZLS remain compatible with each other.
- This program must be run as root as it installs software to system directories
- Configuration via .env file allows for easy customization without rebuilding
- Logging is enabled by default to
zig-install.log, but can be configured or disabled - The program performs automatic dependency checks before installation
- Both Zig and ZLS installations preserve file ownership for non-root users
This project is licensed under the MIT License.