summaryrefslogtreecommitdiff
path: root/ymir.nix
diff options
context:
space:
mode:
Diffstat (limited to 'ymir.nix')
-rw-r--r--ymir.nix23
1 files changed, 22 insertions, 1 deletions
diff --git a/ymir.nix b/ymir.nix
index 2d6fac63..b1adc5d4 100644
--- a/ymir.nix
+++ b/ymir.nix
@@ -891,7 +891,28 @@ in rec {
891 [directory-sync] 891 [directory-sync]
892 directory=/var/lib/infinoted/dirsync 892 directory=/var/lib/infinoted/dirsync
893 interval=5 893 interval=5
894 hook=/var/lib/infinoted/git-sync.sh 894 hook=${pkgs.writeScript "git-sync.sh" ''
895 #!${pkgs.zsh}/bin/zsh
896
897 repository=$(git -C ${2:h} rev-parse --show-toplevel)
898 [[ $? -eq 0 ]] || exit 0
899
900 git() {
901 $(whence -cp git) -C ${repository} ${@}
902 }
903
904 typeset -a changeSet
905 changeSet=()
906 git diff -z --name-only | \
907 while IFS= read -r -d $'\0' change; do changeSet=(${changeSet} ${change}); done
908
909 [[ ${changeSet[(i)$(realpath ${2} --relative-to=${repository})]} -le ${#changeSet} ]] || exit 0
910
911 commitMessage=$(printf "%s modified via infinoted" $(realpath ${2} --relative-to=${repository}))
912 git add ${2}
913 git commit -m ${commitMessage} --no-edit ${2}
914 git push
915 ''}
895 ''; 916 '';
896 }; 917 };
897 918