1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2024-11-23 06:01:15 +00:00
nixpkgs/pkgs/build-support/fetchgitlocal/default.nix
2015-03-31 20:00:00 -07:00

24 lines
586 B
Nix

{ runCommand, git, nix }: src:
let hash = import (runCommand "head-hash.nix"
{ dummy = builtins.currentTime;
preferLocalBuild = true; }
''
cd ${toString src}
(${git}/bin/git show && ${git}/bin/git diff) > $out
hash=$(${nix}/bin/nix-hash $out)
echo "\"$hash\"" > $out
''); in
runCommand "local-git-export"
{ dummy = hash;
preferLocalBuild = true; }
''
cd ${toString src}
mkdir -p "$out"
for file in $(${git}/bin/git ls-files); do
mkdir -p "$out/$(dirname $file)"
cp -d $file "$out/$file" || true # don't fail when trying to copy a directory
done
''