on aec89cc help sign in
haskell.nix/scripts/update-stackage.nix
44 lines 1.4 kB history raw
1{ stdenv, writeScript, coreutils, glibc, git, nix-tools, cabal-install, nix-prefetch-git }@args:
3import ./update-external.nix args {
4 name = "stackage";
5 script = ''
6 # Clone or update the main Stackage Nix expressions repo.
7 # The upstream LTS and Nightly package sets are in submodules, which
8 # should also be updated.
9 if [ -d stackage.nix ]; then
10 cd stackage.nix
11 git pull --ff-only
12 git submodule update --init
13 git submodule foreach git pull origin master
14 else
15 git clone git@github.com:input-output-hk/stackage.nix.git
16 cd stackage.nix
17 git submodule update --init
18 fi
20 echo "Running lts-to-nix for all snapshots..."
22 # update them all in parallel...
23 N=$(getconf _NPROCESSORS_ONLN)
24 for lts in {lts-haskell,stackage-nightly}/*.yaml
25 do
26 lts-to-nix $lts > $(basename ''${lts%.yaml}.nix) &
27 while [[ $(jobs -r -p | wc -l) -gt $N ]]; do
28 # can't use `wait -n` on older bash versions.
29 # e.g. what ships with macOS High Sierra
30 sleep 1;
31 done
32 done
33 wait
35 # update nightlies
36 echo "{" > nightlies.nix;
37 for a in nightly-*.nix; do echo " \"''${a%%.nix}\" = import ./$a;" >> nightlies.nix; done;
38 echo "}" >> nightlies.nix
39 # update lts
40 echo "{" > ltss.nix;
41 for a in lts-*.nix; do echo " \"''${a%%.nix}\" = import ./$a;" >> ltss.nix; done;
42 echo "}" >> ltss.nix
43 '';