FAQ/Pinning Nixpkgs: Difference between revisions

Sandro (talk | contribs)
Drop pre nix 2.0, warn about negatives of pinning
DHCP (talk | contribs)
m use '$' and lang=console for shell commands syntax highlighting; update links to channels.nixos.org
 
Line 11: Line 11:
Be aware that this also pins all dependencies of the application which often causes issues for GUI applications and also brings in back outdated and potentially vulnerable dependencies.
Be aware that this also pins all dependencies of the application which often causes issues for GUI applications and also brings in back outdated and potentially vulnerable dependencies.


<pre>
<syntaxhighlight lang="console">
sudo nix-channel --list
$ sudo nix-channel --list
nixos https://nixos.org/channels/nixos-21.05
nixos https://channels.nixos.org/nixos-26.05
</pre>
</syntaxhighlight>


Nix 2.0 introduces new builtins, <code>fetchTarball</code> and <code>fetchGit</code>, which make it possible to fetch a specific version of nixpkgs without depending on an existing one:
Nix 2.0 introduces new builtins, <code>fetchTarball</code> and <code>fetchGit</code>, which make it possible to fetch a specific version of nixpkgs without depending on an existing one:
Line 23: Line 23:
   name = "nixos-unstable-2018-09-12";
   name = "nixos-unstable-2018-09-12";
   # Commit hash for nixos-unstable as of 2018-09-12
   # Commit hash for nixos-unstable as of 2018-09-12
   url = "https://github.com/nixos/nixpkgs/archive/ca2ba44cab47767c8127d1c8633e2b581644eb8f.tar.gz";
   url = "https://github.com/NixOS/nixpkgs/archive/ca2ba44cab47767c8127d1c8633e2b581644eb8f.tar.gz";
   # Hash obtained using `nix-prefetch-url --unpack <url>`
   # Hash obtained using `nix-prefetch-url --unpack <url>`
   sha256 = "1jg7g6cfpw8qvma0y19kwyp549k1qyf11a5sg6hvn6awvmkny47v";
   sha256 = "1jg7g6cfpw8qvma0y19kwyp549k1qyf11a5sg6hvn6awvmkny47v";
}) {}
}) { }
</syntaxhighlight>
</syntaxhighlight>


Line 35: Line 35:
   # Descriptive name to make the store path easier to identify
   # Descriptive name to make the store path easier to identify
   name = "nixos-unstable-2018-09-12";
   name = "nixos-unstable-2018-09-12";
   url = "https://github.com/nixos/nixpkgs/";
   url = "https://github.com/NixOS/nixpkgs/";
   # Commit hash for nixos-unstable as of 2018-09-12
   # Commit hash for nixos-unstable as of 2018-09-12
   # `git ls-remote https://github.com/nixos/nixpkgs nixos-unstable`
   # `git ls-remote https://github.com/NixOS/nixpkgs nixos-unstable`
   ref = "refs/heads/nixos-unstable";
   ref = "refs/heads/nixos-unstable";
   rev = "ca2ba44cab47767c8127d1c8633e2b581644eb8f";
   rev = "ca2ba44cab47767c8127d1c8633e2b581644eb8f";
}) {}
}) { }
</syntaxhighlight>
</syntaxhighlight>


Line 60: Line 60:
add to configuration.nix a set allowing unstable packages.
add to configuration.nix a set allowing unstable packages.
This assumes a channel named <code>nixpkgs-unstable</code> exists, like so:
This assumes a channel named <code>nixpkgs-unstable</code> exists, like so:
<syntaxhighlight lang="bash">
<syntaxhighlight lang="console">
nix-channel --add https://nixos.org/channels/nixpkgs-unstable nixpkgs-unstable
$ nix-channel --add https://channels.nixos.org/nixpkgs-unstable nixpkgs-unstable
nix-channel --update
$ nix-channel --update
</syntaxhighlight>
</syntaxhighlight>