haskell-te: 8b9843fb4308db2eb237d42a0cb58f9019c5ee6e

     1: # Make a list of packages suitable for a 'buildInputs' field. We treat Haskell
     2: # packages separately from everything else. The Haskell packages will include:
     3: #
     4: #  - The contents of 'extraHaskellPackages', required for our scripts
     5: #  - The contents of the 'extraHs' argument; use '[]' for none
     6: #  - The cabal package contained at path 'standalone' (requires a 'default.nix'
     7: #    file, e.g. from 'nixFromCabal'); use 'null' for none
     8: #  - Any 'package' fields read from the JSON file 'f'
     9: #
    10: # The non-Haskell packages will include:
    11: #
    12: #  - The contents of extra-packages, required by our scripts
    13: #  - The contents of the 'extraPkgs' argument; use '[]' for none
    14: 
    15: { checkHsEnv, extraHaskellPackages, haskellPackages, jq, lib, pkgName,
    16:   runCommand, withDeps }:
    17: 
    18: { extraPkgs ? [], extraHs ? [], standalone ? null, f ? null }:
    19:   with rec {
    20:     names     = if standalone == null then [] else [ name ];
    21:     pkgs      = h: if standalone == null || builtins.elem name hsNames
    22:                       then []
    23:                       else [ (pkg h) ];
    24:     name      = assert standalone != null;
    25:                 pkgName (pkg haskellPackages).name;
    26:     pkg       = assert standalone != null;
    27:                 h: h.callPackage (import standalone) {};
    28:     extras    = [ jq ] ++ extraPkgs;
    29:     hsNames   = lib.unique (map pkgName (extraHaskellPackages ++ extraHs));
    30:     ghcEnv    = (haskellPackages.ghcWithPackages (h: pkgs h ++ (lib.concatMap
    31:                   (n: if builtins.hasAttr n haskellPackages
    32:                          then [ (builtins.getAttr n h) ]
    33:                          else [])
    34:                   hsNames))).override { ignoreCollisions = true; };
    35:     check     = runCommand "checkIfHsPkgsInEnv"
    36:                   { buildInputs = [ ghcEnv ] ++ extras; }
    37:                   ''
    38:                     set -e
    39:                     "${checkHsEnv (hsNames ++ names)}"
    40:                     echo "true" > "$out"
    41:                   '';
    42:   };
    43:   [ (withDeps [ check ] ghcEnv) ] ++ extras

Generated by git2html.