@@ -1,26 +1,46 @@
1+{ stdenv, writeScript, glibc, coreutils, git, openssh
1−{ stdenv, writeScript, glibc, coreutils, git, nix-tools, cabal-install, nix-prefetch-git }:
2+, nix-tools, cabal-install, nix-prefetch-git }:
3{ name, script }:
4{ name, script }:
5with stdenv.lib;
6with stdenv.lib;
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";
7−writeScript "update-${name}-nix.sh" ''
13+ writeScript "update-${name}-nix.sh" ''
8− #!${stdenv.shell}
14+ #!${stdenv.shell}
10− set -euo pipefail
16+ set -euo pipefail
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 ]}"
14− ${script}
20+ ${script}
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"
16− git add .
27+ git add .
17− git commit --allow-empty -m "Automatic update for $(date)"
28+ git commit --allow-empty --message "Automatic update for $(date)"
19− rev=$(git rev-parse HEAD)
30+ rev=$(git rev-parse HEAD)
21− git push
32+ if [ -e ${sshKey} ]
34+ echo "Authenticating using SSH with ${sshKey}"
35+ export GIT_SSH_COMMAND="ssh -i ${sshKey} -F /dev/null"
37+ echo "There is no SSH key at ${sshKey}"
38+ echo "Git push may not work."
23− cd ..
41+ git push ${repoSSH}
25− nix-prefetch-git https://github.com/input-output-hk/${name}.nix.git --rev "$rev" | tee ${name}-src.json
45+ nix-prefetch-git ${repoHTTPS} --rev "$rev" | tee ${name}-src.json