Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ runCommand, git, lib }: 2 3lib.makeOverridable ( 4src: 5 6let 7 srcStr = toString src; 8 9 # Adds the current directory (respecting ignored files) to the git store, and returns the hash 10 gitHashFile = runCommand "put-in-git" { 11 nativeBuildInputs = [ git ]; 12 dummy = builtins.currentTime; # impure, do every time 13 preferLocalBuild = true; 14 } '' 15 cd ${srcStr} 16 DOT_GIT=$(git rev-parse --resolve-git-dir .git) # path to repo 17 18 cp $DOT_GIT/index $DOT_GIT/index-user # backup index 19 git reset # reset index 20 git add . # add current directory 21 22 # hash of current directory 23 # remove trailing newline 24 git rev-parse $(git write-tree) \ 25 | tr -d '\n' > $out 26 27 mv $DOT_GIT/index-user $DOT_GIT/index # restore index 28 ''; 29 30 gitHash = builtins.readFile gitHashFile; # cache against git hash 31 32 nixPath = runCommand "put-in-nix" { 33 nativeBuildInputs = [ git ]; 34 preferLocalBuild = true; 35 } '' 36 mkdir $out 37 38 # dump tar of *current directory* at given revision 39 git -C ${srcStr} archive --format=tar ${gitHash} \ 40 | tar xf - -C $out 41 ''; 42 43in nixPath 44)