Haskell utils: add an attrset mapping GHC version to hidden packages

This commit is contained in:
Brian Leung 2022-10-13 02:12:04 -07:00
parent 539a5cad94
commit f1a53653c3
No known key found for this signature in database
GPG Key ID: 2D86D6A94C8BB3B1
3 changed files with 56 additions and 0 deletions

View File

@ -124,6 +124,22 @@
"type": "github"
}
},
"ghc-utils": {
"flake": false,
"locked": {
"lastModified": 1662774800,
"narHash": "sha256-1Rd2eohGUw/s1tfvkepeYpg8kCEXiIot0RijapUjAkE=",
"ref": "refs/heads/master",
"rev": "bb3a2d3dc52ff0253fb9c2812bd7aa2da03e0fea",
"revCount": 1072,
"type": "git",
"url": "https://gitlab.haskell.org/bgamari/ghc-utils"
},
"original": {
"type": "git",
"url": "https://gitlab.haskell.org/bgamari/ghc-utils"
}
},
"gomod2nix": {
"flake": false,
"locked": {
@ -217,6 +233,7 @@
"crane": "crane",
"devshell": "devshell",
"flake-utils-pre-commit": "flake-utils-pre-commit",
"ghc-utils": "ghc-utils",
"gomod2nix": "gomod2nix",
"mach-nix": "mach-nix",
"nixpkgs": "nixpkgs",

View File

@ -53,6 +53,11 @@
url = "github:nix-community/all-cabal-json/hackage";
flake = false;
};
ghc-utils = {
url = "git+https://gitlab.haskell.org/bgamari/ghc-utils";
flake = false;
};
};
outputs = {
@ -66,6 +71,7 @@
pre-commit-hooks,
crane,
all-cabal-json,
ghc-utils,
...
} @ inp: let
b = builtins;

View File

@ -79,4 +79,37 @@ in {
(targetBuildDepends ++ buildToolDepends ++ condBuildDepends);
in
depNames;
# XXX: This might be better as a function. See
# https://github.com/nixos/nixpkgs/blob/773c2a7afa4cc94f91d53d8cb35245cbf216082b/pkgs/development/haskell-modules/configuration-ghc-9.4.x.nix#L49-L56
# Packages we shouldn't always overwrite with null, but presently do anyway, are
# 1) terminfo, when we cross-compile
# 2) xhtml, when ghc.hasHaddock is set to false
ghcVersionToHiddenPackages = l.pipe "${inputs.ghc-utils}/library-versions/pkg_versions.txt" [
l.readFile
(l.split "\n#+\n# GHC [^\n]+")
l.tail
(l.filter l.isString)
(l.concatMap (l.splitString "\n"))
(l.filter (s: s != "" && !(l.hasPrefix "HEAD" s)))
(l.map (
s: let
ghcVersionAndHiddenPackages = l.match "([^[:space:]]+)[[:space:]]+(.+)" s;
ghcVersion = l.head ghcVersionAndHiddenPackages;
hiddenPackages = l.pipe (l.last ghcVersionAndHiddenPackages) [
(l.splitString " ")
(l.map (packageAndVersion:
l.pipe packageAndVersion [
(l.match "([^/]+)/.+")
l.head
(packageName: l.nameValuePair packageName null)
]))
(pkgNames: [(l.nameValuePair "Win32" null)] ++ pkgNames)
l.listToAttrs
];
in
l.nameValuePair ghcVersion hiddenPackages
))
l.listToAttrs
];
}