@@ -1,26 +1,46 @@
1−{ stdenv, writeScript, glibc, coreutils, git, nix-tools, cabal-install, nix-prefetch-git }:
1+{ stdenv, writeScript, glibc, coreutils, git, openssh
2+, nix-tools, cabal-install, nix-prefetch-git }:
23
34{ name, script }:
45
56with stdenv.lib;
67
7−writeScript "update-${name}-nix.sh" ''
8− #!${stdenv.shell}
8+let
9+ repoHTTPS = "https://github.com/input-output-hk/${name}.nix.git";
10+ repoSSH = "git@github.com:input-output-hk/${name}.nix.git";
11+ sshKey = "/run/keys/buildkite-${name}-ssh-private";
12+in
13+ writeScript "update-${name}-nix.sh" ''
14+ #!${stdenv.shell}
915
10− set -euo pipefail
16+ set -euo pipefail
1117
12− export PATH="${makeBinPath [ coreutils glibc git nix-tools cabal-install nix-prefetch-git ]}"
18+ export PATH="${makeBinPath [ coreutils glibc git openssh nix-tools cabal-install nix-prefetch-git ]}"
1319
14− ${script}
20+ ${script}
1521
16− git add .
17− git commit --allow-empty -m "Automatic update for $(date)"
22+ echo "Committing changes..."
23+ export GIT_COMMITTER_NAME="IOHK"
24+ export GIT_COMMITTER_EMAIL="devops+nix-tools@iohk.io"
25+ export GIT_AUTHOR_NAME="$GIT_COMMITTER_NAME"
26+ export GIT_AUTHOR_EMAIL="$GIT_COMMITTER_EMAIL"
27+ git add .
28+ git commit --allow-empty --message "Automatic update for $(date)"
1829
19− rev=$(git rev-parse HEAD)
30+ rev=$(git rev-parse HEAD)
2031
21− git push
32+ if [ -e ${sshKey} ]
33+ then
34+ echo "Authenticating using SSH with ${sshKey}"
35+ export GIT_SSH_COMMAND="ssh -i ${sshKey} -F /dev/null"
36+ else
37+ echo "There is no SSH key at ${sshKey}"
38+ echo "Git push may not work."
39+ fi
2240
23− cd ..
41+ git push ${repoSSH}
2442
25− nix-prefetch-git https://github.com/input-output-hk/${name}.nix.git --rev "$rev" | tee ${name}-src.json
26−''
43+ cd ..
44+
45+ nix-prefetch-git ${repoHTTPS} --rev "$rev" | tee ${name}-src.json
46+ ''