Skip to content

Commit b873d6f

Browse files
authored
Fix building stack tool (input-output-hk#2004)
Avoid pantry 0.9 in versions without commercialhaskell/stack#6187 This also: * moves the `optparse-applicative` upper bound into `modules/hackage-quirks.nix` * Fixes `readIfExists` in `modules/cabal-project.nix`. * Removes `readIfExists` from `lib/call-cabal-project-to-nix.nix`.
1 parent d215a47 commit b873d6f

File tree

4 files changed

+12
-25
lines changed

4 files changed

+12
-25
lines changed

build.nix

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,9 @@ in rec {
4646
} // pkgs.lib.optionalAttrs (__compareVersions haskell.compiler.${compiler-nix-name}.version "9.6" < 0) {
4747
stack =
4848
tool compiler-nix-name "stack" {
49-
cabalProjectLocal = ''
50-
constraints: optparse-applicative <0.18
51-
'';
5249
version =
5350
if __compareVersions haskell.compiler.${compiler-nix-name}.version "9.2" < 0
54-
then "2.9.3"
51+
then "2.9.3.1"
5552
else "2.11.1";
5653
inherit evalPackages;
5754
};

lib/call-cabal-project-to-nix.nix

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,4 @@
11
{ pkgs, runCommand, cacert, index-state-hashes, haskellLib }@defaults:
2-
let readIfExists = src: fileName:
3-
# Using origSrcSubDir bypasses any cleanSourceWith.
4-
# `lookForCabalProject` allows us to avoid looking in source from hackage
5-
# for cabal.project files. It is set in `modules/hackage-project.nix`.
6-
let origSrcDir = src.origSrcSubDir or src;
7-
in
8-
if (src.lookForCabalProject or true) && builtins.elem ((__readDir origSrcDir)."${fileName}" or "") ["regular" "symlink"]
9-
then __readFile (origSrcDir + "/${fileName}")
10-
else null;
11-
in
122
{ name ? src.name or null # optional name for better error messages
133
, src
144
, materialized-dir ? ../materialized
@@ -19,9 +9,9 @@ in
199
, materialized ? null # Location of a materialized copy of the nix files
2010
, checkMaterialization ? null # If true the nix files will be generated used to check plan-sha256 and material
2111
, cabalProjectFileName ? "cabal.project"
22-
, cabalProject ? readIfExists src cabalProjectFileName
23-
, cabalProjectLocal ? readIfExists src "${cabalProjectFileName}.local"
24-
, cabalProjectFreeze ? readIfExists src "${cabalProjectFileName}.freeze"
12+
, cabalProject ? null
13+
, cabalProjectLocal ? null
14+
, cabalProjectFreeze ? null
2515
, caller ? "callCabalProjectToNix" # Name of the calling function for better warning messages
2616
, compilerSelection ? p: p.haskell-nix.compiler
2717
, ghc ? null # Deprecated in favour of `compiler-nix-name`

modules/cabal-project.nix

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@
22
with lib;
33
with types;
44
let readIfExists = src: fileName:
5+
# Using origSrcSubDir bypasses any cleanSourceWith.
6+
# `lookForCabalProject` allows us to avoid looking in source from hackage
7+
# for cabal.project files. It is set in `modules/hackage-project.nix`.
58
let origSrcDir = src.origSrcSubDir or src;
69
in
7-
if builtins.elem ((__readDir origSrcDir)."${fileName}" or "") ["regular" "symlink"]
10+
if (src.lookForCabalProject or true) && builtins.elem ((__readDir origSrcDir)."${fileName}" or "") ["regular" "symlink"]
811
then __readFile (origSrcDir + "/${fileName}")
912
else null;
1013
in {

modules/hackage-quirks.nix

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,13 @@ in [
4343
}
4444
)
4545

46-
# The latest version of stack (2.9.1) in hackage fails to build because the
47-
# of version of rio-prettyprint (recently released 0.1.4.0) chosen by cabal.
48-
# https://github.com/commercialhaskell/stack/issues/5963
46+
# Avoid pantry 0.9 in versions without https://github.com/commercialhaskell/stack/pull/6187
47+
# Also avoid optparse-applicative 0.18
4948
({config, lib, pkgs, ...}:
5049
{ _file = "haskell.nix/overlays/hackage-quirks.nix#stack"; } //
51-
lib.mkIf (config.name == "stack" && builtins.compareVersions config.version "2.9.3" <= 0) {
50+
lib.mkIf (config.name == "stack" && builtins.compareVersions config.version "2.11.1" <= 0) {
5251
cabalProjectLocal = ''
53-
constraints: unix-compat <0.7${
54-
lib.optionalString (builtins.compareVersions config.version "2.9.1" <= 0)
55-
" rio-prettyprint <0.1.4.0"}
52+
constraints: pantry <0.9, optparse-applicative <0.18
5653
'';
5754
}
5855
)

0 commit comments

Comments
 (0)