mirror of
https://github.com/simplex-chat/haskell.nix.git
synced 2026-06-03 09:17:32 +00:00
a443611ecf
This adds a way to specify the `evalSystem` or `evalPackages` explicitly when calling the `project` functions. Currently if we want to make a `flake` that supports multiple systems we have few options: * Require builders for all the supported systems (even just for `nix flake show`). * Pass `--impure` so that haskell.nix can see `builtins.currentSystem` to set up `pkgs.evalPackages` to use that. Unfortunately this prevents nix from caching some of the work it does and often results in it recalculating for each supported system when it would otherwise be cached and take no time at all. * Add an overlay to replace `evalPackages`. This works, but it is not straight forward. * Materialize the nix files for the project. This change allows `evalSystem = "x86_64-linux";` to be passed telling `haskell.nix` to run `cabal` and `nix-tools` on that system. The user will have to have a builder for that system, but does not need to have builders for the others (unless building outputs for them).
87 lines
2.4 KiB
Nix
87 lines
2.4 KiB
Nix
{ mkCabalProjectPkgSet, stdenv, lib, testSrc, compiler-nix-name, evalPackages }:
|
|
|
|
with lib;
|
|
|
|
let
|
|
pkgSet = mkCabalProjectPkgSet {
|
|
plan-pkgs = import ./pkgs.nix;
|
|
modules = [
|
|
# overrides to fix the build
|
|
{
|
|
packages.transformers-compat.components.library.doExactConfig = true;
|
|
}
|
|
|
|
{
|
|
# Add a hook to the haddock phase
|
|
packages.test-haddock.postHaddock = ''
|
|
echo "==="
|
|
echo "This is the postHaddock hook. The files are:"
|
|
find .
|
|
echo "==="
|
|
'';
|
|
|
|
# Check that the package option works
|
|
packages.stm.doHaddock = false;
|
|
}
|
|
|
|
{ inherit evalPackages; }
|
|
];
|
|
};
|
|
|
|
packages = pkgSet.config.hsPkgs;
|
|
|
|
in
|
|
stdenv.mkDerivation {
|
|
name = "builder-haddock-test";
|
|
|
|
buildCommand = let
|
|
inherit (packages.test-haddock.components) library;
|
|
noDocLibrary = packages.stm.components.library;
|
|
in ''
|
|
########################################################################
|
|
# test haddock
|
|
|
|
doc="${toString library.doc or null}"
|
|
docDir="${toString library.haddockDir}"
|
|
|
|
# exeDoc="$ disabled {toString packages.test-haddock.components.exes.test-haddock.doc}"
|
|
# printf "checking that executable output does not have docs ... " >& 2
|
|
# echo $exeDoc
|
|
# test "$exeDoc" = ""
|
|
|
|
printf "checking that documentation directory was built... " >& 2
|
|
echo "$doc" >& 2
|
|
test -n "$doc"
|
|
|
|
printf "checking that documentation was generated... " >& 2
|
|
grep hello "$docDir/TestHaddock.html" > /dev/null
|
|
echo yes >& 2
|
|
|
|
printf "checking for hoogle index of package... " >& 2
|
|
grep hello "$docDir/test-haddock.txt" > /dev/null
|
|
echo yes >& 2
|
|
|
|
printf "checking for absence of documentation in another package... " >& 2
|
|
if [ -d "${toString noDocLibrary.haddockDir}" ]; then
|
|
echo "it exists - FAIL" >& 2
|
|
else
|
|
echo PASS >& 2
|
|
fi
|
|
|
|
printf "checking for absence of library package store paths in docs... " >& 2
|
|
if grep -R ${library} "$docDir" > /dev/null; then
|
|
echo "Found ${library} - FAIL" >& 2
|
|
exit 1
|
|
else
|
|
echo "PASS" >& 2
|
|
fi
|
|
|
|
touch $out
|
|
'';
|
|
|
|
meta = {
|
|
platforms = platforms.all;
|
|
disabled = stdenv.hostPlatform != stdenv.buildPlatform || stdenv.hostPlatform.isMusl || compiler-nix-name != "ghc865";
|
|
};
|
|
} // { inherit packages pkgSet; }
|