on iko/ghcjs-patch-master help sign in
Merge pull request #101 from input-output-hk/rvl/update-pins
77954f3Rodney Lorrimar
.buildkite/updates.yml+13
@@ -4,6 +4,8 @@ steps:
4 - nix-build -I nixpkgs=channel:nixos-18.09 -A maintainer-scripts.update-hackage -o update-hackage.sh
4 - nix-build -I nixpkgs=channel:nixos-18.09 -A maintainer-scripts.update-hackage -o update-hackage.sh
5 - echo "+++ Updating hackage.nix"
5 - echo "+++ Updating hackage.nix"
6 - ./update-hackage.sh
6 - ./update-hackage.sh
7+ artifact_paths:
8+ - "hackage-src.json"
7 agents:
9 agents:
8 system: x86_64-linux
10 system: x86_64-linux
9
11
@@ -12,5 +14,16 @@ steps:
12 - nix-build -I nixpkgs=channel:nixos-18.09 -A maintainer-scripts.update-stackage -o update-stackage.sh
14 - nix-build -I nixpkgs=channel:nixos-18.09 -A maintainer-scripts.update-stackage -o update-stackage.sh
13 - echo "+++ Updating stackage.nix"
15 - echo "+++ Updating stackage.nix"
14 - ./update-stackage.sh
16 - ./update-stackage.sh
17+ artifact_paths:
18+ - "stackage-src.json"
15 agents:
19 agents:
16 system: x86_64-linux
20 system: x86_64-linux
21+
22+ - wait: ~
23+ continue_on_failure: true
24+
25+ - label: 'Update pins'
26+ command:
27+ - 'buildkite-agent artifact download "*.json" .'
28+ - nix-build -A maintainer-scripts.update-pins -o update-pins.sh
29+ - ./update-pins.sh
default.nix+1
@@ -116,6 +116,7 @@ let
116 maintainer-scripts = {
116 maintainer-scripts = {
117 update-hackage = self.callPackage ./scripts/update-hackage.nix {};
117 update-hackage = self.callPackage ./scripts/update-hackage.nix {};
118 update-stackage = self.callPackage ./scripts/update-stackage.nix {};
118 update-stackage = self.callPackage ./scripts/update-stackage.nix {};
119+ update-pins = self.callPackage ./scripts/update-pins.nix {};
119 };
120 };
120 });
121 });
121
122
scripts/git.envnew file+25
@@ -0,0 +1,25 @@
1+# Env variables and functions for updating git repos
2+
3+export GIT_COMMITTER_NAME="IOHK"
4+export GIT_COMMITTER_EMAIL="devops+nix-tools@iohk.io"
5+export GIT_AUTHOR_NAME="$GIT_COMMITTER_NAME"
6+export GIT_AUTHOR_EMAIL="$GIT_COMMITTER_EMAIL"
7+
8+use_ssh_key() {
9+ sshkey=$1
10+ if [ -e $sshkey ]
11+ then
12+ echo "Authenticating using SSH with $sshkey"
13+ export GIT_SSH_COMMAND="ssh -i $sshkey -F /dev/null"
14+ else
15+ echo "There is no SSH key at $sshkey"
16+ echo "Git push may not work."
17+ fi
18+}
19+
20+check_staged() {
21+ if git diff-index --cached --quiet HEAD --; then
22+ echo "No changes to commit, exiting."
23+ exit 0
24+ fi
25+}
scripts/update-external.nix+7−15
@@ -19,27 +19,19 @@ in
19
19
20 ${script}
20 ${script}
21
21
22+ source ${./git.env}
23+
22 echo "Committing changes..."
24 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 .
25 git add .
26+ check_staged
28− git commit --allow-empty --message "Automatic update for $(date)"
27+ git commit --message "Automatic update for $(date)"
29−
30− rev=$(git rev-parse HEAD)
31
28
32− if [ -e ${sshKey} ]
29+ use_ssh_key ${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
40
30
41 git push ${repoSSH}
31 git push ${repoSSH}
42
32
33+ rev=$(git rev-parse HEAD)
34+
43 cd ..
35 cd ..
44
36
45 nix-prefetch-git ${repoHTTPS} --rev "$rev" | tee ${name}-src.json
37 nix-prefetch-git ${repoHTTPS} --rev "$rev" | tee ${name}-src.json
scripts/update-pins.nixnew file+26
@@ -0,0 +1,26 @@
1+{ stdenv, writeScript, coreutils, glibc, git, openssh }@args:
2+
3+with stdenv.lib;
4+
5+let
6+ repo = "git@github.com:input-output-hk/haskell.nix.git";
7+ sshKey = "/run/keys/buildkite-haskell-nix-ssh-private";
8+in
9+ writeScript "update-pins.sh" ''
10+ #!${stdenv.shell}
11+
12+ set -euo pipefail
13+
14+ export PATH="${makeBinPath [ coreutils glibc git openssh ]}"
15+
16+ source ${./git.env}
17+
18+ git add *.json
19+ check_staged
20+ echo "Committing changes..."
21+ git commit --message "Update Hackage and Stackage"
22+
23+ use_ssh_key ${sshKey}
24+
25+ git push ${repo}
26+ ''