Skip to content

Commit f605217

Browse files
committed
Better warnings
1 parent cf4eeff commit f605217

File tree

3 files changed

+22
-16
lines changed

3 files changed

+22
-16
lines changed

overlays/bootstrap.nix

+14-12
Original file line numberDiff line numberDiff line change
@@ -378,25 +378,27 @@ in {
378378
})));
379379

380380
# Use this where we still have not good way to choose GHC version
381-
defaultCompilerNixNameTODO =
382-
# Need to use something from 8.8.x as the default to build aarch64 native compiler:
383-
if final.targetPlatform.isAarch64 && final.buildPlatform.isAarch64
384-
then "ghc883"
385-
else "ghc865";
381+
internalDefaultCompilerNixName = "ghc883";
386382

387383
# Use this when we are happy with a general warning
388384
defaultCompilerNixName = final.haskell-nix.defaultCompilerNixNameWithWarning
389-
(default:
390-
"WARNING: No compiler nix name specified! "
391-
+ "Defaulting to ${default}. "
392-
+ "Please consider specifying a ghc explicitly.");
385+
(default: "Please consider specifying ${default} explicitly.");
393386

394387
# when we can provide a better message
395388
defaultCompilerNixNameWithWarning = warning:
396389
if final.haskell-nix ? userCompilerNixName
397-
then final.haskell-nix.userCompilerNixName
398-
else __trace (warning final.haskell-nix.defaultCompilerNixNameTODO)
399-
final.haskell-nix.defaultCompilerNixNameTODO;
390+
then
391+
__trace ("WARNING: defaultCompilerNixName is deprecated! "
392+
+ warning final.haskell-nix.userCompilerNixName)
393+
final.haskell-nix.userCompilerNixName
394+
else
395+
# Need to use something from 8.8.x as the default to build aarch64 native compiler:
396+
let compiler-nix-name =
397+
if final.targetPlatform.isAarch64 && final.buildPlatform.isAarch64
398+
then "ghc883"
399+
else "ghc865";
400+
in __trace ("WARNING: No compiler nix name specified! "
401+
+ warning compiler-nix-name) compiler-nix-name;
400402

401403
ghc = final.haskell-nix.compiler."${
402404
final.haskell-nix.defaultCompilerNixNameWithWarning (default:

overlays/haskell.nix

+6-2
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,9 @@ final: prev: {
620620

621621
# Add this to your tests to make all the dependencies of haskell.nix
622622
# are tested and cached.
623-
haskellNixRoots = final.haskell-nix.roots final.haskell-nix.defaultCompilerNixName;
623+
haskellNixRoots = final.haskell-nix.roots (final.haskell-nix.defaultCompilerNixNameWithWarning (default:
624+
"Please consider replacing `haskellNixRoots` with `p.roots` on your project "
625+
+ "or using `haskell-nix.roots \"${default}\"`."));
624626
roots = compiler-nix-name: final.recurseIntoAttrs {
625627
Level0 = roots' compiler-nix-name 0;
626628
Level1 = roots' compiler-nix-name 1;
@@ -629,7 +631,9 @@ final: prev: {
629631
Level2 = roots' compiler-nix-name 2;
630632
};
631633

632-
haskellNixRoots' = final.haskell-nix.roots' final.haskell-nix.defaultCompilerNixName;
634+
haskellNixRoots' = final.haskell-nix.roots' (final.haskell-nix.defaultCompilerNixNameWithWarning (default:
635+
"Please consider replacing `haskellNixRoots'` with `p.roots'` on your project "
636+
+ "or using `haskell-nix.roots' \"${default}\"`."));
633637
roots' = compiler-nix-name: ifdLevel:
634638
final.recurseIntoAttrs ({
635639
# Things that require no IFD to build

overlays/tools.nix

+2-2
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ in { haskell-nix = prev.haskell-nix // {
6969
args' = final.haskell-nix.haskellLib.versionOrArgsToArgs versionOrArgs;
7070
args = {
7171
compiler-nix-name = final.haskell-nix.defaultCompilerNixNameWithWarning (default:
72-
"WARNING: No compiler version specified for building the ${name} tool (using ${default}). "
73-
+ "Please consider using the `p.tool` or `p.tools` function on your project `p` (they will "
72+
"While building the ${name} tool (using ${default}). "
73+
+ "Please consider using the `p.tool` or `p.tools` function on your project (they will "
7474
+ "use the same ghc as the project) or using the `tools` argument of `shellFor` or "
7575
+ (if final.lib.isAttrs versionOrArgs
7676
then "adding `compiler-nix-name = \"${default}\";`"

0 commit comments

Comments
 (0)