Skip to content

Commit fc5a5b4

Browse files
authored
cabalProject': Consider cabalProjectLocal even if cabalProject argument is null (#1588)
* `cabalProject'`: Consider `cabalProjectLocal` even if `cabalProject` argument is null * Respond to review
1 parent a1fda09 commit fc5a5b4

File tree

2 files changed

+9
-14
lines changed

2 files changed

+9
-14
lines changed

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

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -126,17 +126,15 @@ let
126126
# access to the store is restricted. If origSrc was already in the store
127127
# you can pass the project in as a string.
128128
rawCabalProject =
129-
if cabalProject != null
130-
then cabalProject + (
131-
if cabalProjectLocal != null
132-
then ''
133-
134-
-- Added from cabalProjectLocal argument to cabalProject
135-
${cabalProjectLocal}
136-
''
137-
else ""
138-
)
139-
else null;
129+
# Even if `cabal.project` doesn't exist, `cabal.project.local` is still used by cabal.
130+
# We tested this: https://github.com/input-output-hk/haskell.nix/pull/1588
131+
if cabalProject == null && cabalProjectLocal == null
132+
then null
133+
else (
134+
# like fmap
135+
let f = g: x: if x == null then "" else g x; in
136+
f (x: x) cabalProject + f (x: "\n-- Added from cabalProjectLocal argument to cabalProject\n${x}") cabalProjectLocal
137+
);
140138

141139
cabalProjectIndexState =
142140
if rawCabalProject != null

modules/hackage-project.nix

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@ in {
2626
# Avoid readDir and readFile IFD functions looking for these files in the hackage source
2727
# `mkOverride 1100` means this will be used in preference to the mkOption default,
2828
# but a `mkDefault` can still override this.
29-
cabalProject = lib.mkOverride 1100 ''
30-
packages: .
31-
'';
3229
cabalProjectLocal = lib.mkOverride 1100 null;
3330
cabalProjectFreeze = lib.mkOverride 1100 null;
3431
src =

0 commit comments

Comments
 (0)