os/compat/fetch.nix
Timothy DeHerrera e7c0700959
factor out a generic fetch from nixpkgs-compat
Create fetch function which takes a valid flake input, and calls
fetchTarball with the revision and hash information from the flake.lock.

Useful for pulling the exact revision of flake inputs from not flake
expressions, such as those in shell.nix.
2020-12-28 23:08:11 -07:00

18 lines
333 B
Nix

let
inherit (builtins)
fetchTarball
fromJSON
readFile
;
lockfile = fromJSON (readFile ../flake.lock);
in
input:
let
locked = lockfile.nodes."${input}".locked;
inherit (locked) rev narHash owner repo;
in
fetchTarball {
url = "https://github.com/${owner}/${repo}/archive/${rev}.tar.gz";
sha256 = narHash;
}