on 19052d8 help sign in
haskell.nix/test/githash/default.nix
71 lines 2.5 kB history raw
1{ stdenv, lib, haskell-nix, haskellLib, recurseIntoAttrs, testSrc, compiler-nix-name, runCommand, gitMinimal, buildPackages }:
3with lib;
5let
6 src = testSrc "githash";
7 git =
8 # Using the cross compiled version here, but currently git does not
9 # seem to cross compile (so this test is disabled for cross compilation in
10 # the test/default.nix file).
11 # Using buildPackages here is not right, but at least gets musl64 test to pass.
12 if stdenv.hostPlatform != stdenv.buildPlatform
13 then buildPackages.buildPackages.gitReallyMinimal
14 else gitMinimal;
15 project = haskell-nix.cabalProject' {
16 inherit src;
17 # When haskell.nix has come from the store (e.g. on hydra) we need to provide
18 # a suitable mock of the cleaned source with a .git dir.
19 modules = (optional (!(src ? origSrc && __pathExists (src.origSrc + "/.git"))) {
20 packages.githash-test.src =
21 rec {
22 origSrc = runCommand "githash-test-src" { nativeBuildInputs = [ git ]; } ''
23 mkdir -p $out/test/githash
24 cd $out
25 git init
26 cp -r ${src}/* test/githash
27 git add test/githash
28 git -c "user.name=unknown" -c "user.email=unknown" commit -m 'Initial Commit'
29 '';
30 origSubDir = "/test/githash";
31 origSrcSubDir = origSrc + origSubDir;
32 outPath = origSrcSubDir;
33 };
34 }) ++ [{
35 packages.githash-test.components.exes.githash-test.build-tools = mkForce [ git ];
36 }];
37 inherit compiler-nix-name;
38 };
40 packages = project.hsPkgs;
41 githash-test =
42 packages.githash-test.components.exes.githash-test;
44in recurseIntoAttrs {
45 # githash runs git from TH code and this needs a cross compiled git exe
46 # to work correctly. Cross compiling git is currently brocken.
47 meta.disabled = compiler-nix-name == "ghc901" || haskellLib.isCrossHost;
49 ifdInputs = {
50 inherit (project) plan-nix;
51 };
53 run = stdenv.mkDerivation {
54 name = "run-githash-test";
56 buildCommand = ''
57 exe="${githash-test}/bin/githash-test${stdenv.hostPlatform.extensions.executable}"
58 echo Checking that the error message is generated and that it came from the right place:
59 (${toString githash-test.config.testWrapper} $exe || true) 2>&1 \
60 | grep "error, called at src/Main.hs:5:13 in main:Main"
61 touch $out
62 '';
64 meta.platforms = platforms.all;
66 passthru = {
67 # Used for debugging with nix repl
68 inherit project packages;
69 };
70 };