dream2nix/lib/internal/hashFile.nix

18 lines
349 B
Nix
Raw Normal View History

2023-05-19 11:26:39 +03:00
{
lib,
runCommandLocal,
nix,
...
}: let
l = builtins // lib;
# hash a file via `nix hash file`
hashFile = algo: path: let
hashFile = runCommandLocal "hash-${algo}" {} ''
${nix}/bin/nix --option experimental-features nix-command hash file ${path} | tr --delete '\n' > $out
'';
in
l.readFile hashFile;
in
hashFile