on iko/ghcjs-patch-master help sign in
Add Buildkite pipeline for updating hackage.nix and stackage.nix
dd51446Rodney Lorrimar
.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
scripts/update-external.nix+33−13
@@ -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 }:
2
3
3{ name, script }:
4{ name, script }:
4
5
5with stdenv.lib;
6with stdenv.lib;
6
7
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
7−writeScript "update-${name}-nix.sh" ''
13+ writeScript "update-${name}-nix.sh" ''
8− #!${stdenv.shell}
14+ #!${stdenv.shell}
9
15
10− set -euo pipefail
16+ set -euo pipefail
11
17
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 ]}"
13
19
14− ${script}
20+ ${script}
15
21
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)"
18
29
19− rev=$(git rev-parse HEAD)
30+ rev=$(git rev-parse HEAD)
20
31
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
22
40
23− cd ..
41+ git push ${repoSSH}
24
42
43+ cd ..
44+
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
26−''
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:
2
2
3import ./update-external.nix args {
3import ./update-external.nix args {
4 name = "hackage";
4 name = "hackage";
5 script = ''
5 script = ''
6− # Make sure the hackage index is recent.
7− cabal new-update
8−
9 # Clone or update the Hackage Nix expressions repo.
6 # Clone or update the Hackage Nix expressions repo.
10 if [ -d hackage.nix ]; then
7 if [ -d hackage.nix ]; then
11 cd hackage.nix
8 cd hackage.nix
@@ -15,6 +12,10 @@ import ./update-external.nix args {
15 git clone git@github.com:input-output-hk/hackage.nix.git
12 git clone git@github.com:input-output-hk/hackage.nix.git
16 fi
13 fi
17
14
15+ # Make sure the hackage index is recent.
16+ echo "Updating local hackage index..."
17+ cabal update
18+
18 echo "Running hackage-to-nix..."
19 echo "Running hackage-to-nix..."
19
20
20 hackage-to-nix hackage.nix
21 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:
2
2
3import ./update-external.nix args {
3import ./update-external.nix args {
4 name = "stackage";
4 name = "stackage";