Skip to content

Commit ec75652

Browse files
committed
Add Buildkite pipeline for updating hackage.nix and stackage.nix
1 parent 0de60e8 commit ec75652

File tree

3 files changed

+51
-15
lines changed

3 files changed

+51
-15
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=https://github.com/NixOS/nixpkgs-channels/archive/nixos-18.09.tar.gz -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

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,42 @@
44

55
with stdenv.lib;
66

7-
writeScript "update-${name}-nix.sh" ''
8-
#!${stdenv.shell}
7+
let
8+
repoHTTPS = "https://github.com/input-output-hk/${name}.nix.git";
9+
repoSSH = "[email protected]:input-output-hk/${name}.nix.git";
10+
sshKey = "/run/keys/buildkite-${name}-ssh-private";
11+
in
12+
writeScript "update-${name}-nix.sh" ''
13+
#!${stdenv.shell}
914
10-
set -euo pipefail
15+
set -euo pipefail
1116
12-
export PATH="${makeBinPath [ coreutils glibc git nix-tools cabal-install nix-prefetch-git ]}"
17+
export PATH="${makeBinPath [ coreutils glibc git nix-tools cabal-install nix-prefetch-git ]}"
1318
14-
${script}
19+
${script}
1520
16-
git add .
17-
git commit --allow-empty -m "Automatic update for $(date)"
21+
echo "Committing changes..."
22+
export GIT_COMMITTER_NAME="IOHK"
23+
export GIT_COMMITTER_EMAIL="[email protected]"
24+
export GIT_AUTHOR_NAME="$GIT_COMMITTER_NAME"
25+
export GIT_AUTHOR_EMAIL="$GIT_COMMITTER_EMAIL"
26+
git add .
27+
git commit --allow-empty --message "Automatic update for $(date)"
1828
19-
rev=$(git rev-parse HEAD)
29+
rev=$(git rev-parse HEAD)
2030
21-
git push
31+
if [ -e ${sshKey} ]
32+
then
33+
echo "Authenticating using SSH with ${sshKey}"
34+
export GIT_SSH_COMMAND="ssh -i ${sshKey} -F /dev/null"
35+
else
36+
echo "There is no SSH key at ${sshKey}"
37+
echo "Git push may not work."
38+
fi
2239
23-
cd ..
40+
git push ${repoSSH}
2441
25-
nix-prefetch-git https://github.com/input-output-hk/${name}.nix.git --rev "$rev" | tee ${name}-src.json
26-
''
42+
cd ..
43+
44+
nix-prefetch-git ${repoHTTPS} --rev "$rev" | tee ${name}-src.json
45+
''

scripts/update-hackage.nix

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

0 commit comments

Comments
 (0)