Flakes: Difference between revisions

imported>Sid-code
Rewrite introduction paragraph.
imported>Lolbinarycat
Pinning the registry to the system pkgs on NixOS: add suggestion for how to make caching more reliable
Line 299: Line 299:
   };
   };
</syntaxHighlight>
</syntaxHighlight>
{{warning|The above example seems to break nix's eval cache, and may slow down hdd systems significantly!}}
To make sure the registry entry is "locked", use the following:
<syntaxHighlight lang=nix>
  nix.registry = {
    nixpkgs.to = {
      type = "path";
      path = pkgs.path;
      narHash = builtins.readFile
          (pkgs.runCommandLocal "get-nixpkgs-hash"
            { nativeBuildInputs = [ pkgs.nix ]; }
            "nix-hash --type sha256 --sri ${pkgs.path} > $out");
    };
  };
</syntaxHighlight>
This has the unfortunate side-effect of requiring import-from-derivation and slowing down build times, however it may greatly speed up almost every eval. Full-time flakes users may be able to just use <code>narHash = pkgs.narHash</code>.


== Super fast nix-shell ==
== Super fast nix-shell ==