Skip to content

Commit 1251129

Browse files
authored
Merge pull request #56 from input-output-hk/rvl/buildkite-update-scripts
Add Buildkite pipeline for updating hackage.nix and stackage.nix
2 parents 0de60e8 + a9f0250 commit 1251129

File tree

5 files changed

+58
-21
lines changed

5 files changed

+58
-21
lines changed

.buildkite/updates.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -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

56
with 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 = "[email protected]: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="[email protected]"
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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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

33
import ./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 [email protected]: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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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

33
import ./update-external.nix args {
44
name = "stackage";

0 commit comments

Comments
 (0)