mirror of
https://github.com/divnix/digga.git
synced 2024-08-17 11:00:34 +03:00
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.
This commit is contained in:
parent
828a939470
commit
e7c0700959
17
compat/fetch.nix
Normal file
17
compat/fetch.nix
Normal file
@ -0,0 +1,17 @@
|
||||
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;
|
||||
}
|
5
compat/nixpkgs.nix
Normal file
5
compat/nixpkgs.nix
Normal file
@ -0,0 +1,5 @@
|
||||
let
|
||||
fetch = import ./fetch.nix;
|
||||
nixpkgs = fetch "nixos";
|
||||
in
|
||||
nixpkgs
|
@ -1,13 +0,0 @@
|
||||
let
|
||||
inherit (builtins)
|
||||
fetchTarball
|
||||
fromJSON
|
||||
readFile
|
||||
;
|
||||
nixos = (fromJSON (readFile ./flake.lock)).nodes.nixos.locked;
|
||||
nixpkgs = fetchTarball {
|
||||
url = "https://github.com/NixOS/nixpkgs/archive/${nixos.rev}.tar.gz";
|
||||
sha256 = nixos.narHash;
|
||||
};
|
||||
in
|
||||
nixpkgs
|
Loading…
Reference in New Issue
Block a user