FAQ: Difference between revisions
Phanirithvij (talk | contribs) m fix the broken wiki link |
Reduce header level to make font size more readable on mobile |
||
(3 intermediate revisions by 3 users not shown) | |||
Line 7: | Line 7: | ||
http://unix.stackexchange.com/questions/tagged/nixos can also be used for questions. | http://unix.stackexchange.com/questions/tagged/nixos can also be used for questions. | ||
== Why is there a new wiki? What is with nixos.wiki? == <!--T:25--> | === Why is there a new wiki? What is with nixos.wiki? === <!--T:25--> | ||
<!--T:26--> | <!--T:26--> | ||
Line 29: | Line 29: | ||
* https://greasyfork.org/en/scripts/495011-redirect-to-wiki-nixos-org (trivial userscript to redirect nixos.wiki links here) | * https://greasyfork.org/en/scripts/495011-redirect-to-wiki-nixos-org (trivial userscript to redirect nixos.wiki links here) | ||
== Why is Nix written in C++ rather than a functional language like Haskell? == <!--T:2--> | === Why is Nix written in C++ rather than a functional language like Haskell? === <!--T:2--> | ||
<!--T:30--> | <!--T:30--> | ||
Mainly because Nix is intended to be lightweight, easy to learn, and portable (zero dependencies). | Mainly because Nix is intended to be lightweight, easy to learn, and portable (zero dependencies). | ||
== 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--> | ||
<!--T:31--> | <!--T:31--> | ||
Line 70: | Line 70: | ||
Consult man pages of nix-store and nix-instantiate for further information. | Consult man pages of nix-store and nix-instantiate for further information. | ||
== Why <hash>-<name> instead of <name>-<hash>? == <!--T:4--> | === Why <hash>-<name> instead of <name>-<hash>? === <!--T:4--> | ||
<!--T:37--> | <!--T:37--> | ||
Line 99: | Line 99: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
== 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--> | ||
Line 126: | Line 126: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
== 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--> | ||
<!--T:46--> | <!--T:46--> | ||
Line 132: | Line 132: | ||
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. | ||
== How can I compile a package with debugging symbols included? == <!--T:7--> | === How can I compile a package with debugging symbols included? === <!--T:7--> | ||
<!--T:47--> | <!--T:47--> | ||
Line 143: | Line 143: | ||
See also [[Debug Symbols]] | See also [[Debug Symbols]] | ||
== How can I force a rebuild from source even without modifying the nix expression? == <!--T:8--> | === How can I force a rebuild from source even without modifying the nix expression? === <!--T:8--> | ||
<!--T:50--> | <!--T:50--> | ||
Line 150: | Line 150: | ||
<!--T:51--> | <!--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? == | === How can I manage software with nix-env like with configuration.nix? === | ||
<!--T:52--> | <!--T:52--> | ||
Line 182: | Line 182: | ||
<!--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 211: | Line 211: | ||
programs.nix-ld = { | programs.nix-ld = { | ||
enable = true; | enable = true; | ||
libraries = pkgs.steam-run | libraries = pkgs.steam-run.args.multiPkgs pkgs; | ||
};</syntaxhighlight> | };</syntaxhighlight> | ||
Line 279: | Line 279: | ||
<br> | <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. | ||
== What are channels and how do they get updated? == | |||
=== What are channels and how do they get updated? === | |||
{{main|Channel branches}} | {{main|Channel branches}} | ||
Line 323: | Line 324: | ||
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. | ||
== How do I know where's nixpkgs channel located and at which commit? == <!--T:11--> | === How do I know where's nixpkgs channel located and at which commit? === <!--T:11--> | ||
<!--T:78--> | <!--T:78--> | ||
Line 336: | Line 337: | ||
<!--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 349: | Line 350: | ||
So in short, the <code>relase-XX.YY</code> branches have not been run through Hydra yet, whereas the <code>nixos-XX.YY</code> ones have. | So in short, the <code>relase-XX.YY</code> branches have not been run through Hydra yet, whereas the <code>nixos-XX.YY</code> ones have. | ||
== There's an updated version for $software on nixpkgs but not in channels, how can I use it? == <!--T:13--> | === There's an updated version for $software on nixpkgs but not in channels, how can I use it? === <!--T:13--> | ||
<!--T:84--> | <!--T:84--> | ||
Line 359: | Line 360: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
== 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--> | ||
<!--T:86--> | <!--T:86--> | ||
Line 367: | Line 368: | ||
if you just want the old version of the single package but with new dependencies it is often easier to copy the package description into your scope and add it to your <code>configuration.nix</code> via: <code> mypackage-old = pkgs.callPackage ./mypackage-old.nix {};</code>.You can try to build the package as described in [[FAQ#I.27m_working_on_a_new_package.2C_how_can_I_build_it_without_adding_it_to_nixpkgs.3F|the FAQ: building a single derivation]]. | if you just want the old version of the single package but with new dependencies it is often easier to copy the package description into your scope and add it to your <code>configuration.nix</code> via: <code> mypackage-old = pkgs.callPackage ./mypackage-old.nix {};</code>.You can try to build the package as described in [[FAQ#I.27m_working_on_a_new_package.2C_how_can_I_build_it_without_adding_it_to_nixpkgs.3F|the FAQ: building a single derivation]]. | ||
== An error occurs while fetching sources from an url, how do I fix it? == <!--T:15--> | === An error occurs while fetching sources from an url, how do I fix it? === <!--T:15--> | ||
<!--T:88--> | <!--T:88--> | ||
Line 373: | Line 374: | ||
<!--T:89--> | <!--T:89--> | ||
If that fails you can update the url in the nix expression yourself. [ | If that fails you can update the url in the nix expression yourself. [[#How_do_I_know_where's_nixpkgs_channel_located_and_at_which_commit?|Navigate to your channel's expressions]] and find the package in one of the subdirectories. Edit the respective ''default.nix'' file by altering the ''url'' and ''sha256''. You can use <code>nix-prefetch-url url</code> to get the SHA-256 hash of source distributions. | ||
<!--T:90--> | <!--T:90--> | ||
Line 397: | Line 398: | ||
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]. | ||
== How do I know the sha256 to use with fetchgit, fetchsvn, fetchbzr or fetchcvs? == <!--T:16--> | === How do I know the sha256 to use with fetchgit, fetchsvn, fetchbzr or fetchcvs? === <!--T:16--> | ||
<!--T:96--> | <!--T:96--> | ||
Line 411: | Line 412: | ||
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. | ||
== Should I use http://hydra.nixos.org/ as a binary cache? == <!--T:17--> | === Should I use http://hydra.nixos.org/ as a binary cache? === <!--T:17--> | ||
<!--T:100--> | <!--T:100--> | ||
No. As of 2017, all build artifacts are directly pushed to http://cache.nixos.org/ and are available there, therefore setting http://hydra.nixos.org/ as a binary cache no longer serves any function. | No. As of 2017, all build artifacts are directly pushed to http://cache.nixos.org/ and are available there, therefore setting http://hydra.nixos.org/ as a binary cache no longer serves any function. | ||
== I'm trying to install NixOS but my WiFi isn't working and I don't have an ethernet port == <!--T:18--> | === I'm trying to install NixOS but my WiFi isn't working and I don't have an ethernet port === <!--T:18--> | ||
<!--T:101--> | <!--T:101--> | ||
Line 427: | Line 428: | ||
For connecting to your WiFi, see [[NixOS_Installation_Guide#Wireless]] | For connecting to your WiFi, see [[NixOS_Installation_Guide#Wireless]] | ||
== How can I disable the binary cache and build everything locally? == <!--T:19--> | === How can I disable the binary cache and build everything locally? === <!--T:19--> | ||
<!--T:104--> | <!--T:104--> | ||
Line 438: | Line 439: | ||
<syntaxhighlight lang="bash">nixos-rebuild switch --option binary-caches ''</syntaxhighlight> | <syntaxhighlight lang="bash">nixos-rebuild switch --option binary-caches ''</syntaxhighlight> | ||
== 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--> | ||
Line 459: | Line 460: | ||
See [[Nix package manager#Sandbox_builds]] for more details. | See [[Nix package manager#Sandbox_builds]] for more details. | ||
== How can I install a package from unstable while remaining on the stable channel? == <!--T:21--> | === How can I install a package from unstable while remaining on the stable channel? === <!--T:21--> | ||
<!--T:111--> | <!--T:111--> | ||
Line 510: | Line 511: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
== 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--> | ||
<!--T:119--> | <!--T:119--> | ||
Line 534: | Line 535: | ||
Restart NixOS. | Restart NixOS. | ||
== What is the origin of the name "Nix" == <!--T:23--> | === What is the origin of the name "Nix" === <!--T:23--> | ||
<!--T:126--> | <!--T:126--> | ||
Line 540: | Line 541: | ||
<!--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. | ||
== I'm getting ‘infinite recursion’ errors when trying to do something clever with <code>imports</code> == <!--T:128--> | === I'm getting ‘infinite recursion’ errors when trying to do something clever with <code>imports</code> === <!--T:128--> | ||
<!--T:129--> | <!--T:129--> |