Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ 2 lib, 3 writeText, 4 haskellPackages, 5 cabal-install, 6}: 7 8(haskellPackages.shellFor { 9 packages = p: [ 10 p.constraints 11 p.cereal 12 ]; 13 # WARNING: When updating this, make sure that the libraries passed to 14 # `extraDependencies` are not actually transitive dependencies of libraries in 15 # `packages` above. We explicitly want to test that it is possible to specify 16 # `extraDependencies` that are not in the closure of `packages`. 17 extraDependencies = p: { libraryHaskellDepends = [ p.conduit ]; }; 18 nativeBuildInputs = [ cabal-install ]; 19 phases = [ 20 "unpackPhase" 21 "buildPhase" 22 "installPhase" 23 ]; 24 unpackPhase = '' 25 sourceRoot=$(pwd)/scratch 26 mkdir -p "$sourceRoot" 27 cd "$sourceRoot" 28 tar -xf ${haskellPackages.constraints.src} 29 tar -xf ${haskellPackages.cereal.src} 30 cp ${writeText "cabal.project" "packages: constraints* cereal*"} cabal.project 31 ''; 32 buildPhase = '' 33 export HOME=$(mktemp -d) 34 mkdir -p $HOME/.cabal 35 touch $HOME/.cabal/config 36 37 # Check that the extraDependencies.libraryHaskellDepends arg is correctly 38 # picked up. This uses ghci to interpret a small Haskell program that uses 39 # a package from extraDependencies. 40 ghci <<EOF 41 :set -XOverloadedStrings 42 :m + Conduit 43 runResourceT $ connect (yield "done") (sinkFile "outfile") 44 EOF 45 46 if [[ "done" != "$(cat outfile)" ]]; then 47 echo "ERROR: extraDependencies appear not to be available in the environment" 48 exit 1 49 fi 50 51 # Check packages arg 52 cabal v2-build --offline --verbose constraints cereal --ghc-options="-O0 -j$NIX_BUILD_CORES" 53 ''; 54 installPhase = '' 55 touch $out 56 ''; 57}).overrideAttrs 58 (oldAttrs: { 59 meta = 60 let 61 oldMeta = oldAttrs.meta or { }; 62 oldMaintainers = oldMeta.maintainers or [ ]; 63 additionalMaintainers = with lib.maintainers; [ cdepillabout ]; 64 allMaintainers = oldMaintainers ++ additionalMaintainers; 65 in 66 oldMeta 67 // { 68 maintainers = allMaintainers; 69 inherit (cabal-install.meta) platforms; 70 }; 71 # `shellFor` adds a `buildCommand` (via `envFunc -> runCommandCC`), which 72 # overrides custom phases. To ensure this test's phases run, we remove 73 # that `buildCommand` from the derivation. 74 buildCommand = null; 75 })