FAQ: Difference between revisions

Ardenet (talk | contribs)
Marked this version for translation
Tags: Mobile edit Mobile web edit
Ardenet (talk | contribs)
Adjust tranlate tag's placement
Line 1: Line 1:
<languages/>
<languages/>
{{cleanup}}
<translate>
<translate>
<!--T:1-->
<!--T:1-->
{{cleanup}}
Frequently asked questions and common newcomer trouble should be put here so that we can point to this page instead of answering the same question over and over again.
Frequently asked questions and common newcomer trouble should be put here so that we can point to this page instead of answering the same question over and over again.


Line 36: Line 36:


=== How to keep build-time dependencies around / be able to rebuild while being offline? === <!--T:3-->
=== How to keep build-time dependencies around / be able to rebuild while being offline? === <!--T:3-->
</translate>


<!--T:31-->
<syntaxhighlight lang="nix"># /etc/nixos/configuration.nix
<syntaxhighlight lang="nix"># /etc/nixos/configuration.nix
{ config, pkgs, lib, ... }:
{ config, pkgs, lib, ... }:
Line 48: Line 48:
   };
   };
}</syntaxhighlight>
}</syntaxhighlight>
<translate>
<!--T:31-->
Check 'man configuration.nix' for these options. Rebuild for these options to take effect:
Check 'man configuration.nix' for these options. Rebuild for these options to take effect:
</translate>
<syntaxhighlight lang="bash">nixos-rebuild switch</syntaxhighlight>


<translate>
<!--T:32-->
<!--T:32-->
<syntaxhighlight lang="bash">nixos-rebuild switch</syntaxhighlight>
List all store paths that form the system closure and realise them:
List all store paths that form the system closure and realise them:
</translate>


<!--T:33-->
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
nix-store -qR $(nix-instantiate '<nixpkgs/nixos>' -A system) | xargs nix-store -r
nix-store -qR $(nix-instantiate '<nixpkgs/nixos>' -A system) | xargs nix-store -r
warning: you did not specify `--add-root'; the result might be removed by the garbage collector
warning: you did not specify `--add-root'; the result might be removed by the garbage collector


<!--T:34-->
<build output and list of successfully realised paths>
<build output and list of successfully realised paths>
</syntaxhighlight>
</syntaxhighlight>
<translate>
<!--T:34-->
Repeat for your user and further profiles:
Repeat for your user and further profiles:
</translate>


<syntaxhighlight lang="bash">nix-store -qR ~/.nix-profile | xargs nix-store -r</syntaxhighlight>
<translate>
<!--T:35-->
<!--T:35-->
<syntaxhighlight lang="bash">nix-store -qR ~/.nix-profile | xargs nix-store -r</syntaxhighlight>
The warning can be ignored for profiles that are listed/linked in ''/nix/var/nix/profiles/'' or one of its subdirectories.
The warning can be ignored for profiles that are listed/linked in ''/nix/var/nix/profiles/'' or one of its subdirectories.


Line 86: Line 97:
<!--T:40-->
<!--T:40-->
This is what might happen if you don't garbage collect frequently, or if you are testing compilation variants:
This is what might happen if you don't garbage collect frequently, or if you are testing compilation variants:
</translate>


<!--T:41-->
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
q0yi2nr8i60gm2zap46ryysydd2nhzhp-automake-1.11.1/
q0yi2nr8i60gm2zap46ryysydd2nhzhp-automake-1.11.1/
Line 100: Line 111:
</syntaxhighlight>
</syntaxhighlight>


<translate>
=== I've updated my channel and something is broken, how can I rollback to an earlier channel? === <!--T:5-->
=== I've updated my channel and something is broken, how can I rollback to an earlier channel? === <!--T:5-->


<!--T:42-->
<!--T:42-->
View the available generations of your channel:
View the available generations of your channel:
</translate>


<!--T:43-->
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
nix-env --list-generations -p /nix/var/nix/profiles/per-user/root/channels
nix-env --list-generations -p /nix/var/nix/profiles/per-user/root/channels
Line 112: Line 124:
20  2014-08-12 19:09:20  (current)
20  2014-08-12 19:09:20  (current)
</syntaxhighlight>
</syntaxhighlight>
<translate>
<!--T:43-->
To rollback to the previous generation:
To rollback to the previous generation:
</translate>


