mirror of
https://github.com/ilyakooo0/haskell.nix.git
synced 2024-10-26 09:37:17 +03:00
Fix stack.yaml filtering when resolver file is in a subdirectory (#943)
* Fix stack.yaml filtering when resolver file is in a subdirectory `maybeCleanedSource` tries to include the resolver file into the cleaned source, if a resolver is specified, but it was only working when the file was in the root of the project, because all directories would be filtered out. * fixup! Fix stack.yaml filtering when resolver file is in a subdirectory Fix calculating relPath for paths using subDir * Add test case for local stack snapshot located in a subdirectory
This commit is contained in:
parent
a62a254683
commit
99fdad7640
@ -32,8 +32,18 @@ let
|
||||
then haskellLib.cleanSourceWith {
|
||||
inherit src;
|
||||
filter = path: type:
|
||||
pkgs.lib.hasSuffix ("/" + stackYaml) path
|
||||
|| (resolver != null && pkgs.lib.hasSuffix ("/" + resolver) path);
|
||||
let
|
||||
origSrc = if src ? _isLibCleanSourceWith then src.origSrc else src;
|
||||
origSubDir = if src ? _isLibCleanSourceWithEx then src.origSubDir else "";
|
||||
relPath = pkgs.lib.removePrefix (toString origSrc + origSubDir + "/") path;
|
||||
|
||||
# checks if path1 is a parent directory for path2
|
||||
isParent = path1: path2: pkgs.lib.hasPrefix "${path1}/" path2;
|
||||
|
||||
in
|
||||
(relPath == stackYaml)
|
||||
|| (resolver != null && (relPath == resolver || isParent relPath resolver))
|
||||
;
|
||||
}
|
||||
else src;
|
||||
|
||||
|
@ -158,6 +158,7 @@ let
|
||||
builder-haddock = callTest ./builder-haddock {};
|
||||
stack-simple = callTest ./stack-simple {};
|
||||
stack-local-resolver = callTest ./stack-local-resolver {};
|
||||
stack-local-resolver-subdir = callTest ./stack-local-resolver-subdir {};
|
||||
stack-remote-resolver = callTest ./stack-remote-resolver {};
|
||||
shell-for-setup-deps = callTest ./shell-for-setup-deps { inherit compiler-nix-name; };
|
||||
setup-deps = import ./setup-deps { inherit pkgs compiler-nix-name; };
|
||||
|
2
test/stack-local-resolver-subdir/.gitignore
vendored
Normal file
2
test/stack-local-resolver-subdir/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
/.stack-work/
|
||||
/*.cabal
|
14
test/stack-local-resolver-subdir/default.nix
Normal file
14
test/stack-local-resolver-subdir/default.nix
Normal file
@ -0,0 +1,14 @@
|
||||
{ project', recurseIntoAttrs, testSrc }:
|
||||
|
||||
let
|
||||
project = project' {
|
||||
src = testSrc "stack-local-resolver-subdir";
|
||||
};
|
||||
packages = project.hsPkgs;
|
||||
|
||||
in recurseIntoAttrs {
|
||||
ifdInputs = {
|
||||
inherit (project) stack-nix;
|
||||
};
|
||||
inherit (packages.stack-local-resolver.components) library;
|
||||
}
|
7
test/stack-local-resolver-subdir/package.yaml
Normal file
7
test/stack-local-resolver-subdir/package.yaml
Normal file
@ -0,0 +1,7 @@
|
||||
name: stack-local-resolver
|
||||
|
||||
dependencies:
|
||||
- base
|
||||
|
||||
library:
|
||||
source-dirs: src
|
4
test/stack-local-resolver-subdir/snapshot/snapshot.yaml
Normal file
4
test/stack-local-resolver-subdir/snapshot/snapshot.yaml
Normal file
@ -0,0 +1,4 @@
|
||||
name: local-snapshot
|
||||
resolver: lts-14.13
|
||||
|
||||
packages: []
|
6
test/stack-local-resolver-subdir/src/Lib.hs
Normal file
6
test/stack-local-resolver-subdir/src/Lib.hs
Normal file
@ -0,0 +1,6 @@
|
||||
module Lib
|
||||
( someFunc
|
||||
) where
|
||||
|
||||
someFunc :: IO ()
|
||||
someFunc = putStrLn "someFunc"
|
4
test/stack-local-resolver-subdir/stack.yaml
Normal file
4
test/stack-local-resolver-subdir/stack.yaml
Normal file
@ -0,0 +1,4 @@
|
||||
resolver: snapshot/snapshot.yaml
|
||||
|
||||
packages:
|
||||
- .
|
Loading…
Reference in New Issue
Block a user