nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 haskell,
4 haskellPackages,
5 runCommand,
6}:
7
8let
9 localRaw = haskellPackages.callPackage ./generated.nix { };
10
11 # A patched variant to test that buildFromCabalSdist respects patches
12 localPatched = haskell.lib.appendPatches localRaw [ ./change-greeting.patch ];
13in
14lib.recurseIntoAttrs rec {
15
16 helloFromCabalSdist = haskellPackages.buildFromCabalSdist haskellPackages.hello;
17
18 # A more complicated example with a cabal hook.
19 hercules-ci-cnix-store = haskellPackages.buildFromCabalSdist haskellPackages.hercules-ci-cnix-store;
20
21 localFromCabalSdist = haskellPackages.buildFromCabalSdist localRaw;
22
23 # This test makes sure that localHasNoDirectReference can actually fail if
24 # it doesn't do anything. If this test fails, either the test setup was broken,
25 # or Haskell packaging has changed the way `src` is treated in such a way that
26 # either the test or the design of `buildFromCabalSdist` needs to be reconsidered.
27 assumptionLocalHasDirectReference =
28 runCommand "localHasDirectReference"
29 {
30 drvPath = builtins.unsafeDiscardOutputDependency localRaw.drvPath;
31 }
32 ''
33 grep ${localRaw.src} $drvPath >/dev/null
34 touch $out
35 '';
36
37 localHasNoDirectReference =
38 runCommand "localHasNoDirectReference"
39 {
40 drvPath = builtins.unsafeDiscardOutputDependency localFromCabalSdist.drvPath;
41 }
42 ''
43 grep -v ${localRaw.src} $drvPath >/dev/null
44 touch $out
45 '';
46
47 # Test that buildFromCabalSdist respects patches applied to the package.
48 # The patch changes the greeting from "Hello, Haskell!" to "Hello, Patched Haskell!".
49 localPatchedFromCabalSdist = haskellPackages.buildFromCabalSdist localPatched;
50
51 patchRespected =
52 runCommand "patchRespected"
53 {
54 nativeBuildInputs = [ localPatchedFromCabalSdist ];
55 }
56 ''
57 ${lib.getExe localPatchedFromCabalSdist} | grep "Patched" >/dev/null
58 touch $out
59 '';
60
61 # Test that buildFromSdist (non-cabal-install variant) also respects patches.
62 localPatchedFromSdist = haskell.lib.buildFromSdist localPatched;
63
64 patchRespectedSdist =
65 runCommand "patchRespectedSdist"
66 {
67 nativeBuildInputs = [ localPatchedFromSdist ];
68 }
69 ''
70 ${lib.getExe localPatchedFromSdist} | grep "Patched" >/dev/null
71 touch $out
72 '';
73}