<!--T:44-->
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
nix-env --rollback -p /nix/var/nix/profiles/per-user/root/channels
nix-env --rollback -p /nix/var/nix/profiles/per-user/root/channels
switching from generation 20 to 19
switching from generation 20 to 19
</syntaxhighlight>
</syntaxhighlight>
<translate>
<!--T:44-->
To switch to a particular generation:
To switch to a particular generation:
</translate>


<!--T:45-->
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
nix-env --switch-generation 18 -p /nix/var/nix/profiles/per-user/root/channels
nix-env --switch-generation 18 -p /nix/var/nix/profiles/per-user/root/channels
Line 127: Line 145:
</syntaxhighlight>
</syntaxhighlight>


<translate>
=== I'm working on a new package, how can I build it without adding it to nixpkgs? === <!--T:6-->
=== I'm working on a new package, how can I build it without adding it to nixpkgs? === <!--T:6-->
</translate>


<syntaxhighlight lang="bash">nix-build -E 'with import <nixpkgs> { }; callPackage ./mypackage.nix { }'</syntaxhighlight>
<translate>
<!--T:46-->
<!--T:46-->
<syntaxhighlight lang="bash">nix-build -E 'with import <nixpkgs> { }; callPackage ./mypackage.nix { }'</syntaxhighlight>
You can replace callPackage with callPackage_i686 to build the 32-bit version of your package on a 64-bit system if you want to test that.
You can replace callPackage with callPackage_i686 to build the 32-bit version of your package on a 64-bit system if you want to test that.


Line 137: Line 159:
<!--T:47-->
<!--T:47-->
To build a package with -Og and -g, and without stripping debug symbols use:
To build a package with -Og and -g, and without stripping debug symbols use:
</translate>


<!--T:48-->
<syntaxhighlight lang="bash">nix-build -E 'with import <nixpkgs> { }; enableDebugging fooPackage'</syntaxhighlight>
<syntaxhighlight lang="bash">nix-build -E 'with import <nixpkgs> { }; enableDebugging fooPackage'</syntaxhighlight>


<translate>
<!--T:49-->
<!--T:49-->
See also [[Debug Symbols]]
See also [[Debug Symbols]]
Line 148: Line 171:
<!--T:50-->
<!--T:50-->
As root you can run nix-build with the --check flag:
As root you can run nix-build with the --check flag:
</translate>


<!--T:51-->
<syntaxhighlight lang="bash">sudo nix-build --check -A ncdu</syntaxhighlight>
<syntaxhighlight lang="bash">sudo nix-build --check -A ncdu</syntaxhighlight>
=== How can I manage software with nix-env like with configuration.nix? ===
 
<translate>
=== How can I manage software with nix-env like with configuration.nix? === <!--T:51-->


<!--T:52-->
<!--T:52-->
There are many ways, one is the following:
There are many ways, one is the following:
</translate>


<!--T:53-->
<ol style="list-style-type: decimal;">
<ol style="list-style-type: decimal;">
<li><p>Create a meta package called ''userPackages'' your ''~/.config/nixpkgs/config.nix'' file with the packages you would like to have in your environment:</p>
<li><p><translate><!--T:53--> Create a meta package called ''userPackages'' your ''~/.config/nixpkgs/config.nix'' file with the packages you would like to have in your environment:</translate></p>
<syntaxhighlight lang="nix">
<syntaxhighlight lang="nix">
with (import <nixpkgs> {});
with (import <nixpkgs> {});
Line 173: Line 198:
}
}
</syntaxhighlight></li>
</syntaxhighlight></li>
<li><p>Install all specified packages using this command:</p>
<li><p><translate>Install all specified packages using this command:</translate></p>
<syntaxhighlight lang="bash">nix-env -iA userPackages -f '<nixpkgs>'</syntaxhighlight></li></ol>
<syntaxhighlight lang="bash">nix-env -iA userPackages -f '<nixpkgs>'</syntaxhighlight></li></ol>


