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).
54 lines
2.0 KiB
Nix
54 lines
2.0 KiB
Nix
{ stdenv, lib, fetchFromGitHub, recurseIntoAttrs, runCommand, testSrc, compiler-nix-name, evalPackages, buildPackages, sources }:
|
|
|
|
with lib;
|
|
|
|
let
|
|
# Using buildPackages.buildPackages here because buildPackages.git
|
|
# is built with a cross compiler version of gdb (needed by python).
|
|
# So buildPackages.buildPackages.git is more likely to be in the cache.
|
|
inherit (buildPackages.buildPackages) jq git;
|
|
|
|
hpc-coveralls-exes = (buildPackages.haskell-nix.project' {
|
|
inherit compiler-nix-name evalPackages;
|
|
src = sources.hpc-coveralls;
|
|
}).hsPkgs.hpc-coveralls.components.exes;
|
|
|
|
exampleProjectSrc = sources.cardano-shell;
|
|
|
|
exampleProject = import "${exampleProjectSrc}" { config = { haskellNix = { coverage = true; }; }; };
|
|
exampleCoverageReport = exampleProject.cardanoShellHaskellPackages.projectCoverageReport;
|
|
|
|
in recurseIntoAttrs ({
|
|
# Does not work on ghcjs because it needs zlib.
|
|
meta.disabled = stdenv.hostPlatform.isGhcjs;
|
|
run = stdenv.mkDerivation {
|
|
name = "coverage-golden-test";
|
|
|
|
nativeBuildInputs = [ git jq hpc-coveralls-exes.hpc-coveralls hpc-coveralls-exes.run-cabal-test ];
|
|
buildCommand = ''
|
|
########################################################################
|
|
# Test that the coverage reports haven't materially changed
|
|
|
|
TRAVIS=1 TRAVIS_JOB_ID=1 hpc-coveralls all \
|
|
--package-dir ${exampleProjectSrc}/cardano-shell/ \
|
|
--package-dir ${exampleProjectSrc}/cardano-launcher \
|
|
--hpc-dir ${exampleCoverageReport}/share/hpc/vanilla \
|
|
--coverage-mode StrictlyFullLines \
|
|
--dont-send
|
|
|
|
# Format JSON for better diffing error messages and remove
|
|
# references to Nix path, our golden coverage file contains no
|
|
# Nix paths
|
|
cat ./travis-ci-1.json | jq -S | sed "s;${exampleProjectSrc}/;;g" > ./actual.json
|
|
|
|
# Fail if doesn't match golden, i.e. our coverage has changed
|
|
diff ${./golden.json} ./actual.json
|
|
|
|
touch $out
|
|
'';
|
|
|
|
meta.platforms = platforms.all;
|
|
meta.disabled = compiler-nix-name != "ghc865";
|
|
};
|
|
})
|