@@ -1,4 +1,11 @@
1{ dotCabal, pkgs, runCommand, nix-tools, cabal-install, ghc, hpack, symlinkJoin, cacert, index-state-hashes, haskellLib, materialize }@defaults:
1{ dotCabal, pkgs, runCommand, nix-tools, cabal-install, ghc, hpack, symlinkJoin, cacert, index-state-hashes, haskellLib, materialize }@defaults:
2+let readIfExists = src: fileName:
3+ let origSrcDir = src.origSrcSubDir or src;
5+ if ((__readDir origSrcDir)."${fileName}" or "") == "regular"
6+ then __readFile (origSrcDir + "/${fileName}")
2{ name ? src.name or null # optional name for better error messages
9{ name ? src.name or null # optional name for better error messages
4, index-state ? null # Hackage index-state, eg. "2019-10-10T00:00:00Z"
11, index-state ? null # Hackage index-state, eg. "2019-10-10T00:00:00Z"
@@ -6,7 +13,10 @@
6, plan-sha256 ? null # The hash of the plan-to-nix output (makes the plan-to-nix step a fixed output derivation)
13, plan-sha256 ? null # The hash of the plan-to-nix output (makes the plan-to-nix step a fixed output derivation)
7, materialized ? null # Location of a materialized copy of the nix files
14, materialized ? null # Location of a materialized copy of the nix files
8, checkMaterialization ? null # If true the nix files will be generated used to check plan-sha256 and material
15, checkMaterialization ? null # If true the nix files will be generated used to check plan-sha256 and material
9−, cabalProject ? null # Cabal project file (when null uses "${src}/cabal.project")
16+, cabalProjectFileName ? "cabal.project"
17+, cabalProject ? readIfExists src cabalProjectFileName
18+, cabalProjectLocal ? readIfExists src "${cabalProjectFileName}.local"
19+, cabalProjectFreeze ? readIfExists src "${cabalProjectFileName}.freeze"
10, compiler-nix-name ? null # Nix name of the ghc compiler as a string eg. "ghc883"
20, compiler-nix-name ? null # Nix name of the ghc compiler as a string eg. "ghc883"
11, ghc ? null # Deprecated in favour of `compiler-nix-name`
21, ghc ? null # Deprecated in favour of `compiler-nix-name`
12, ghcOverride ? null # Used when we need to set ghc explicitly during bootstrapping
22, ghcOverride ? null # Used when we need to set ghc explicitly during bootstrapping
@@ -63,20 +73,24 @@ let
63 src = src.origSrc;
73 src = src.origSrc;
64 filter = path: type: src.filter path type && (
74 filter = path: type: src.filter path type && (
65 type == "directory" ||
75 type == "directory" ||
66− pkgs.lib.any (i: (pkgs.lib.hasSuffix i path)) [ ".project" ".cabal" ".freeze" "package.yaml" ]); })
76+ pkgs.lib.any (i: (pkgs.lib.hasSuffix i path)) [ ".cabal" "package.yaml" ]); })
67 else src.origSrc or src;
77 else src.origSrc or src;
69 # Using origSrcSubDir bypasses any cleanSourceWith so that it will work when
79 # Using origSrcSubDir bypasses any cleanSourceWith so that it will work when
70 # access to the store is restricted. If origSrc was already in the store
80 # access to the store is restricted. If origSrc was already in the store
71 # you can pass the project in as a string.
81 # you can pass the project in as a string.
72 rawCabalProject =
82 rawCabalProject =
73− let origSrcDir = (maybeCleanedSource.origSrcSubDir or maybeCleanedSource) + subDir';
83+ if cabalProject != null
74− in if cabalProject != null
84+ then cabalProject + (
85+ if cabalProjectLocal != null
75− then cabalProject
86+ then ''
77− if ((builtins.readDir origSrcDir)."cabal.project" or "") == "regular"
88+ -- Added from cabalProjectLocal argument to cabalProject
78− then builtins.readFile (origSrcDir + "/cabal.project")
89+ ${cabalProjectLocal}
79− else null;
93+ else null;
81 # Look for a index-state: field in the cabal.project file
95 # Look for a index-state: field in the cabal.project file
82 parseIndexState = rawCabalProject:
96 parseIndexState = rawCabalProject:
@@ -107,7 +121,7 @@ let
109 assert (if index-state-found == null
123 assert (if index-state-found == null
110− then throw "No index state passed and none found in cabal.project" else true);
124+ then throw "No index state passed and none found in ${cabalProjectFileName}" else true);
111 assert (if index-sha256-found == null
125 assert (if index-sha256-found == null
112 then throw "provided sha256 for index-state ${index-state-found} is null!" else true);
126 then throw "provided sha256 for index-state ${index-state-found} is null!" else true);
@@ -144,7 +158,7 @@ let
144 ref = repo.tag;
158 ref = repo.tag;
146 in __trace "WARNING: No sha256 found for source-repository-package ${repo.location} ${repo.tag} download may fail in restricted mode (hydra)"
160 in __trace "WARNING: No sha256 found for source-repository-package ${repo.location} ${repo.tag} download may fail in restricted mode (hydra)"
147− (__trace "Consider adding `--sha256: ${hashPath drv}` to the cabal.project file or passing in a lookupSha256 argument"
161+ (__trace "Consider adding `--sha256: ${hashPath drv}` to the ${cabalProjectFileName} file or passing in a lookupSha256 argument"
149 ) + (if repo.subdir or "" == "" then "" else "/" + repo.subdir);
163 ) + (if repo.subdir or "" == "" then "" else "/" + repo.subdir);
@@ -359,6 +373,10 @@ let
359 find . -name package.yaml -exec hpack "{}" \;
373 find . -name package.yaml -exec hpack "{}" \;
360 ${pkgs.lib.optionalString (subDir != "") "cd ${subDir}"}
374 ${pkgs.lib.optionalString (subDir != "") "cd ${subDir}"}
361 ${fixedProject.makeFixedProjectFile}
375 ${fixedProject.makeFixedProjectFile}
376+ ${pkgs.lib.optionalString (cabalProjectFreeze != null) ''
377+ cp ${pkgs.evalPackages.writeText "cabal.project.freeze" cabalProjectFreeze} \
378+ cabal.project.freeze
362 export SSL_CERT_FILE=${cacert}/etc/ssl/certs/ca-bundle.crt
380 export SSL_CERT_FILE=${cacert}/etc/ssl/certs/ca-bundle.crt
363 export GIT_SSL_CAINFO=${cacert}/etc/ssl/certs/ca-bundle.crt
381 export GIT_SSL_CAINFO=${cacert}/etc/ssl/certs/ca-bundle.crt
364 HOME=${dotCabal {
382 HOME=${dotCabal {