nisspkgs/apps/multi-ghc.nix
2025-03-03 22:34:32 +01:00

27 lines
751 B
Nix

{ pkgs ? import <nixpkgs> {},
versions ? [ "8.10" "9.0" "9.2" "9.4" "9.6" "9.8" "9.10" "9.12" ],
}:
let
inherit (builtins) attrValues replaceStrings;
inherit (pkgs) lib stdenv haskell;
toPkg = version:
"ghc" + replaceStrings ["."] [""] version;
ghcs = lib.genAttrs versions
(v: haskell.compiler.${toPkg v});
mkLinkCmd = version: pkg: ''
ln -s ${pkg}/bin/ghc $out/bin/ghc-${version}
ln -s ${pkg}/bin/ghci $out/bin/ghci-${version}
ln -s ${pkg}/bin/ghc-pkg $out/bin/ghc-pkg-${version}
'';
in
stdenv.mkDerivation {
name = "multi-ghc";
buildInputs = attrValues ghcs;
dontUnpack = true;
installPhase = lib.concatLines
([ "mkdir -p $out/bin" ] ++
lib.mapAttrsToList mkLinkCmd ghcs);
}