Nix Cookbook: Difference between revisions

Vulnerabilities: Add an actual link to vulnix
 
(5 intermediate revisions by 2 users not shown)
Line 156: Line 156:
   withGui ?
   withGui ?
   if (withX != null) then
   if (withX != null) then
     lib.warn "withX is deprecated and will be removed in the next release; use withGui instead." withX
     lib.warn ''
      withX is deprecated and will be removed in the next release;
      use withGui instead.
    '' withX
   else
   else
     true
     true
Line 162: Line 165:
}
}
</syntaxHighlight>
</syntaxHighlight>
With this warning, consumers will have time to patch their codes.
== Bulk pre-download all dependencies of a package ==
Sometimes we need to download all source dependencies of a package.
E.G. a long build is being planned, so we first download all needed files, so that after that we only need to worry about local (non-Internet) issues.
Here is a one-liner for downloading all the source dependencies of a package (thanks Eelco Dolstra!):
<syntaxHighlight lang="shell">
$> nix-store -r $(grep -l outputHash $(nix-store -qR $(nix-instantiate '<nixpkgs>' -A bochs) | grep '.drv$'))
</syntaxHighlight>
Let's dissect this:
<syntaxhighlight lang="sh" line="1">
## instantiate bochs into `.drv` files and print the filenames;
instantiate=$(nix-instantiate '<nixpkgs>' -A bochs)
## print all references/requirements, filtering the .drv files (which is where static derivations live)
requirements=$(nix-store -qR $instantiate | grep '.drv$')
## keep only the source derivations, since those will have a predefined hash of the output
sources=$(grep -l outputHash $requirements)
## realize those derivations, downloading all sources and storing them in the nix store
nix-store -r $sources
</syntaxhighlight>
After that, all sources will be locally stored!
Source: [https://web.archive.org/web/20160829181620/http://lists.science.uu.nl/pipermail/nix-dev/2013-January/010438.html nix-dev thread]


== Wrapping packages ==
== Wrapping packages ==
Line 349: Line 388:
=== Vulnerabilities ===
=== Vulnerabilities ===


See Vulnix.
See [https://github.com/nix-community/vulnix vulnix].




[[Category:nix]]
[[Category:nix]]
[[Category:Cookbook]]
[[Category:Cookbook]]