<translate>
<!--T:54-->
<!--T:54-->
Now you can add and remove packages from the paths list and rerun nix-env to update your user local packages.
Now you can add and remove packages from the paths list and rerun nix-env to update your user local packages.
Line 184: Line 210:
<!--T:9-->
<!--T:9-->
=== I've downloaded a binary, but I can't run it, what can I do? ===
=== I've downloaded a binary, but I can't run it, what can I do? ===
Binaries normally do not work out of the box when you download them because they normally just assume that libraries can be found in hardcoded paths such as <code>/lib</code>. However this assumption is incorrect on NixOS systems due to the inner workings of <code>nix</code> - there is no default path, everything gets set to the corresponding version on compile time.
Binaries normally do not work out of the box when you download them because they normally just assume that libraries can be found in hardcoded paths such as <code>/lib</code>. However this assumption is incorrect on NixOS systems due to the inner workings of <code>nix</code> - there is no default path, everything gets set to the corresponding version on compile time.


Line 194: Line 221:
<!--T:58-->
<!--T:58-->
You can use [https://github.com/Mic92/nix-ld nix-ld] to run compiled binaries. For example, if your binary needs zlib and openssl:
You can use [https://github.com/Mic92/nix-ld nix-ld] to run compiled binaries. For example, if your binary needs zlib and openssl:
</translate>


<!--T:59-->
<syntaxhighlight lang="nix">
<syntaxhighlight lang="nix">
programs.nix-ld = {
programs.nix-ld = {
Line 202: Line 229:
};</syntaxhighlight>
};</syntaxhighlight>


<translate>
<!--T:60-->
<!--T:60-->
Log out and back in to apply the environment variables it sets, and you can then directly run the binary.
Log out and back in to apply the environment variables it sets, and you can then directly run the binary.
Line 207: Line 235:
<!--T:61-->
<!--T:61-->
If you don't want to configure the list of libraries manually, a quick and dirty way to run nearly any precompiled binary is the following:
If you don't want to configure the list of libraries manually, a quick and dirty way to run nearly any precompiled binary is the following:
</translate>


<!--T:62-->
<syntaxhighlight lang="nix">
<syntaxhighlight lang="nix">
programs.nix-ld = {
programs.nix-ld = {
Line 215: Line 243:
};</syntaxhighlight>
};</syntaxhighlight>


<translate>
<!--T:63-->
<!--T:63-->
This uses the libraries that are used by [[Steam]] to simulate a traditional Linux FHS environment to run games in. It's a [https://github.com/NixOS/nixpkgs/blob/nixos-unstable/pkgs/by-name/st/steam/package.nix big list] that usually contains all the libraries your binary needs to run.
This uses the libraries that are used by [[Steam]] to simulate a traditional Linux FHS environment to run games in. It's a [https://github.com/NixOS/nixpkgs/blob/nixos-unstable/pkgs/by-name/st/steam/package.nix big list] that usually contains all the libraries your binary needs to run.
Line 220: Line 249:
<!--T:64-->
<!--T:64-->
Another possibility is to use [https://nixos.org/patchelf.html patchelf] to set the library path and dynamic linker appropriately, since compiled binaries have hard-coded interpreter and require certain dynamic libraries.
Another possibility is to use [https://nixos.org/patchelf.html patchelf] to set the library path and dynamic linker appropriately, since compiled binaries have hard-coded interpreter and require certain dynamic libraries.
</translate>


<!--T:65-->
<syntaxhighlight lang="nix">
<syntaxhighlight lang="nix">
# mybinaryprogram.nix
# mybinaryprogram.nix
Line 242: Line 271:
   '';
   '';
}</syntaxhighlight>
}</syntaxhighlight>
<translate>
<!--T:65-->
This can be built with:
This can be built with:
</translate>
<syntaxhighlight lang="bash">nix-build mybinaryprogram.nix</syntaxhighlight>


<translate>
<!--T:66-->
<!--T:66-->
<syntaxhighlight lang="bash">nix-build mybinaryprogram.nix</syntaxhighlight>
And run with:
And run with:
</translate>


<syntaxhighlight lang="bash">./result/bin/mybinaryprogram</syntaxhighlight>
<translate>
<!--T:67-->
<!--T:67-->
<syntaxhighlight lang="bash">./result/bin/mybinaryprogram</syntaxhighlight>
Another possibility is using a FHS-compatible Sandbox with [https://nixos.org/nixpkgs/manual/#sec-fhs-environments buildFHSUserEnv]
Another possibility is using a FHS-compatible Sandbox with [https://nixos.org/nixpkgs/manual/#sec-fhs-environments buildFHSUserEnv]
</translate>


<!--T:68-->
<syntaxhighlight lang="nix">
<syntaxhighlight lang="nix">
# fhsUser.nix
# fhsUser.nix
Line 274: Line 312:
   runScript = "bash";
   runScript = "bash";
}).env</syntaxhighlight>
}).env</syntaxhighlight>
<translate>
<!--T:68-->
the sandbox can be entered with
the sandbox can be entered with
</translate>


