Nix: Add prefetch function.

This commit is contained in:
Dmitry Voronin 2024-10-22 11:21:28 +03:00
parent ef467986ad
commit 48246191f8
Signed by: voronind
SSH key fingerprint: SHA256:3kBb4iV2ahufEBNq+vFbUe4QYfHt98DHQjN7QaptY9k

View file

@ -47,5 +47,18 @@
SHELL_NAME="''${pkg}" NIXPKGS_ALLOW_UNFREE=1 nix shell --impure github:NixOS/nixpkgs/''${rev}#''${pkg} -c ''${cmd} SHELL_NAME="''${pkg}" NIXPKGS_ALLOW_UNFREE=1 nix shell --impure github:NixOS/nixpkgs/''${rev}#''${pkg} -c ''${cmd}
} }
# Prefetch to nix store.
# Usage: prefetch <URL>
function prefetch() {
local url="''${1}"
if [[ "''${url}" = "" ]]; then
help prefetch
return 2
fi
nix hash to-sri --type sha256 $(nix-prefetch-url "''${url}")
}
''; '';
} }