2019-10-19 18:53:48 +03:00
|
|
|
|
{ pkgs ? (import ./nix/nixpkgs)
|
2020-06-26 14:55:55 +03:00
|
|
|
|
, ghc ? "ghc884"
|
2019-10-19 18:53:48 +03:00
|
|
|
|
}:
|
|
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
|
|
megaparsecSource = pkgs.lib.sourceByRegex ./. [
|
|
|
|
|
"^CHANGELOG\.md$"
|
|
|
|
|
"^LICENSE\.md$"
|
|
|
|
|
"^README\.md$"
|
|
|
|
|
"^Text.*$"
|
|
|
|
|
"^bench.*$"
|
|
|
|
|
"^megaparsec\.cabal$"
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
megaparsecTestsSource = pkgs.lib.sourceByRegex ./megaparsec-tests [
|
|
|
|
|
"^LICENSE\.md$"
|
|
|
|
|
"^README\.md$"
|
|
|
|
|
"^megaparsec-tests\.cabal$"
|
|
|
|
|
"^src.*$"
|
|
|
|
|
"^tests.*$"
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
parsersBenchSource = pkgs.lib.sourceByRegex ./parsers-bench [
|
|
|
|
|
"^README\.md$"
|
|
|
|
|
"^parsers-bench\.cabal$"
|
|
|
|
|
"^ParsersBench.*$"
|
|
|
|
|
"^bench.*$"
|
|
|
|
|
"^data.*$"
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
doBenchmark = p:
|
|
|
|
|
let targets = ["bench-speed" "bench-memory"];
|
|
|
|
|
copying = pkgs.lib.concatMapStrings
|
|
|
|
|
(t: "cp dist/build/${t}/${t} $out/bench/\n")
|
|
|
|
|
targets;
|
|
|
|
|
in pkgs.haskell.lib.doBenchmark
|
|
|
|
|
(p.overrideAttrs (drv: {
|
|
|
|
|
postInstall = ''
|
|
|
|
|
mkdir -p $out/bench
|
|
|
|
|
if test -d data/
|
|
|
|
|
then
|
|
|
|
|
mkdir -p $out/bench/data
|
|
|
|
|
cp data/* $out/bench/data/
|
|
|
|
|
fi
|
|
|
|
|
${copying}
|
|
|
|
|
'';
|
|
|
|
|
}));
|
|
|
|
|
|
2019-11-07 21:35:27 +03:00
|
|
|
|
doJailbreak = pkgs.haskell.lib.doJailbreak;
|
|
|
|
|
|
2019-10-19 18:53:48 +03:00
|
|
|
|
megaparsecOverlay = self: super: {
|
|
|
|
|
"megaparsec" = doBenchmark
|
|
|
|
|
(super.callCabal2nix "megaparsec" megaparsecSource { });
|
|
|
|
|
"megaparsec-tests" =
|
|
|
|
|
super.callCabal2nix "megaparsec-tests" megaparsecTestsSource { };
|
|
|
|
|
# The ‘parser-combinators-tests’ package is a bit special because it
|
|
|
|
|
# does not contain an executable nor a library, so its install phase
|
|
|
|
|
# normally fails. We want to build it and run the tests anyway, so we
|
|
|
|
|
# have to do these manipulations.
|
2020-02-28 01:38:39 +03:00
|
|
|
|
"parser-combinators-tests" = pkgs.haskell.lib.dontHaddock
|
2020-06-26 14:55:55 +03:00
|
|
|
|
(super.parser-combinators-tests.overrideAttrs (drv: {
|
2020-02-28 01:38:39 +03:00
|
|
|
|
installPhase = "mkdir $out";
|
|
|
|
|
broken = false;
|
|
|
|
|
}));
|
|
|
|
|
"modern-uri" = doBenchmark super.modern-uri;
|
|
|
|
|
"parsers-bench" = doBenchmark
|
|
|
|
|
(super.callCabal2nix "parsers-bench" parsersBenchSource { });
|
2020-06-26 14:55:55 +03:00
|
|
|
|
"hspec-megaparsec" =
|
|
|
|
|
patch super.hspec-megaparsec ./nix/patches/hspec-megaparsec.patch;
|
|
|
|
|
"dhall" =
|
|
|
|
|
patch super.dhall ./nix/patches/dhall.patch;
|
|
|
|
|
"idris" =
|
|
|
|
|
patch super.idris ./nix/patches/idris.patch;
|
|
|
|
|
"tomland" =
|
|
|
|
|
patch super.tomland ./nix/patches/tomland.patch;
|
2019-10-19 18:53:48 +03:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
updatedPkgs = pkgs // {
|
|
|
|
|
haskell = pkgs.haskell // {
|
|
|
|
|
packages = pkgs.haskell.packages // {
|
|
|
|
|
"${ghc}" = pkgs.haskell.packages.${ghc}.override {
|
|
|
|
|
overrides = megaparsecOverlay;
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
haskellPackages = updatedPkgs.haskell.packages.${ghc};
|
|
|
|
|
|
|
|
|
|
patch = p: patch:
|
|
|
|
|
pkgs.haskell.lib.appendPatch p patch;
|
|
|
|
|
|
|
|
|
|
in {
|
|
|
|
|
# Base: Megaparsec and its unit tests:
|
|
|
|
|
base = pkgs.recurseIntoAttrs {
|
|
|
|
|
inherit (haskellPackages)
|
|
|
|
|
hspec-megaparsec
|
|
|
|
|
megaparsec
|
|
|
|
|
megaparsec-tests
|
|
|
|
|
parser-combinators-tests;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
# Dependent packages of interest:
|
|
|
|
|
deps = pkgs.recurseIntoAttrs {
|
|
|
|
|
inherit (haskellPackages)
|
2020-06-26 14:55:55 +03:00
|
|
|
|
cachix
|
2019-10-19 18:53:48 +03:00
|
|
|
|
cassava-megaparsec
|
|
|
|
|
cue-sheet
|
2019-11-06 01:24:04 +03:00
|
|
|
|
dhall
|
2019-10-19 18:53:48 +03:00
|
|
|
|
hledger
|
|
|
|
|
hnix
|
2019-11-06 01:24:04 +03:00
|
|
|
|
idris
|
2019-10-19 18:53:48 +03:00
|
|
|
|
language-puppet
|
|
|
|
|
mmark
|
|
|
|
|
modern-uri
|
|
|
|
|
replace-megaparsec
|
|
|
|
|
stache
|
|
|
|
|
tomland;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
# Benchmarks:
|
|
|
|
|
benches = pkgs.recurseIntoAttrs {
|
|
|
|
|
inherit (haskellPackages)
|
|
|
|
|
megaparsec
|
|
|
|
|
mmark
|
|
|
|
|
modern-uri
|
|
|
|
|
parsers-bench;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
# For development:
|
|
|
|
|
shell = haskellPackages.shellFor {
|
|
|
|
|
packages = ps: [
|
|
|
|
|
ps.megaparsec
|
|
|
|
|
ps.megaparsec-tests
|
|
|
|
|
];
|
|
|
|
|
buildInputs = with haskellPackages; [
|
|
|
|
|
cabal-install
|
|
|
|
|
ghcid
|
|
|
|
|
];
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
# Distribution tarballs:
|
|
|
|
|
dist = with pkgs.haskell.lib; pkgs.recurseIntoAttrs {
|
|
|
|
|
megaparsec = sdistTarball haskellPackages.megaparsec;
|
|
|
|
|
megaparsec-tests = sdistTarball haskellPackages.megaparsec-tests;
|
|
|
|
|
};
|
|
|
|
|
}
|