Caching nix shell build inputs: Difference between revisions

imported>Fzakaria
Created page with "== Problem statement == Caching a Nix build is ''straightforward'' if there's a build result. We can use {{ic|nix-store --query --requisites}} to query the runtime closure of..."
 
Klinger (talk | contribs)
mNo edit summary
 
(2 intermediate revisions by 2 users not shown)
Line 6: Line 6:


<syntaxhighlight lang="nix">
<syntaxhighlight lang="nix">
let nixpkgs = import <nixpkgs> {};
let pkgs = import <nixpkgs> {};
in
in
with nixpkgs;
with pkgs.stdenv;
with stdenv;
with pkgs.stdenv.lib;
with stdenv.lib;
pkgs.mkShell {
mkShell {
   name = "example-shell";
   name = "example-shell";
   buildInputs = [];
  nativeBuildInputs = with pkgs.buildPackages; [ /* tools */ ];
   buildInputs = with pkgs; [ /* libs */ ];
}
}
</syntaxhighlight>
</syntaxhighlight>
Line 27: Line 27:
== How can we cache all buildInputs for mkShell? ==
== How can we cache all buildInputs for mkShell? ==


A [https://fzakaria.com/2020/08/11/caching-your-nix-shell.html blog post] on the subject improved upon the previous wisdom and came up with the following
A [https://fzakaria.com/2020/08/11/caching-your-nix-shell.html blog post] ([https://web.archive.org/web/20201012134126/https://fzakaria.com/2020/08/11/caching-your-nix-shell.html mirror]) on the subject improved upon the previous wisdom and came up with the following


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
Line 53: Line 53:
nix-build shell.nix -A inputDerivation | cachix push $name
nix-build shell.nix -A inputDerivation | cachix push $name
</syntaxhighlight>
</syntaxhighlight>
[[Category:nix]]