Skip to content

Commit 6cb0bbe

Browse files
authored
Preserve overridden Stack compiler (fixes #2039) (#2041)
* Add test case for #2039 * Preserve overridden Stack compiler (fixes #2039)
1 parent 101b26a commit 6cb0bbe

File tree

8 files changed

+39
-3
lines changed

8 files changed

+39
-3
lines changed

lib/import-and-filter-project.nix

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ let
1717
projectSubDir'' = if projectSubDir == "" then "" else projectSubDir + "/"; # With trailing /
1818
project = import "${projectNix}${projectSubDir'}";
1919
in project // {
20-
extras = hackage: let old = (project.extras hackage).packages; in {
20+
extras = hackage: let
21+
old = project.extras hackage;
22+
in old // {
2123
packages = pkgs.lib.attrsets.mapAttrs (name: value:
2224
if builtins.isFunction value
2325
then value
@@ -56,6 +58,6 @@ in project // {
5658
package = oldPkg.package // {
5759
isProject = (pkgs.lib).mkDefault packageInfo.isProject;
5860
};
59-
}) old;
61+
}) old.packages;
6062
};
6163
}

overlays/haskell.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ final: prev: {
121121
else module;
122122
removeSpecialPackages = ps: removeAttrs ps [ "$locals" "$targets" "$everything" ];
123123
in mkPkgSet {
124-
pkg-def = excludeBootPackages null pkg-def;
124+
pkg-def = excludeBootPackages compiler.nix-name pkg-def;
125125
pkg-def-extras = [ stack-pkgs.extras
126126
final.ghc-boot-packages.${compiler.nix-name}
127127
]

test/default.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ let
175175
with-packages = callTest ./with-packages { inherit util; };
176176
builder-haddock = callTest ./builder-haddock {};
177177
stack-simple = callTest ./stack-simple {};
178+
stack-compiler = callTest ./stack-compiler {};
178179
stack-local-resolver = callTest ./stack-local-resolver {};
179180
stack-local-resolver-subdir = callTest ./stack-local-resolver-subdir {};
180181
stack-remote-resolver = callTest ./stack-remote-resolver {};

test/stack-compiler/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/.stack-work/

test/stack-compiler/Lib.hs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module Lib where
2+
3+
foo :: Int
4+
foo = 1

test/stack-compiler/default.nix

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{ stackProject', recurseIntoAttrs, testSrc, compiler-nix-name, evalPackages }:
2+
3+
let
4+
project = stackProject' {
5+
src = testSrc "stack-compiler";
6+
inherit evalPackages;
7+
};
8+
packages = project.hsPkgs;
9+
10+
in recurseIntoAttrs {
11+
meta.disabled = compiler-nix-name != "ghc947";
12+
ifdInputs = {
13+
inherit (project) stack-nix;
14+
};
15+
inherit (packages.stack-compiler.components) library;
16+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
cabal-version: 3.8
2+
name: stack-compiler
3+
version: 0.0.1
4+
5+
library
6+
exposed-modules: Lib
7+
build-depends: base

test/stack-compiler/stack.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
resolver: lts-21.9
2+
compiler: ghc-9.4.7
3+
compiler-check: match-exact
4+
packages:
5+
- .

0 commit comments

Comments
 (0)