mirror of
https://github.com/ilyakooo0/haskell.nix.git
synced 2024-09-11 06:55:40 +03:00
Add a script for updating the Stackage rev
This commit is contained in:
parent
12076ea8f0
commit
a6d28bacb2
@ -90,6 +90,7 @@ let
|
||||
# Scripts for keeping Hackage and Stackage up to date.
|
||||
maintainer-scripts = {
|
||||
update-hackage = self.callPackage ./scripts/update-hackage.nix {};
|
||||
update-stackage = self.callPackage ./scripts/update-stackage.nix {};
|
||||
};
|
||||
});
|
||||
|
||||
|
26
scripts/update-external.nix
Normal file
26
scripts/update-external.nix
Normal file
@ -0,0 +1,26 @@
|
||||
{ stdenv, writeScript, glibc, coreutils, git, nix-tools, cabal-install, nix-prefetch-git }:
|
||||
|
||||
{ name, script }:
|
||||
|
||||
with stdenv.lib;
|
||||
|
||||
writeScript "update-${name}-nix.sh" ''
|
||||
#!${stdenv.shell}
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
export PATH="${makeBinPath [ coreutils glibc git nix-tools cabal-install nix-prefetch-git ]}"
|
||||
|
||||
${script}
|
||||
|
||||
git add .
|
||||
git commit --allow-empty -m "Automatic update for $(date)"
|
||||
|
||||
rev=$(git rev-parse HEAD)
|
||||
|
||||
git push
|
||||
|
||||
cd ..
|
||||
|
||||
nix-prefetch-git https://github.com/input-output-hk/${name}.nix.git --rev "$rev" | tee ${name}-src.json
|
||||
''
|
@ -1,36 +1,24 @@
|
||||
{ stdenv, writeScriptBin, coreutils, git, nix-tools, cabal-install, nix-prefetch-git }:
|
||||
{ stdenv, writeScript, coreutils, glibc, git, nix-tools, cabal-install, nix-prefetch-git }@args:
|
||||
|
||||
with stdenv.lib;
|
||||
import ./update-external.nix args {
|
||||
name = "hackage";
|
||||
script = ''
|
||||
# Make sure the hackage index is recent.
|
||||
cabal new-update
|
||||
|
||||
writeScriptBin "update-hackage-nix" ''
|
||||
#!${stdenv.shell}
|
||||
# Clone or update the Hackage Nix expressions repo.
|
||||
if [ -d hackage.nix ]; then
|
||||
cd hackage.nix
|
||||
git pull --ff-only
|
||||
cd ..
|
||||
else
|
||||
git clone git@github.com:input-output-hk/hackage.nix.git
|
||||
fi
|
||||
|
||||
set -euo pipefail
|
||||
echo "Running hackage-to-nix..."
|
||||
|
||||
export PATH="${makeBinPath [ coreutils git nix-tools cabal-install nix-prefetch-git ]}"
|
||||
hackage-to-nix hackage.nix
|
||||
|
||||
# Make sure the hackage index is recent.
|
||||
cabal new-update
|
||||
|
||||
if [ -d hackage.nix ]; then
|
||||
cd hackage.nix
|
||||
git pull --ff-only
|
||||
cd ..
|
||||
else
|
||||
git clone git@github.com:input-output-hk/hackage.nix.git
|
||||
fi
|
||||
|
||||
hackage-to-nix hackage.nix
|
||||
|
||||
cd hackage.nix
|
||||
git add .
|
||||
git commit --allow-empty -m "Automatic update for $(date)"
|
||||
|
||||
rev=$(git rev-parse HEAD)
|
||||
|
||||
git push
|
||||
|
||||
cd ..
|
||||
|
||||
nix-prefetch-git https://github.com/input-output-hk/hackage.nix.git --rev "$rev" | tee hackage-src.json
|
||||
''
|
||||
'';
|
||||
}
|
||||
|
44
scripts/update-stackage.nix
Normal file
44
scripts/update-stackage.nix
Normal file
@ -0,0 +1,44 @@
|
||||
{ stdenv, writeScript, coreutils, glibc, git, nix-tools, cabal-install, nix-prefetch-git }@args:
|
||||
|
||||
import ./update-external.nix args {
|
||||
name = "stackage";
|
||||
script = ''
|
||||
# Clone or update the main Stackage Nix expressions repo.
|
||||
# The upstream LTS and Nightly package sets are in submodules, which
|
||||
# should also be updated.
|
||||
if [ -d stackage.nix ]; then
|
||||
cd stackage.nix
|
||||
git pull --ff-only
|
||||
git submodule update --init
|
||||
git submodule foreach git pull origin master
|
||||
else
|
||||
git clone git@github.com:input-output-hk/stackage.nix.git
|
||||
cd stackage.nix
|
||||
git submodule update --init
|
||||
fi
|
||||
|
||||
echo "Running lts-to-nix for all snapshots..."
|
||||
|
||||
# update them all in parallel...
|
||||
N=$(getconf _NPROCESSORS_ONLN)
|
||||
for lts in {lts-haskell,stackage-nightly}/*.yaml
|
||||
do
|
||||
lts-to-nix $lts > $(basename ''${lts%.yaml}.nix) &
|
||||
while [[ $(jobs -r -p | wc -l) -gt $N ]]; do
|
||||
# can't use `wait -n` on older bash versions.
|
||||
# e.g. what ships with macOS High Sierra
|
||||
sleep 1;
|
||||
done
|
||||
done
|
||||
wait
|
||||
|
||||
# update nightlies
|
||||
echo "{" > nightlies.nix;
|
||||
for a in nightly-*.nix; do echo " \"''${a%%.nix}\" = import ./$a;" >> nightlies.nix; done;
|
||||
echo "}" >> nightlies.nix
|
||||
# update lts
|
||||
echo "{" > ltss.nix;
|
||||
for a in lts-*.nix; do echo " \"''${a%%.nix}\" = import ./$a;" >> ltss.nix; done;
|
||||
echo "}" >> ltss.nix
|
||||
'';
|
||||
}
|
Loading…
Reference in New Issue
Block a user