1 { runCommand, git, lib }:
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;
16 DOT_GIT=$(git rev-parse --resolve-git-dir .git) # path to repo
18 cp $DOT_GIT/index $DOT_GIT/index-user # backup index
19 git reset # reset index
20 git add . # add current directory
22 # hash of current directory
23 # remove trailing newline
24 git rev-parse $(git write-tree) \
27 mv $DOT_GIT/index-user $DOT_GIT/index # restore index
30 gitHash = builtins.readFile gitHashFile; # cache against git hash
32 nixPath = runCommand "put-in-nix" {
33 nativeBuildInputs = [ git ];
34 preferLocalBuild = true;
38 # dump tar of *current directory* at given revision
39 git -C ${srcStr} archive --format=tar ${gitHash} \