From NixOS Wiki
Jump to: navigation, search
m (whitespace cleanup)
Line 1: Line 1:
 
{{FAQ/breadcrumb}}{{#tweekihide:firstHeading}}<onlyinclude>
 
{{FAQ/breadcrumb}}{{#tweekihide:firstHeading}}<onlyinclude>
== Why not use nix-env -i foo? ==
+
== Why not use nix-env -i hello? ==
  
<code>nix-env -i foo</code> is slower and tends to be less precise than <code>nix-env -f '<nixpkgs>' -iA foo</code>. This is because it will evaluate all of nixpkgs searching for packages with the name foo, and install the one [https://nixos.org/nix/manual/#description-1 determined to be the latest] (which may not even be the one that you want). Meanwhile, with <code>-A</code>, nix-env will evaluate only the given attribute in nixpkgs. This will be significantly faster, consume significantly less memory, and more likely to get you what you want.
+
<code>nix-env -i hello</code> is slower and tends to be less precise than <code>nix-env -f '<nixpkgs>' -iA hello</code>. This is because it will evaluate all of nixpkgs searching for packages with the name <code>hello</code>, and install the one [https://nixos.org/nix/manual/#description-1 determined to be the latest] (which may not even be the one that you want). Meanwhile, with <code>-A</code>, nix-env will evaluate only the given attribute in nixpkgs. This will be significantly faster, consume significantly less memory, and more likely get you what you want.
  
 
<code>nix-env -u</code> has the same problem, searching for all the packages in the user environment by name and upgrading them. This may lead to unwanted major-version upgrades like JDK 8 → JDK 9. If you want to have a declarative user environment, you may wish to create an overlay like [https://gist.github.com/LnL7/570349866bb69467d0caf5cb175faa74 LnL's]. With this setup, you can update your packages by simply running <code>nix-rebuild</code>.</onlyinclude>
 
<code>nix-env -u</code> has the same problem, searching for all the packages in the user environment by name and upgrading them. This may lead to unwanted major-version upgrades like JDK 8 → JDK 9. If you want to have a declarative user environment, you may wish to create an overlay like [https://gist.github.com/LnL7/570349866bb69467d0caf5cb175faa74 LnL's]. With this setup, you can update your packages by simply running <code>nix-rebuild</code>.</onlyinclude>

Revision as of 09:14, 16 July 2019

Why not use nix-env -i hello?

nix-env -i hello is slower and tends to be less precise than nix-env -f '<nixpkgs>' -iA hello. This is because it will evaluate all of nixpkgs searching for packages with the name hello, and install the one determined to be the latest (which may not even be the one that you want). Meanwhile, with -A, nix-env will evaluate only the given attribute in nixpkgs. This will be significantly faster, consume significantly less memory, and more likely get you what you want.

nix-env -u has the same problem, searching for all the packages in the user environment by name and upgrading them. This may lead to unwanted major-version upgrades like JDK 8 → JDK 9. If you want to have a declarative user environment, you may wish to create an overlay like LnL's. With this setup, you can update your packages by simply running nix-rebuild.