Skip to content

Stop using nix-env -iA and add better instructions for Nix users #538

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

Merged
merged 2 commits into from
Apr 14, 2025

Conversation

testplayername
Copy link
Contributor

@testplayername testplayername commented Apr 13, 2025

This PR is an alternative to #506.

The original explanation for this PR's change is at #506 (comment) and is copied below.


Nix is a complex beast, with a package management system that looks alien compared to other package managers. A comment on a Github issue is a poor place to explain all that is Nix, so I'll try to provide a short summary of Nix here, and just the parts that are immediately relevant to this issue.

One of the primary points of Nix is declarative package management and configuration. Whereas with other package managers the way to install something would be a shell command, e.g. sudo apt install firefox and sudo pacman -S firefox, the best way to install a package in Nix is editing configuration files. This is conceptually similar to the go.mod for Go programs, but in the case of Nix, these configuration files defines a configuration of a system, including what programs are installed.

However, Nix also provides several other ways to "install" a package. This is where nix-env -iA zk and nix profile install nixpkgs#zk comes from. These two commands install the package imperatively, and I would argue both of these commands are anti-patterns, because Nix is designed for declarative package management.

Nix (and NixOS) configurations can get highly customized. Installation instructions necessarily have to assume the user has some basic Nix knowledge. I recommend these lines in the section for Nix in the readme:

The pitfalls of using `nix-env -iA` are explained at https://stop-using-nix-env.privatevoid.net/.

In summary, using `nix-env -iA` to install packages is bad because of potential name collisions, confusing conflicts with other packages installed by other means, and are generally against the declarative principles of Nix.
@testplayername testplayername force-pushed the better-nix-install-docs branch from 0c928cd to ca2ce21 Compare April 13, 2025 09:02
@tjex tjex merged commit a10d80b into zk-org:main Apr 14, 2025
@tjex
Copy link
Member

tjex commented Apr 14, 2025

thanks :)

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

Successfully merging this pull request may close these issues.

2 participants