forked from typeable/nixpkgs-stackage
-
Notifications
You must be signed in to change notification settings - Fork 0
/
update.nix
61 lines (55 loc) · 1.6 KB
/
update.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
{ nixpkgs ? import ./nixpkgs.nix {} }:
with nixpkgs; let
lib = callPackage ./stackage2nix/lib.nix {};
in stdenv.mkDerivation rec {
name = "nixpkgs-typeable-update-script";
buildCommand = ''
echo "Update failed"
exit 1
'';
# generate missing stackage/lts-xx packages
updateLtsSh = ''
pushd stackage
# iterate through stackage-lts configs
for conf in $(find ${lib.stackage-lts} -type f -name '*.yaml' | sort --version-sort); do
resolver=$(basename --suffix='.yaml' $conf)
if [ ! -d $resolver ]; then
mkdir $resolver
pushd $resolver
# generate stackage release
(set -x; time ${stackage2nixWrapper}/bin/stackage2nix --resolver $resolver)
# update supported releases
popd
echo $resolver >> ../supported-stackage-releases.txt
fi
done
popd # stackage
sort --version-sort -o supported-stackage-releases.txt supported-stackage-releases.txt
'';
# update stackage/default.nix
updateStackageSh = ''
pushd stackage
echo '{ callPackage }:' > default.nix
echo '{' >> default.nix
for dir in $(find . -mindepth 1 -type d | sort --version-sort); do
resolver=$(basename $dir)
echo " ''${resolver//.} = callPackage $dir {};" >> default.nix
done
echo '}' >> default.nix
popd
'';
shellHook = ''
echo 'Start ${name}'
echo 'Start update-lts-sh'
${updateLtsSh}
echo 'Start update-stackage-sh'
${updateStackageSh}
EXIT_CODE=$?
if [ "$EXIT_CODE" != "0" ]; then
echo 'ERROR: update-script'
exit $EXIT_CODE
fi
echo 'OK: ${name}'
exit 0
'';
}