title: Prevent nix build from querying cache.nixos.org
body: <p>when trying to build a derivation:</p>
  <pre><code>with import &lt;nixpkgs&gt; {};
  stdenv.mkDerivation {
      name = &quot;testdrive&quot;;
      version = &quot;1.0.0&quot;;
      src = ./. ;
      phases = [
          &quot;unpackPhase&quot;  
          &quot;buildPhase&quot; 
          &quot;installPhase&quot;
      ];
      buildPhase = ''
          ${gcc}/bin/g++ a.cc -o a
      '';
      installPhase = ''
          mkdir -p $out/
          cp a $out/
      '';
  }
  </code></pre>
  <p>nix always queries <code>https://cache.nixos.org</code> before the actual build. Since the dependencies was retrieved at first build, the subsequent query seems redundant and inefficient.</p>
  <p>documentation around <a href="https://nixos.wiki/wiki/Nix_command/build" rel="nofollow noreferrer">nix build</a> command is a bit obscure. the behavior seems to relate to how nix handle the <code>src</code>.</p>
  <p>how to disable the query?</p>