Files
haskell.nix/scripts/find-pkg-config-all.nix
Hamish Mackenzie 6c7f9d0042 Use cabal 3.8 (#1641)
A bug was fixed in cabal 3.8 (https://github.com/haskell/cabal/issues/6771) that haskell.nix relied on for `pkg-config` in support.  To work around this we added a dummy `pkg-config` that `cabal configure` now uses when haskell.nix runs it `cabal configure` internally.  That returns version information for all the `pkg-config` packages in `lib/pkgconfig-nixpkgs-map.nix`.  This mapping has also been expanded based on the results of searching nixpkgs for `*.pc` files.

This update also includes workarounds for:

https://github.com/haskell/cabal/issues/8352
https://github.com/haskell/cabal/issues/8370
https://github.com/haskell/cabal/issues/8455
2022-09-13 12:00:04 +12:00

48 lines
2.0 KiB
Nix

# Script used to help make the lists of pkc-config packages in lib/pkgconf-nipkgs-map.nix.
# It searches for .pc files in every package it can find.
#
# This really is not a great way to do this and if we have to run it again
# it might be worht making some improvements or finding something else to do it.
#
# I had hoped the `-j0` would stop it from building anything (but it does not) and
# setting `--builders ""` did not seem to help either. Instead I ran multiple copies
# in multiple terminals like this:
#
# $(nix-build scripts/find-pkg-config-all.nix --argstr startAt "v") > v.txt
#
# Hitting ctrl+c if one of them started building anything massive (causes
# nix-build to fail and the script moves on to the next one).
#
# I monitored the progress with:
# tail -f v.txt
# (in even more teminals)
#
# If one of them caught up to the next one I killed it.
#
{ startAt ? "" }:
let
pkgs = import <nixpkgs> { config = { allowUnfree = true; allowAliases = false; }; };
in
pkgs.writeScript "find-pkg-config-all" ''
${ pkgs.lib.concatStrings (map (name: pkgs.lib.optionalString (name >= startAt && name != "AAAAAASomeThingsFailToEvaluate" && null == builtins.match ".*[^0-9A-Za-z_-].*" name) ''
OUT_DIR=$(mktemp -d)
if nix-build -E 'let pkgs = import <nixpkgs> {}; in pkgs.lib.getDev pkgs."${name}"' -j0 --out-link $OUT_DIR/result >&2; then
find $OUT_DIR/*/ -name '*.pc' | sed 's|^.*/\([^/]*\)\.pc| "\1" = [ "${name}" ];|' | sort -u
rm $OUT_DIR/result*
fi
''
) (__attrNames pkgs))
}
echo '# pkgs.xorg'
${ pkgs.lib.concatStrings (map (name: pkgs.lib.optionalString (null == builtins.match ".*[^0-9A-Za-z_-].*" name) ''
OUT_DIR=$(mktemp -d)
if nix-build -E 'let pkgs = import <nixpkgs> {}; in pkgs.lib.getDev pkgs.xorg."${name}"' -j0 --out-link $OUT_DIR/result >&2; then
find $OUT_DIR/*/ -name '*.pc' | sed 's|^.*/\([^/]*\)\.pc| "\1" = [ "${name}" ];|' | sort -u
rm $OUT_DIR/result*
fi
''
) (__attrNames pkgs.xorg))
}
''