on iko/ghcjs-patch-master help sign in
fix the way the isProject package flag is set (#1003)
22ad57cHamish Mackenzie
lib/import-and-filter-project.nix+35−22
@@ -24,30 +24,43 @@ in project // {
24 packages = pkgs.lib.attrsets.mapAttrs (name: value:
24 packages = pkgs.lib.attrsets.mapAttrs (name: value:
25 if builtins.isFunction value
25 if builtins.isFunction value
26 then value
26 then value
27− else {...}@args:
27+ else {...}@args: with pkgs.lib.strings;
28+ let
28− let oldPkg = import value args;
29+ oldPkg = import value args;
29− packageSrc = if !pkgs.lib.strings.hasPrefix (toString projectNix) (toString oldPkg.src.content)
30+ # When the package src is in the project dir, this is the subDir it is in.
30− then toString oldPkg.src.content
31− else let
32− subDir = pkgs.lib.strings.removePrefix "/" (
33− pkgs.lib.strings.removePrefix (toString projectNix)
31+ subDir = removePrefix "/" (removePrefix (toString projectNix)
34− (toString oldPkg.src.content));
32+ (toString oldPkg.src.content));
35− srcRepoPrefix = projectSubDir'' + ".source-repository-packages/";
33+ srcRepoPrefix = projectSubDir'' + ".source-repository-packages/";
34+
35+ packageInfo =
36+ if !hasPrefix (toString projectNix) (toString oldPkg.src.content)
37+ then {
38+ # Source location does not match project prefix
39+ isProject = false;
40+ packageSrc = toString oldPkg.src.content;
41+ }
36− in if pkgs.lib.strings.hasPrefix srcRepoPrefix subDir
42+ else if hasPrefix srcRepoPrefix subDir
37− then
43+ then {
44+ # The source is from a source repository
45+ isProject = false;
38− pkgs.lib.lists.elemAt sourceRepos (
46+ packageSrc = pkgs.lib.lists.elemAt sourceRepos (
39− pkgs.lib.strings.toInt (pkgs.lib.strings.removePrefix srcRepoPrefix subDir))
47+ toInt (removePrefix srcRepoPrefix subDir));
48+ }
49+ else {
50+ # Source does match project prefix and it is not from a source repository
51+ isProject = true;
40− else haskellLib.appendSubDir {
52+ packageSrc = haskellLib.appendSubDir {
41− src = srcRoot;
53+ src = srcRoot;
42− inherit subDir;
54+ inherit subDir;
43− includeSiblings = true; # Filtering sibling dirs of the package dir is done in the
55+ includeSiblings = true; # Filtering sibling dirs of the package dir is done in the
44− # component builder so that relative paths can be used to
56+ # component builder so that relative paths can be used to
45− # reference project directories not in the package subDir.
57+ # reference project directories not in the package subDir.
58+ };
46− };
59+ };
47 in oldPkg // {
60 in oldPkg // {
48− src = (pkgs.lib).mkDefault packageSrc;
61+ src = (pkgs.lib).mkDefault packageInfo.packageSrc;
49 package = oldPkg.package // {
62 package = oldPkg.package // {
50− isProject = (pkgs.lib).mkDefault true;
63+ isProject = (pkgs.lib).mkDefault packageInfo.isProject;
51 };
64 };
52 }) old;
65 }) old;
53 };
66 };