FAQ: Difference between revisions

imported>Dezgeg
Comment out dangerous suggestions of mounting /nix/store rw
imported>Mic92
No edit summary
Line 227: Line 227:
<syntaxhighlight lang="bash">nix-instantiate --find-file nixpkgs</syntaxhighlight>
<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.
<!-- FIXME: Needs a rewrite. This sort of dangerous crap of mounting /nix/store rw and modifying files there must NOT be suggested.


== 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 252: Line 250:
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/fetchcvs? ==
== How do I know the sha256 to use with fetchgit/fetchsvn/fetchbzr/fetchcvs? ==


Line 275: Line 272:


<syntaxhighlight lang="bash">nixos-rebuild switch --option binary-caches ""</syntaxhighlight>
<syntaxhighlight lang="bash">nixos-rebuild switch --option binary-caches ""</syntaxhighlight>
== How do I enable chrooted builds on non-NixOS? ==
== How do I enable sandboxed builds on non-NixOS? ==


Two options have to be added to make chrooted builds work on Nix, ''build-use-chroot'' and ''build-chroot-dirs'':
Two options have to be added to make sandboxed builds work on Nix, ''build-use-sandbox'' and ''build-sandbox-paths'':


<!-- TODO: WTF is the build-chroot-dirs doing here??? -->
<syntaxhighlight lang="nix">
<syntaxhighlight lang="nix">
# /etc/nix/nix.conf
# /etc/nix/nix.conf
build-use-chroot = true
build-use-sandbox = true
build-chroot-dirs = $(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>
On NixOS set the following in ''configuration.nix'':
On NixOS set the following in ''configuration.nix'':
Line 290: Line 286:
nix.useSandbox = true;
nix.useSandbox = true;
</syntaxhighlight>
</syntaxhighlight>
See [[Nix Package Manager#Sandbox_builds]] for more details.


== I cannot find $package when running <code>nix-env -qaP</code> even with channels configured ==
== I cannot find $package when running <code>nix-env -qaP</code> even with channels configured ==