on iko/ghcjs-patch-master help sign in
Merge pull request #56 from input-output-hk/rvl/buildkite-update-scripts

Add Buildkite pipeline for updating hackage.nix and stackage.nix

commit1251129aa428972843aec379e5511d47c7c595a6 authorRodney Lorrimar <dev@rodney.id.au> dateWed 20 Mar 2019, 12:44 (8 years ago) parent0de60e8a9f0250
5 files changed+58−21
.buildkite/updates.yml+16 nix-tools/nix-tools-src.json+3−3 scripts/update-external.nix+33−13 scripts/update-hackage.nix+5−4 scripts/update-stackage.nix+1−1
.buildkite/updates.ymlnew file+16
@@ -0,0 +1,16 @@
1+steps:
2+ - label: 'Update hackage.nix'
3+ command:
4+ - nix-build -I nixpkgs=channel:nixos-18.09 -A maintainer-scripts.update-hackage -o update-hackage.sh
5+ - echo "+++ Updating hackage.nix"
6+ - ./update-hackage.sh
7+ agents:
8+ system: x86_64-linux
9+
10+ - label: 'Update stackage.nix'
11+ command:
12+ - nix-build -I nixpkgs=channel:nixos-18.09 -A maintainer-scripts.update-stackage -o update-stackage.sh
13+ - echo "+++ Updating stackage.nix"
14+ - ./update-stackage.sh
15+ agents:
16+ system: x86_64-linux
nix-tools/nix-tools-src.json+3−3
@@ -1,7 +1,7 @@
11{
22 "url": "https://github.com/input-output-hk/nix-tools",
3− "rev": "232e4fde7f942ef234b649144016d5da0f7e2745",
4− "date": "2019-02-11T12:59:38+08:00",
5− "sha256": "1nrm9vcq443isk09z1fmlp8zxnw9p3cx95zbda29s5mky17ky2c0",
3+ "rev": "38bf6fd0adef4d22fe06def521f5d793c081f6ed",
4+ "date": "2019-03-20T12:40:31+10:00",
5+ "sha256": "0y8xap5cvc9rssjjvlgv6lyi8ixpxnq675r3gkz2ix7hrsgk8989",
66 "fetchSubmodules": false
77}
scripts/update-external.nix+33−13
@@ -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+ ''
scripts/update-hackage.nix+5−4
@@ -1,11 +1,8 @@
1−{ stdenv, writeScript, coreutils, glibc, git, nix-tools, cabal-install, nix-prefetch-git }@args:
1+{ stdenv, writeScript, coreutils, glibc, git, openssh, nix-tools, cabal-install, nix-prefetch-git }@args:
22
33import ./update-external.nix args {
44 name = "hackage";
55 script = ''
6− # Make sure the hackage index is recent.
7− cabal new-update
8−
96 # Clone or update the Hackage Nix expressions repo.
107 if [ -d hackage.nix ]; then
118 cd hackage.nix
@@ -15,6 +12,10 @@ import ./update-external.nix args {
1512 git clone git@github.com:input-output-hk/hackage.nix.git
1613 fi
1714
15+ # Make sure the hackage index is recent.
16+ echo "Updating local hackage index..."
17+ cabal update
18+
1819 echo "Running hackage-to-nix..."
1920
2021 hackage-to-nix hackage.nix
scripts/update-stackage.nix+1−1
@@ -1,4 +1,4 @@
1−{ stdenv, writeScript, coreutils, glibc, git, nix-tools, cabal-install, nix-prefetch-git }@args:
1+{ stdenv, writeScript, coreutils, glibc, git, openssh, nix-tools, cabal-install, nix-prefetch-git }@args:
22
33import ./update-external.nix args {
44 name = "stackage";