1{
2 runCommand,
3 haskellPackages,
4 lib,
5 all-cabal-hashes,
6}:
7let
8 # Checks if the version looks like a Haskell PVP version which is the format
9 # Hackage enforces. This will return false if the version strings is empty or
10 # we've overridden the package to ship an unstable version of the package
11 # (sadly there's no good way to show something useful on hackage in this case).
12 isPvpVersion = v: builtins.match "([0-9]+)(\\.[0-9]+)*" v != null;
13
14 pkgLine =
15 name: pkg:
16 let
17 version = pkg.version or "";
18 in
19 lib.optionalString (isPvpVersion version && (pkg.meta.hydraPlatforms or null) != lib.platforms.none)
20 ''"${name}","${version}","http://hydra.nixos.org/job/nixpkgs/trunk/haskellPackages.${name}.x86_64-linux"'';
21 all-haskellPackages = builtins.toFile "all-haskellPackages" (
22 lib.concatStringsSep "\n" (lib.filter (x: x != "") (lib.mapAttrsToList pkgLine haskellPackages))
23 );
24in
25runCommand "hackage-package-list" { }
26 # This command will make a join between all packages on hackage and haskellPackages.*.
27 # It ignores packages marked as broken (according to hydraPlatforms)
28 # It creates a valid csv file which can be uploaded to hackage.haskell.org.
29 # The call is wrapped in echo $(...) to trim trailing newline, which hackage requires.
30 ''
31 mkdir -p $out/bin
32 echo -n "$(tar -t -f ${all-cabal-hashes} | sed 's![^/]*/\([^/]*\)/.*!"\1"!' | sort -u | join -t , - ${all-haskellPackages})" > $out/nixos-hackage-packages.csv
33 ''