on angerman/bump-nix-tools help sign in
haskell.nix/call-stack-to-nix.nix
20 lines 764 B history raw
1/* The function obtained when this is applied to a package set calls
2 * the stack-to-nix tool on a supplied source set and then
3 * imports the resulting pkgs.nix. The application of this function
4 * to a source path can thus be used directly as the input to mkStackPackageSet
5 */
6{ nix-tools, pkgs }:
7{ src, stackYaml ? null }:
8let
9 pkgsNix = pkgs.stdenv.mkDerivation {
10 name = "pkgs-nix";
11 inherit src;
12 nativeBuildInputs = [ nix-tools pkgs.nix-prefetch-git ];
13 installPhase = ''
14 export LANG=C.utf8 # Needed or stack-to-nix will die on unicode inputs
15 mkdir -p $out
16 stack-to-nix --stack-yaml=$src/${if stackYaml == null then "stack.yaml" else stackYaml} -o $out
17 mv $out/pkgs.nix $out/default.nix
18 '';
19 };
20in import pkgsNix