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

18 lines
365 B
Nix

{
lib,
runCommandLocal,
nix,
...
}: let
l = builtins // lib;
# hash the contents of a path via `nix hash path`
hashPath = algo: path: let
hashPath = runCommandLocal "hash-${algo}" {} ''
${nix}/bin/nix --option experimental-features nix-command hash path ${path} | tr --delete '\n' > $out
'';
in
l.readFile hashPath;
in
hashPath