<syntaxhighlight lang="bash">nix-shell fhsUser.nix</syntaxhighlight>
<translate>
<!--T:10-->
<!--T:10-->
<syntaxhighlight lang="bash">nix-shell fhsUser.nix</syntaxhighlight>
<br>
If your target application can't find shared libraries inside buildFHSUserEnv, you may run [https://github.com/lexleogryfon/de-generate nix-de-generate] for target application inside FHS, which will generate newenv.nix file, an nix-expression of buildFHSUserEnv with resolved dependencies for shared libraries.
If your target application can't find shared libraries inside buildFHSUserEnv, you may run [https://github.com/lexleogryfon/de-generate nix-de-generate] for target application inside FHS, which will generate newenv.nix file, an nix-expression of buildFHSUserEnv with resolved dependencies for shared libraries.


<!--T:136-->
<!--T:136-->
=== What are channels and how do they get updated? ===
=== What are channels and how do they get updated? ===
</translate>
{{main|Channel branches}}
{{main|Channel branches}}


<translate>
<!--T:69-->
<!--T:69-->
[https://github.com/NixOS/nixpkgs Nixpkgs] is the git repository containing all packages and NixOS modules/expressions. Installing packages directly from Nixpkgs master branch is possible but a bit risky as git commits are merged into master before being heavily tested. That's where channels are useful.
[https://github.com/NixOS/nixpkgs Nixpkgs] is the git repository containing all packages and NixOS modules/expressions. Installing packages directly from Nixpkgs master branch is possible but a bit risky as git commits are merged into master before being heavily tested. That's where channels are useful.
Line 317: Line 363:
* For nixos-small: the unstable-small [http://hydra.nixos.org/job/nixos/unstable-small/tested tested] job.
* For nixos-small: the unstable-small [http://hydra.nixos.org/job/nixos/unstable-small/tested tested] job.
* For nixpkgs: the trunk [http://hydra.nixos.org/job/nixpkgs/trunk/unstable unstable] job, which contains some critical release packages.
* For nixpkgs: the trunk [http://hydra.nixos.org/job/nixpkgs/trunk/unstable unstable] job, which contains some critical release packages.
</translate>


<!--T:76-->
<ol start="2" style="list-style-type: decimal;">
<ol start="2" style="list-style-type: decimal;">
<li>Once the job succeeds at a particular nixpkgs commit, '''cache.nixos.org''' will download binaries from '''hydra.nixos.org'''.</li>
<li><translate><!--T:76--> Once the job succeeds at a particular nixpkgs commit, '''cache.nixos.org''' will download binaries from '''hydra.nixos.org'''.</translate></li>
<li>Once the above download completes, the channel updates.</li></ol>
<li><translate>Once the above download completes, the channel updates.</translate></li>
</ol>


<translate>
<!--T:77-->
<!--T:77-->
You can checkout the nixpkgs git and reset it to a particular commit of a channel. This will not affect your access to the binary cache.
You can checkout the nixpkgs git and reset it to a particular commit of a channel. This will not affect your access to the binary cache.
Line 333: Line 382:
<!--T:79-->
<!--T:79-->
If you want to know where <nixpkgs> is located:
If you want to know where <nixpkgs> is located:
</translate>
<syntaxhighlight lang="bash">nix-instantiate --find-file nixpkgs</syntaxhighlight>


<translate>
<!--T:80-->
<!--T:80-->
<syntaxhighlight lang="bash">nix-instantiate --find-file nixpkgs</syntaxhighlight>
To know the commit, open the .version-suffix file in the nixpkgs location. The hash after the dot is the git commit.
To know the commit, open the .version-suffix file in the nixpkgs location. The hash after the dot is the git commit.


<!--T:12-->
<!--T:12-->
=== Nixpkgs branches ===
=== Nixpkgs branches ===
Branches on the nixpkgs repo have a relationship with channels, but that relationship is not 1:1.
Branches on the nixpkgs repo have a relationship with channels, but that relationship is not 1:1.


Line 356: Line 409:
<!--T:84-->
<!--T:84-->
You can jump the queue and use <code>nix-shell</code> with a <code>NIX_PATH</code> pointing to a tarball of the channel to get a shell for that software. Some building may occur. This will not work for system services.
You can jump the queue and use <code>nix-shell</code> with a <code>NIX_PATH</code> pointing to a tarball of the channel to get a shell for that software. Some building may occur. This will not work for system services.
</translate>


<!--T:85-->
<syntaxhighlight lang="command">
<syntaxhighlight lang="command">
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>
=== 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-->


Line 383: Line 437:
<!--T:91-->
<!--T:91-->
start a new shell with a private mount namespace (Linux-only)
start a new shell with a private mount namespace (Linux-only)
</translate>
<syntaxhighlight lang="bash">sudo unshare -m bash</syntaxhighlight>


<translate>
<!--T:92-->
<!--T:92-->
<syntaxhighlight lang="bash">sudo unshare -m bash</syntaxhighlight>
remount the filesystem with write privileges (as root)
remount the filesystem with write privileges (as root)
</translate>
<syntaxhighlight lang="bash">mount -o remount,rw /nix/store</syntaxhighlight>


<translate>
<!--T:93-->
<!--T:93-->
<syntaxhighlight lang="bash">mount -o remount,rw /nix/store</syntaxhighlight>
update the file
update the file
</translate>
<syntaxhighlight lang="bash">nano <PATH_TO_PACKAGE>/default.nix</syntaxhighlight>


<translate>
<!--T:94-->
<!--T:94-->
<syntaxhighlight lang="bash">nano <PATH_TO_PACKAGE>/default.nix</syntaxhighlight>
exit to shell where /nix/store is still mounted read-only
exit to shell where /nix/store is still mounted read-only
</translate>


<syntaxhighlight lang="bash">exit</syntaxhighlight>
<translate>
<!--T:95-->
<!--T:95-->
<syntaxhighlight lang="bash">exit</syntaxhighlight>
Be sure to [https://github.com/NixOS/nixpkgs/issues report the incorrect url] or [https://github.com/NixOS/nixpkgs/pulls fix it yourself].
Be sure to [https://github.com/NixOS/nixpkgs/issues report the incorrect url] or [https://github.com/NixOS/nixpkgs/pulls fix it yourself].


Line 407: Line 473:
<!--T:97-->
<!--T:97-->
For instance to get the checksum of a git repository use:
For instance to get the checksum of a git repository use:
</translate>


<!--T:98-->
<syntaxhighlight lang="bash">nix-prefetch-git https://git.zx2c4.com/password-store</syntaxhighlight>
<syntaxhighlight lang="bash">nix-prefetch-git https://git.zx2c4.com/password-store</syntaxhighlight>


<translate>
<!--T:99-->
<!--T:99-->
Or, use <code>lib.fakeHash</code> as the fetcher's hash argument, and attempt to build; Nix will tell you the actual and expected hash's mismatch, and you may copy the actual hash.
Or, use <code>lib.fakeHash</code> as the fetcher's hash argument, and attempt to build; Nix will tell you the actual and expected hash's mismatch, and you may copy the actual hash.
Line 437: Line 504:
<!--T:105-->
<!--T:105-->
This is also useful to make simple configuration changes in NixOS (ex.: network related), when no network connectivity is available:
This is also useful to make simple configuration changes in NixOS (ex.: network related), when no network connectivity is available:
</translate>


<!--T:106-->
<syntaxhighlight lang="bash">nixos-rebuild switch --option binary-caches ''</syntaxhighlight>
<syntaxhighlight lang="bash">nixos-rebuild switch --option binary-caches ''</syntaxhighlight>


<translate>
=== How do I enable sandboxed builds on non-NixOS? === <!--T:20-->
=== How do I enable sandboxed builds on non-NixOS? === <!--T:20-->


<!--T:107-->
<!--T:107-->
Two options have to be added to make sandboxed builds work on Nix, ''build-use-sandbox'' and ''build-sandbox-paths'':
Two options have to be added to make sandboxed builds work on Nix, ''build-use-sandbox'' and ''build-sandbox-paths'':
</translate>


<!--T:108-->
<syntaxhighlight lang="nix">
<syntaxhighlight lang="nix">
# /etc/nix/nix.conf
# /etc/nix/nix.conf
Line 452: Line 520:
build-sandbox-paths = $(nix-store -qR $(nix-build '<nixpkgs>' -A bash) | xargs echo /bin/sh=$(nix-build '<nixpkgs>' -A bash)/bin/bash)
build-sandbox-paths = $(nix-store -qR $(nix-build '<nixpkgs>' -A bash) | xargs echo /bin/sh=$(nix-build '<nixpkgs>' -A bash)/bin/bash)
</syntaxhighlight>
</syntaxhighlight>
<translate>
<!--T:108-->
On NixOS set the following in ''configuration.nix'':
On NixOS set the following in ''configuration.nix'':
</translate>


<!--T:109-->
<syntaxhighlight lang="nix">
<syntaxhighlight lang="nix">
nix.settings.sandbox = true;
nix.settings.sandbox = true;
</syntaxhighlight>
</syntaxhighlight>


<translate>
<!--T:110-->
<!--T:110-->
See [[Nix package manager#Sandbox_builds]] for more details.
See [[Nix package manager#Sandbox_builds]] for more details.
Line 466: Line 538:
<!--T:111-->
<!--T:111-->
If you simply want to run a ''nix-shell'' with a package from unstable, you can run a command like the following:
If you simply want to run a ''nix-shell'' with a package from unstable, you can run a command like the following:
</translate>


<!--T:112-->
<syntaxhighlight lang="bash">nix-shell -I nixpkgs=channel:nixpkgs-unstable -p somepackage</syntaxhighlight>
<syntaxhighlight lang="bash">nix-shell -I nixpkgs=channel:nixpkgs-unstable -p somepackage</syntaxhighlight>


<translate>
<!--T:113-->
<!--T:113-->
It is possible to have multiple nix-channels simultaneously. To add the unstable channel with the specifier ''unstable'',
It is possible to have multiple nix-channels simultaneously. To add the unstable channel with the specifier ''unstable'',
</translate>
<syntaxhighlight lang="bash">sudo nix-channel --add https://nixos.org/channels/nixos-unstable nixos-unstable</syntaxhighlight>


<translate>
<!--T:114-->
<!--T:114-->
<syntaxhighlight lang="bash">sudo nix-channel --add https://nixos.org/channels/nixos-unstable nixos-unstable</syntaxhighlight>
After updating the channel
After updating the channel
</translate>
<syntaxhighlight lang="bash">sudo nix-channel --update nixos-unstable</syntaxhighlight>


<translate>
<!--T:115-->
<!--T:115-->
<syntaxhighlight lang="bash">sudo nix-channel --update nixos-unstable</syntaxhighlight>
queries via <code>nix-env</code> will show packages from both ''stable'' and ''unstable''. Use this to install unstable packages into your user environment. The following snippet shows how this can be done in ''configuration.nix''.
queries via <code>nix-env</code> will show packages from both ''stable'' and ''unstable''. Use this to install unstable packages into your user environment. The following snippet shows how this can be done in ''configuration.nix''.
</translate>


<!--T:116-->
<syntaxhighlight lang="nix">
<syntaxhighlight lang="nix">
{ config, pkgs, ... }:
{ config, pkgs, ... }:
Line 491: Line 570:
</syntaxhighlight>
</syntaxhighlight>


<translate>
<!--T:117-->
<!--T:117-->
This only changes what version of <code>PACKAGE_NAME</code> is available on <code>$PATH</code>. If the package you want to take from unstable is installed through a NixOS module, you must use [[overlays]]:
This only changes what version of <code>PACKAGE_NAME</code> is available on <code>$PATH</code>. If the package you want to take from unstable is installed through a NixOS module, you must use [[overlays]]:
</translate>
<syntaxhighlight lang="nix">
<syntaxhighlight lang="nix">
{ config, pkgs, ... }:
{ config, pkgs, ... }:
Line 505: Line 587:
}
}
</syntaxhighlight>
</syntaxhighlight>
<translate>
Note that this will rebuild all packages depending on the overlaid package, which may be a lot. Some modules offer a <code>services.foo.package</code> to change the actual derivation used by the module without and overlay, and without recompiling dependencies ([https://nixos.org/manual/nixos/stable/options.html#opt-services.gvfs.package example]).
Note that this will rebuild all packages depending on the overlaid package, which may be a lot. Some modules offer a <code>services.foo.package</code> to change the actual derivation used by the module without and overlay, and without recompiling dependencies ([https://nixos.org/manual/nixos/stable/options.html#opt-services.gvfs.package example]).


<!--T:118-->
<!--T:118-->
If you want to install unfree packages from unstable you need to also set allowUnfree by replacing the import statment above with:
If you want to install unfree packages from unstable you need to also set allowUnfree by replacing the import statment above with:
</translate>
<syntaxhighlight lang="nix">
<syntaxhighlight lang="nix">
import <nixos-unstable> { config = { allowUnfree = true; }; }
import <nixos-unstable> { config = { allowUnfree = true; }; }
</syntaxhighlight>
</syntaxhighlight>


<translate>
=== I'm unable to connect my USB HDD | External HDD is failing to mount automatically === <!--T:22-->
=== I'm unable to connect my USB HDD | External HDD is failing to mount automatically === <!--T:22-->


Line 520: Line 607:
<!--T:120-->
<!--T:120-->
exfat is not supported in NixOS by default - since there are legality issues still with exFAT filesystem.  
exfat is not supported in NixOS by default - since there are legality issues still with exFAT filesystem.  
</translate>


<!--T:121-->
<syntaxhighlight lang="bash">su nano /etc/nixos/configuration.nix</syntaxhighlight>
<syntaxhighlight lang="bash">su nano /etc/nixos/configuration.nix</syntaxhighlight>


<translate>
<!--T:122-->
<!--T:122-->
Add this line to your configuration file.
Add this line to your configuration file.
</translate>
<syntaxhighlight lang="bash">boot.extraModulePackages = [ config.boot.kernelPackages.exfat-nofuse ];</syntaxhighlight>
<syntaxhighlight lang="bash">boot.extraModulePackages = [ config.boot.kernelPackages.exfat-nofuse ];</syntaxhighlight>


<translate>
<!--T:123-->
<!--T:123-->
After saving the file rebuild NixOS:
After saving the file rebuild NixOS:
</translate>


<!--T:124-->
<syntaxhighlight lang="bash">nixos-rebuild switch</syntaxhighlight>
<syntaxhighlight lang="bash">nixos-rebuild switch</syntaxhighlight>


<translate>
<!--T:125-->
<!--T:125-->
Restart NixOS.
Restart NixOS.
Line 544: Line 636:
<!--T:127-->
<!--T:127-->
=== What does it mean to say that NixOS is "immutable" ===
=== What does it mean to say that NixOS is "immutable" ===
Immutability is a property of data, in general, which means that the data cannot be modified after it is created. In the context of an operating system, it really means that certain parts of the system have this property. In the case of Nix and NixOS, that includes the Nix store, where files can be created but not modified after the time they are created. It does not apply to every part of the operating system, in that users can still modify their own files in their home directory, for example.
Immutability is a property of data, in general, which means that the data cannot be modified after it is created. In the context of an operating system, it really means that certain parts of the system have this property. In the case of Nix and NixOS, that includes the Nix store, where files can be created but not modified after the time they are created. It does not apply to every part of the operating system, in that users can still modify their own files in their home directory, for example.


Line 559: Line 652:
<!--T:132-->
<!--T:132-->
(Note that none of this applies to the [https://nix.dev/manual/nix/stable/language/builtins#builtins-import <code>import</code> built-in Nix language function], which is its own thing.)
(Note that none of this applies to the [https://nix.dev/manual/nix/stable/language/builtins#builtins-import <code>import</code> built-in Nix language function], which is its own thing.)
</translate>


<!--T:133-->
{{:FAQ/Libraries}}
{{:FAQ/Libraries}}
{{:FAQ/nix-env -iA}}
{{:FAQ/nix-env -iA}}
Line 567: Line 660:
<!-- Transclude subpages -->
<!-- Transclude subpages -->


<translate>
== References == <!--T:134-->
== References == <!--T:134-->