nixpkgs/pkgs/development/haskell-modules/package-list.nix
Silvan Mosberger 4f0dadbf38 treewide: format all inactive Nix files
After final improvements to the official formatter implementation,
this commit now performs the first treewide reformat of Nix files using it.
This is part of the implementation of RFC 166.

Only "inactive" files are reformatted, meaning only files that
aren't being touched by any PR with activity in the past 2 months.
This is to avoid conflicts for PRs that might soon be merged.
Later we can do a full treewide reformat to get the rest,
which should not cause as many conflicts.

A CI check has already been running for some time to ensure that new and
already-formatted files are formatted, so the files being reformatted here
should also stay formatted.

This commit was automatically created and can be verified using

    nix-build a08b3a4d19.tar.gz \
      --argstr baseRev b32a094368
    result/bin/apply-formatting $NIXPKGS_PATH
2024-12-10 20:26:33 +01:00

34 lines
1.5 KiB
Nix

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