FAQ: Difference between revisions

Rhendric (talk | contribs)
No edit summary
Line 1: Line 1:
<languages/>
<translate>
<!--T:1-->
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 21: Line 24:
* 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)


<!--T:2-->
== Why is Nix written in C++ rather than a functional language like Haskell? ==
== Why is Nix written in C++ rather than a functional language like Haskell? ==


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).


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


Line 55: Line 60:
Consult man pages of nix-store and nix-instantiate for further information.
Consult man pages of nix-store and nix-instantiate for further information.


<!--T:4-->
== Why <hash>-<name> instead of <name>-<hash>? ==
== Why <hash>-<name> instead of <name>-<hash>? ==


Line 79: Line 85:
</syntaxhighlight>
</syntaxhighlight>


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


Line 101: Line 108:
switching from generation 20 to 18
switching from generation 20 to 18
</syntaxhighlight>
</syntaxhighlight>
<!--T:6-->
== I'm working on a new package, how can I build it without adding it to nixpkgs? ==
== I'm working on a new package, how can I build it without adding it to nixpkgs? ==


Line 106: Line 115:
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.


<!--T:7-->
== How can I compile a package with debugging symbols included? ==
== How can I compile a package with debugging symbols included? ==


Line 114: Line 124:
See also [[Debug Symbols]]
See also [[Debug Symbols]]


<!--T:8-->
== How can I force a rebuild from source even without modifying the nix expression? ==
== How can I force a rebuild from source even without modifying the nix expression? ==


Line 146: Line 157:
Another way is using [[Home Manager]].
Another way is using [[Home Manager]].


<!--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 228: Line 240:
<syntaxhighlight lang="bash">nix-shell fhsUser.nix</syntaxhighlight>
<syntaxhighlight lang="bash">nix-shell fhsUser.nix</syntaxhighlight>
<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.
 
<!--T:10-->
== 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 265: Line 278:
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.


<!--T:11-->
== How do I know where's nixpkgs channel located and at which commit? ==
== How do I know where's nixpkgs channel located and at which commit? ==


Line 274: Line 288:
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-->
== 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 284: Line 299:
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.


<!--T:13-->
== There's an updated version for $software on nixpkgs but not in channels, how can I use it? ==
== There's an updated version for $software on nixpkgs but not in channels, how can I use it? ==


Line 292: Line 308:
</syntaxhighlight>
</syntaxhighlight>


<!--T:14-->
== How do I install a specific version of a package for build reproducibility etc.? ==
== How do I install a specific version of a package for build reproducibility etc.? ==


Line 298: Line 315:
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]].


<!--T:15-->
== An error occurs while fetching sources from an url, how do I fix it? ==
== An error occurs while fetching sources from an url, how do I fix it? ==


Line 320: Line 338:
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].


<!--T:16-->
== How do I know the sha256 to use with fetchgit, fetchsvn, fetchbzr or fetchcvs? ==
== How do I know the sha256 to use with fetchgit, fetchsvn, fetchbzr or fetchcvs? ==


Line 330: Line 349:
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.


<!--T:17-->
== Should I use http://hydra.nixos.org/ as a binary cache? ==
== Should I use http://hydra.nixos.org/ as a binary cache? ==


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.


<!--T:18-->
== I'm trying to install NixOS but my WiFi isn't working and I don't have an ethernet port ==
== I'm trying to install NixOS but my WiFi isn't working and I don't have an ethernet port ==


Line 342: Line 363:
For connecting to your WiFi, see [[NixOS_Installation_Guide#Wireless]]
For connecting to your WiFi, see [[NixOS_Installation_Guide#Wireless]]


<!--T:19-->
== How can I disable the binary cache and build everything locally? ==
== How can I disable the binary cache and build everything locally? ==


Line 350: Line 372:
<syntaxhighlight lang="bash">nixos-rebuild switch --option binary-caches ''</syntaxhighlight>
<syntaxhighlight lang="bash">nixos-rebuild switch --option binary-caches ''</syntaxhighlight>


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


Line 367: Line 390:
See [[Nix package manager#Sandbox_builds]] for more details.
See [[Nix package manager#Sandbox_builds]] for more details.


<!--T:21-->
== How can I install a package from unstable while remaining on the stable channel? ==
== How can I install a package from unstable while remaining on the stable channel? ==


Line 410: Line 434:
</syntaxhighlight>
</syntaxhighlight>


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


Line 427: Line 452:
Restart NixOS.
Restart NixOS.


<!--T:23-->
== What is the origin of the name "Nix" ==
== What is the origin of the name "Nix" ==


Line 454: Line 480:


[[Category:Cookbook]]
[[Category:Cookbook]]
</translate>