Skip to content

Commit 278df11

Browse files
committed
Per component pre-exisiting depends
1 parent cfe3bf2 commit 278df11

File tree

2 files changed

+25
-15
lines changed

2 files changed

+25
-15
lines changed

builder/make-config-files.nix

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
let
66
# Sort and remove duplicates from nonReinstallablePkgs.
77
# That way changes to the order of nonReinstallablePkgs does not require rebuilds.
8-
nonReinstallablePkgs' = __attrNames (lib.genAttrs nonReinstallablePkgs (x: x));
8+
nonReinstallablePkgs' = __attrNames (lib.genAttrs nonReinstallablePkgs (x: x))
9+
++ lib.filter (x: builtins.isString x) component.depends;
910

1011
ghc = if enableDWARF then defaults.ghc.dwarf else defaults.ghc;
1112

@@ -55,7 +56,7 @@ let
5556
map chooseDrv (
5657
(if enableDWARF then (x: map (p: p.dwarf or p) x) else x: x)
5758
((if needsProfiling then (x: map (p: p.profiled or p) x) else x: x)
58-
(map haskellLib.dependToLib component.depends))
59+
(map haskellLib.dependToLib (lib.filter (x: !builtins.isString x) component.depends)))
5960
)
6061
);
6162
script = ''

overlays/haskell.nix

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -650,13 +650,24 @@ final: prev: {
650650
builtins.unsafeDiscardStringContext (
651651
builtins.readFile (callProjectResults.projectNix + "/plan.json")));
652652
by-id = final.lib.listToAttrs (map (x: { name = x.id; value = x; }) plan-json.install-plan);
653-
to-key = p: if p.type == "pre-existing"
654-
then p.pkg-name
655-
else p.id;
653+
lookupPreExisting = depends:
654+
final.lib.concatMap (d: builtins.attrNames pre-existing-depends.${d}) depends;
655+
pre-existing-depends =
656+
final.lib.listToAttrs (map (p: {
657+
name = p.id;
658+
value = final.lib.optionalAttrs (p.type == "pre-existing") { ${p.pkg-name} = null; } //
659+
final.lib.listToAttrs (
660+
map (dname: { name = dname; value = null; }) (lookupPreExisting (p.depends or p.components.lib.depends)));
661+
}) plan-json.install-plan);
662+
to-key = p: p.id;
656663
lookupDependency = hsPkgs: d:
657-
if by-id.${d}.component-name or "lib" == "lib"
658-
then hsPkgs.${to-key by-id.${d}} or hsPkgs.${by-id.${d}.pkg-name}
659-
else hsPkgs.${to-key by-id.${d}}.components.sublibs.${final.lib.removePrefix "lib:" by-id.${d}.component-name};
664+
final.lib.optional (by-id.${d}.type != "pre-existing") (
665+
if by-id.${d}.component-name or "lib" == "lib"
666+
then hsPkgs.${to-key by-id.${d}} or hsPkgs.${by-id.${d}.pkg-name}
667+
else hsPkgs.${to-key by-id.${d}}.components.sublibs.${final.lib.removePrefix "lib:" by-id.${d}.component-name});
668+
lookupDependencies = hsPkgs: depends:
669+
final.lib.concatMap (lookupDependency hsPkgs) depends
670+
++ lookupPreExisting depends;
660671
lookupExeDependency = hsPkgs: d:
661672
# Try to lookup by ID, but if that fails use the name (currently a different plan is used by pkgsBuildBuild when cross compiling)
662673
(hsPkgs.pkgsBuildBuild.${to-key by-id.${d}} or hsPkgs.pkgsBuildBuild.${by-id.${d}.pkg-name}).components.exes.${final.lib.removePrefix "exe:" by-id.${d}.component-name};
@@ -670,7 +681,7 @@ final: prev: {
670681
name = final.lib.removePrefix "${prefix}:" n;
671682
value = (if cabal2nixComponents == null then {} else cabal2nixComponents.${collectionName}.${name}) // {
672683
buildable = true;
673-
depends = map (lookupDependency hsPkgs) c.depends;
684+
depends = lookupDependencies hsPkgs c.depends;
674685
build-tools = map lookupExeDependency c.exe-depends;
675686
};
676687
in { inherit name value; }
@@ -680,7 +691,7 @@ final: prev: {
680691
// final.lib.optionalAttrs (components ? lib) {
681692
library = (if cabal2nixComponents == null then {} else cabal2nixComponents.library) // {
682693
buildable = true;
683-
depends = map (lookupDependency hsPkgs) components.lib.depends;
694+
depends = lookupDependencies hsPkgs components.lib.depends;
684695
build-tools = map (lookupExeDependency hsPkgs) components.lib.exe-depends;
685696
};
686697
};
@@ -721,7 +732,7 @@ final: prev: {
721732
package = cabal2nix.package // {
722733
identifier = { name = p.pkg-name; version = p.pkg-version; };
723734
isProject = false;
724-
setup-depends = map (lookupDependency hsPkgs.pkgsBuildBuild) (p.components.setup.depends or []);
735+
setup-depends = lookupDependencies hsPkgs.pkgsBuildBuild (p.components.setup.depends or []);
725736
# TODO = map (lookupExeDependency hsPkgs.pkgsBuildBuild) (p.components.setup.exe-depends or []);
726737
};
727738
};
@@ -751,16 +762,14 @@ final: prev: {
751762
package = cabal2nix.package // {
752763
identifier = { name = p.pkg-name; version = p.pkg-version; };
753764
isProject = true;
754-
setup-depends = map (lookupDependency hsPkgs.pkgsBuildBuild) (p.components.setup.depends or []);
765+
setup-depends = lookupDependencies hsPkgs.pkgsBuildBuild (p.components.setup.depends or []);
755766
# TODO = map (lookupExeDependency hsPkgs.pkgsBuildBuild) (p.components.setup.exe-depends or []);
756767
};
757768
};
758769
}) plan-json.install-plan);
759770
});
760771
modules = [{
761-
preExistingPkgs =
762-
final.lib.concatMap (p:
763-
final.lib.optional (p.type == "pre-existing") p.pkg-name) plan-json.install-plan;
772+
preExistingPkgs = [];
764773
}
765774
({config, ...}: {
766775
packages = final.lib.listToAttrs (map (p: {

0 commit comments

Comments
 (0)