FAQ/Pinning Nixpkgs: Difference between revisions
m FAQ Breadcrumb |
m use '$' and lang=console for shell commands syntax highlighting; update links to channels.nixos.org |
||
| (2 intermediate revisions by 2 users not shown) | |||
| Line 9: | Line 9: | ||
Note: You can <code>sudo nix-channel --remove nixpkgs</code>, but you still need a nix-channel for nixos | Note: You can <code>sudo nix-channel --remove nixpkgs</code>, but you still need a nix-channel for nixos | ||
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. | |||
= | <syntaxhighlight lang="console"> | ||
$ sudo nix-channel --list | |||
nixos https://channels.nixos.org/nixos-26.05 | |||
</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/ | 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> | ||
Or, to use git for fetching | Or, to use git for fetching: | ||
<syntaxhighlight lang="nix"> | <syntaxhighlight lang="nix"> | ||
| 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/ | 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/ | # `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 51: | Line 51: | ||
while evaluating anonymous function at /nix/store/b93cq865x6qxpn4dw9ivrk3yjcsm8r97-nixos-19.09/pkgs/stdenv/generic/make-derivation.nix:142:17, called from undefined position: | while evaluating anonymous function at /nix/store/b93cq865x6qxpn4dw9ivrk3yjcsm8r97-nixos-19.09/pkgs/stdenv/generic/make-derivation.nix:142:17, called from undefined position: | ||
program 'git' failed with exit code 128 | program 'git' failed with exit code 128 | ||
</syntaxhighlight> | </syntaxhighlight> | ||
| Line 162: | 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=" | <syntaxhighlight lang="console"> | ||
nix-channel --add https://nixos.org | $ nix-channel --add https://channels.nixos.org/nixpkgs-unstable nixpkgs-unstable | ||
nix-channel --update | $ nix-channel --update | ||
</syntaxhighlight> | </syntaxhighlight> | ||
| Line 235: | Line 133: | ||
== See also == | == See also == | ||
* [https://nix.dev/reference/pinning-nixpkgs Pinning Nixpkgs] | |||
* [https://nix.dev/tutorials/first-steps/towards-reproducibility-pinning-nixpkgs Towards Reproducibility: Pinning Nixpkgs] | |||
* [https://nix.dev/guides/recipes/dependency-management.html Dependency Management] | |||