aboutsummaryrefslogtreecommitdiff
path: root/pkgs/test
diff options
context:
space:
mode:
authorJacquin Mininger <jacquin.mininger@gmail.com>2019-12-23 15:33:18 -0500
committerJohn Ericson <John.Ericson@Obsidian.Systems>2020-01-17 10:46:29 -0500
commit7d67db39199130aa75bb3315e991830e2a988258 (patch)
tree73b8bff21d46d60e4fbcc97500ad343f2ff47ca3 /pkgs/test
parentba9066abcaace69b8ed36ef43a8b82d04a6e0e5b (diff)
shellFor: Refactor for consistency and cross
This makes it work like work-on-multi from Reflex Platform. In particular, rather than making `.env` from `shellFor`, we make `.env` the primitive, and `shellFor` works by combining together the arguments of all the packages to `generic-builder` and taking the `.env` of the resulting mashup-package. There are 2 benefits of this: 1. The dependency logic is deduplicated. generic builder just concatted lists, whereas all the envs until now would sieve apart haskell and system build inputs. Now, they both decide haskell vs system the same way: according to the argument list and without reflection. Consistency is good, especially because it mean that if the build works, the shell is more likely to work. 2. Cross is handled better. For native builds, because the `ghcWithPackages` calls would shadow, we through both the regular component (lib, exe, test, bench) haskell deps and Setup.hs haskell deps in the same `ghcWithPackages` call. But for cross builds we use `buildPackages.ghcWithPackages` to get the setup deps. This ensures everything works correctly.
Diffstat (limited to 'pkgs/test')
-rw-r--r--pkgs/test/default.nix2
-rw-r--r--pkgs/test/haskell-shellFor/default.nix24
2 files changed, 26 insertions, 0 deletions
diff --git a/pkgs/test/default.nix b/pkgs/test/default.nix
index 793229f8bbb0..da7e8a816cdb 100644
--- a/pkgs/test/default.nix
+++ b/pkgs/test/default.nix
@@ -22,6 +22,8 @@ with pkgs;
cc-wrapper-libcxx-7 = callPackage ./cc-wrapper { stdenv = llvmPackages_7.libcxxStdenv; };
stdenv-inputs = callPackage ./stdenv-inputs { };
+ haskell-shellFor = callPackage ./haskell-shellFor { };
+
cc-multilib-gcc = callPackage ./cc-wrapper/multilib.nix { stdenv = gccMultiStdenv; };
cc-multilib-clang = callPackage ./cc-wrapper/multilib.nix { stdenv = clangMultiStdenv; };
diff --git a/pkgs/test/haskell-shellFor/default.nix b/pkgs/test/haskell-shellFor/default.nix
new file mode 100644
index 000000000000..1b3de999d228
--- /dev/null
+++ b/pkgs/test/haskell-shellFor/default.nix
@@ -0,0 +1,24 @@
+{ stdenv, haskellPackages, cabal-install }:
+
+haskellPackages.shellFor {
+ packages = p: [ p.database-id-class p.constraints-extras ];
+ nativeBuildInputs = [ cabal-install ];
+ phases = [ "unpackPhase" "buildPhase" "installPhase" ];
+ unpackPhase = ''
+ sourceRoot=$(pwd)/scratch
+ mkdir -p "$sourceRoot"
+ cd "$sourceRoot"
+ tar -xf ${haskellPackages.database-id-class.src}
+ tar -xf ${haskellPackages.constraints-extras.src}
+ cp ${builtins.toFile "cabal.project" "packages: database-id-class* constraints-extras*"} cabal.project
+ '';
+ buildPhase = ''
+ export HOME=$(mktemp -d)
+ mkdir -p $HOME/.cabal
+ touch $HOME/.cabal/config
+ cabal v2-build --offline --verbose database-id-class constraints-extras --ghc-options="-O0 -j$NIX_BUILD_CORES"
+ '';
+ installPhase = ''
+ touch $out
+ '';
+}