Skip to content

Commit 77954f3

Browse files
authored
Merge pull request #101 from input-output-hk/rvl/update-pins
Nightly: Also update hackage-src.json and stackage-src.json
2 parents fedbc8e + b12e3b3 commit 77954f3

File tree

5 files changed

+72
-15
lines changed

5 files changed

+72
-15
lines changed

.buildkite/updates.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ steps:
44
- nix-build -I nixpkgs=channel:nixos-18.09 -A maintainer-scripts.update-hackage -o update-hackage.sh
55
- echo "+++ Updating hackage.nix"
66
- ./update-hackage.sh
7+
artifact_paths:
8+
- "hackage-src.json"
79
agents:
810
system: x86_64-linux
911

@@ -12,5 +14,16 @@ steps:
1214
- nix-build -I nixpkgs=channel:nixos-18.09 -A maintainer-scripts.update-stackage -o update-stackage.sh
1315
- echo "+++ Updating stackage.nix"
1416
- ./update-stackage.sh
17+
artifact_paths:
18+
- "stackage-src.json"
1519
agents:
1620
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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ let
116116
maintainer-scripts = {
117117
update-hackage = self.callPackage ./scripts/update-hackage.nix {};
118118
update-stackage = self.callPackage ./scripts/update-stackage.nix {};
119+
update-pins = self.callPackage ./scripts/update-pins.nix {};
119120
};
120121
});
121122

scripts/git.env

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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="[email protected]"
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

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,27 +19,19 @@ in
1919
2020
${script}
2121
22+
source ${./git.env}
23+
2224
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"
2725
git add .
28-
git commit --allow-empty --message "Automatic update for $(date)"
29-
30-
rev=$(git rev-parse HEAD)
26+
check_staged
27+
git commit --message "Automatic update for $(date)"
3128
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
29+
use_ssh_key ${sshKey}
4030
4131
git push ${repoSSH}
4232
33+
rev=$(git rev-parse HEAD)
34+
4335
cd ..
4436
4537
nix-prefetch-git ${repoHTTPS} --rev "$rev" | tee ${name}-src.json

scripts/update-pins.nix

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{ stdenv, writeScript, coreutils, glibc, git, openssh }@args:
2+
3+
with stdenv.lib;
4+
5+
let
6+
repo = "[email protected]: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+
''

0 commit comments

Comments
 (0)