mirror of
https://github.com/ilyakooo0/haskell.nix.git
synced 2024-09-11 06:55:40 +03:00
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).
72 lines
2.5 KiB
Nix
72 lines
2.5 KiB
Nix
{ stdenv, lib, haskell-nix, haskellLib, recurseIntoAttrs, testSrc, compiler-nix-name, evalPackages, runCommand, gitMinimal, buildPackages }:
|
|
|
|
with lib;
|
|
|
|
let
|
|
src = testSrc "githash";
|
|
git =
|
|
# Using the cross compiled version here, but currently git does not
|
|
# seem to cross compile (so this test is disabled for cross compilation in
|
|
# the test/default.nix file).
|
|
# Using buildPackages here is not right, but at least gets musl64 test to pass.
|
|
if stdenv.hostPlatform != stdenv.buildPlatform
|
|
then buildPackages.buildPackages.gitReallyMinimal
|
|
else gitMinimal;
|
|
project = haskell-nix.cabalProject' {
|
|
inherit src;
|
|
# When haskell.nix has come from the store (e.g. on hydra) we need to provide
|
|
# a suitable mock of the cleaned source with a .git dir.
|
|
modules = (optional (!(src ? origSrc && __pathExists (src.origSrc + "/.git"))) {
|
|
packages.githash-test.src =
|
|
rec {
|
|
origSrc = runCommand "githash-test-src" { nativeBuildInputs = [ git ]; } ''
|
|
mkdir -p $out/test/githash
|
|
cd $out
|
|
git init
|
|
cp -r ${src}/* test/githash
|
|
git add test/githash
|
|
git -c "user.name=unknown" -c "user.email=unknown" commit -m 'Initial Commit'
|
|
'';
|
|
origSubDir = "/test/githash";
|
|
origSrcSubDir = origSrc + origSubDir;
|
|
outPath = origSrcSubDir;
|
|
};
|
|
}) ++ [{
|
|
packages.githash-test.components.exes.githash-test.build-tools = mkForce [ git ];
|
|
}];
|
|
inherit compiler-nix-name evalPackages;
|
|
};
|
|
|
|
packages = project.hsPkgs;
|
|
githash-test =
|
|
packages.githash-test.components.exes.githash-test;
|
|
|
|
in recurseIntoAttrs {
|
|
# githash runs git from TH code and this needs a cross compiled git exe
|
|
# to work correctly. Cross compiling git is currently brocken.
|
|
meta.disabled = __elem compiler-nix-name ["ghc901" "ghc902"] || haskellLib.isCrossHost;
|
|
|
|
ifdInputs = {
|
|
inherit (project) plan-nix;
|
|
};
|
|
|
|
run = stdenv.mkDerivation {
|
|
name = "run-githash-test";
|
|
|
|
buildCommand = ''
|
|
exe="${githash-test}/bin/githash-test${stdenv.hostPlatform.extensions.executable}"
|
|
echo Checking that the error message is generated and that it came from the right place:
|
|
(${toString githash-test.config.testWrapper} $exe || true) 2>&1 \
|
|
| grep "error, called at src/Main.hs:5:13 in main:Main"
|
|
touch $out
|
|
'';
|
|
|
|
meta.platforms = platforms.all;
|
|
|
|
passthru = {
|
|
# Used for debugging with nix repl
|
|
inherit project packages;
|
|
};
|
|
};
|
|
}
|