FAQ: Difference between revisions

TLATER (talk | contribs)
Add FAQ entry on mixing stable/unstable
Ardenet (talk | contribs)
Marked this version for translation
 
(One intermediate revision by the same user not shown)
Line 413: Line 413:
NIX_PATH=nixpkgs=https://github.com/NixOS/nixpkgs/archive/release-17.09.tar.gz nix-shell -p $software
NIX_PATH=nixpkgs=https://github.com/NixOS/nixpkgs/archive/release-17.09.tar.gz nix-shell -p $software
</syntaxhighlight>
</syntaxhighlight>
<translate>
<translate>
=== There's an updated version for $software on the unstable branch, but I use stable, how can I use it? === <!--T:143-->


=== There's an updated version for $software on the unstable branch, but I use stable, how can I use it? ===
<!--T:144-->
Before going ahead with this, note that firstly, this likely means that the package you intend to update has had a major version change. If you have used it previously, there is a chance that your existing data either will not work with the new version or will need to be migrated; If in doubt, consult the upstream documentation of the package.  
Before going ahead with this, note that firstly, this likely means that the package you intend to update has had a major version change. If you have used it previously, there is a chance that your existing data either will not work with the new version or will need to be migrated; If in doubt, consult the upstream documentation of the package.  


<!--T:145-->
Secondly, while you're less likely to run into issues on NixOS than on, for example, Debian when installing packages from different releases, it's not impossible.
Secondly, while you're less likely to run into issues on NixOS than on, for example, Debian when installing packages from different releases, it's not impossible.


<!--T:146-->
Nix ensures that libraries and (usually) runtime dependencies of packages are kept separate, so that you can trivially have many versions of those dependencies installed, without affecting the versions of said dependencies used by important system components. This ensures that you cannot accidentally break your package manager by, say, updating Python, as is quite common on other distros.
Nix ensures that libraries and (usually) runtime dependencies of packages are kept separate, so that you can trivially have many versions of those dependencies installed, without affecting the versions of said dependencies used by important system components. This ensures that you cannot accidentally break your package manager by, say, updating Python, as is quite common on other distros.


<!--T:147-->
Nix cannot however ensure that there will be no incompatibilities with services of which there can inherently be only one running instance. As an example, if you try to use a package from unstable on a stable system that requires a feature in systemd that is not yet present in the systemd version on stable, this package will not work; it's simply not possible to run two different versions of systemd simultaneously.
Nix cannot however ensure that there will be no incompatibilities with services of which there can inherently be only one running instance. As an example, if you try to use a package from unstable on a stable system that requires a feature in systemd that is not yet present in the systemd version on stable, this package will not work; it's simply not possible to run two different versions of systemd simultaneously.


<!--T:148-->
Nonetheless, it's quite uncommon that end-user facing applications rely on such singleton services, or at the very least they will typically have internal backwards compatibility. As such, mixing channels is usually unproblematic in practice, and even if not, NixOS' rollback features make it trivial to recover from problems should they occur.
Nonetheless, it's quite uncommon that end-user facing applications rely on such singleton services, or at the very least they will typically have internal backwards compatibility. As such, mixing channels is usually unproblematic in practice, and even if not, NixOS' rollback features make it trivial to recover from problems should they occur.


==== Using channels ====
==== Using channels ==== <!--T:149-->
 
<!--T:150-->
First we need to add the unstable channel to our system channels:
First we need to add the unstable channel to our system channels:
<!--T:151-->
{{Warning|`nixos-rebuild --upgrade` will by default only update the channel named `nixos`, which this new channel is not. Use `nixos-rebuild --upgrade-all` instead.}}
{{Warning|`nixos-rebuild --upgrade` will by default only update the channel named `nixos`, which this new channel is not. Use `nixos-rebuild --upgrade-all` instead.}}
</translate>
</translate>
<syntaxhighlight lang="console">
<syntaxhighlight lang="console">
$ sudo nix-channel --add https://nixos.org/channels/nixos-unstable nixos-unstable
$ sudo nix-channel --add https://nixos.org/channels/nixos-unstable nixos-unstable
$ sudo nix-channel --update
$ sudo nix-channel --update
</syntaxhighlight>
</syntaxhighlight>
<translate>
<translate>
<!--T:152-->
Then we can import this channel using the angle-bracket notation to refer to it:
Then we can import this channel using the angle-bracket notation to refer to it:
</translate>
</translate>
<syntaxhighlight lang="nixos"># configuration.nix
<syntaxhighlight lang="nixos"># configuration.nix
{  
{  
Line 454: Line 468:
   ];
   ];
}</syntaxhighlight>
}</syntaxhighlight>
<translate>
<translate>
==== Using flakes ==== <!--T:153-->


==== Using flakes ====
<!--T:154-->
We simply add the unstable branch to our flake inputs, and pass them into the NixOS module system using <code>specialArgs</code>:
We simply add the unstable branch to our flake inputs, and pass them into the NixOS module system using <code>specialArgs</code>:
</translate>
</translate>
<syntaxhighlight lang="nix">
<syntaxhighlight lang="nix">
# flake.nix
# flake.nix
Line 488: Line 505:
}
}
</syntaxhighlight>
</syntaxhighlight>
<translate>
<translate>
<!--T:155-->
Using this in <code>configuration.nix</code> then looks as follows:
Using this in <code>configuration.nix</code> then looks as follows:
</translate>
</translate>
<syntaxhighlight lang="nixos">
<syntaxhighlight lang="nixos">
# configuration.nix
# configuration.nix
Line 503: Line 523:
}
}
</syntaxhighlight>
</syntaxhighlight>
<translate>
<translate>
=== How do I install a specific version of a package for build reproducibility etc.? === <!--T:14-->
=== How do I install a specific version of a package for build reproducibility etc.? === <!--T:14-->