Skip to content

Commit 57c0be6

Browse files
committed
Add a script for updating the Hackage rev
1 parent d82a013 commit 57c0be6

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

default.nix

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,11 @@ let
8484
# Snapshots of Hackage and Stackage, converted to Nix expressions,
8585
# regularly updated.
8686
inherit hackage stackage;
87+
88+
# Scripts for keeping Hackage and Stackage up to date.
89+
maintainer-scripts = {
90+
update-hackage = self.callPackage ./scripts/update-hackage.nix {};
91+
};
8792
});
8893

8994
in

scripts/update-hackage.nix

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{ stdenv, writeScriptBin, coreutils, git, nix-tools, cabal-install, nix-prefetch-git }:
2+
3+
with stdenv.lib;
4+
5+
writeScriptBin "update-hackage-nix" ''
6+
#!${stdenv.shell}
7+
8+
set -euo pipefail
9+
10+
export PATH="${makeBinPath [ coreutils git nix-tools cabal-install nix-prefetch-git ]}"
11+
12+
# Make sure the hackage index is recent.
13+
cabal new-update
14+
15+
if [ -d hackage.nix ]; then
16+
cd hackage.nix
17+
git pull --ff-only
18+
cd ..
19+
else
20+
git clone [email protected]:input-output-hk/hackage.nix.git
21+
fi
22+
23+
hackage-to-nix hackage.nix
24+
25+
cd hackage.nix
26+
git add .
27+
git commit --allow-empty -m "Automatic update for $(date)"
28+
29+
rev=$(git rev-parse HEAD)
30+
31+
git push
32+
33+
cd ..
34+
35+
nix-prefetch-git https://github.com/input-output-hk/hackage.nix.git --rev "$rev" | tee hackage-src.json
36+
''

0 commit comments

Comments
 (0)