zix is a command-line tool that simplifies the management of Nix user profiles. It offers a user-friendly interface to handle package installations across different, switchable profiles (e.g., 'work', 'personal'), blending both imperative commands with a declarative foundation.
Managing packages directly with nix-env can sometimes feel purely imperative and difficult to reproduce. zix solves this by maintaining a simple JSON manifest (zix.json) that declaratively defines your profiles and their packages. It then uses this manifest to generate and manage a flake.nix, bringing reproducibility and easy environment switching to your user profile.
- Profile Management: Create, remove, and switch between multiple, isolated user profiles.
- Simple Package Management: Add or remove packages from the current profile with simple commands.
- Declarative Foundation: All profiles and packages are stored in a
zix.jsonmanifest. - Synchronization Check:
zix listshows if your installed environment is out of sync with your manifest. - Nix Flake Integration: Automatically generates and manages a
flake.nixto build, apply, and rollback your environment.
Ensure the zix binary is available in your system's PATH.
To start using zix, run the initialization command. This will create the ~/.zix directory, which contains the manifest and the Nix Flake.
zix initzix provides a set of commands to manage your profiles and packages.
Initializes the ~/.zix configuration directory.
zix initManage your profiles.
-
List available profiles:
zix profile list
-
Add a new profile:
zix profile add work
-
Switch to a different profile:
zix profile switch work
-
Remove a profile:
zix profile remove work
Adds one or more packages to the current profile's manifest.
zix add git neovimRemoves one or more packages from the current profile's manifest.
zix remove neovimLists all packages declared in the current profile's manifest and compares them against the packages currently installed in your Nix profile. This helps you see if your environment is in sync.
zix listBuilds the current profile using the flake.nix but does not activate it. This is useful for validating your configuration.
zix buildBuilds and applies the current profile, making the packages available in your environment. This is the main command to sync your environment with the manifest.
zix applyRolls back your Nix profile to the previous generation.
zix rollback-
Initialize zix:
zix init
-
Create a new profile for work:
zix profile add work
-
Switch to the new profile:
zix profile switch work
-
Add some development tools to the manifest:
zix add git go
-
Apply the changes to your system:
zix apply
-
Check the status:
zix list
~/.zix/zix.json: The core manifest file. It's a simple JSON that stores a list of your profiles and the packages associated with each one.~/.zix/flake.nix: A Nix Flake template that is dynamically populated with data fromzix.json. It reads the package list for the current profile and builds a Nix environment.- The
zixbinary: This tool acts as an orchestrator. It modifies thezix.jsonmanifest and runs the appropriatenixcommands (e.g.,nix run .#profile.switch) against the generated flake to manage your system state.