dream2nix/lib/internal/hashFile.nix
2023-07-19 15:53:03 +02:00

18 lines
349 B
Nix

{
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