@@ -655,15 +655,14 @@ final: prev: {
655
655
final . lib . listToAttrs (
656
656
map ( dname : { name = dname ; value = null ; } ) ( lookupPreExisting ( p . depends or p . components . lib . depends ) ) ) ;
657
657
} ) plan-json . install-plan ) ;
658
- to-key = p : p . id ;
659
658
lookupDependency = hsPkgs : d :
660
659
final . lib . optional ( by-id . ${ d } . type != "pre-existing" ) (
661
660
if by-id . ${ d } . component-name or "lib" == "lib"
662
- then hsPkgs . ${ to-key by-id . ${ d } } or hsPkgs . ${ by-id . ${ d } . pkg-name }
663
- else hsPkgs . ${ to-key by-id . ${ d } } . components . sublibs . ${ final . lib . removePrefix "lib:" by-id . ${ d } . component-name } ) ;
661
+ then hsPkgs . ${ d } or hsPkgs . ${ by-id . ${ d } . pkg-name }
662
+ else hsPkgs . ${ d } . components . sublibs . ${ final . lib . removePrefix "lib:" by-id . ${ d } . component-name } ) ;
664
663
lookupExeDependency = hsPkgs : d :
665
664
# Try to lookup by ID, but if that fails use the name (currently a different plan is used by pkgsBuildBuild when cross compiling)
666
- ( 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 } ;
665
+ ( hsPkgs . pkgsBuildBuild . ${ d } or hsPkgs . pkgsBuildBuild . ${ by-id . ${ d } . pkg-name } ) . components . exes . ${ final . lib . removePrefix "exe:" by-id . ${ d } . component-name } ;
667
666
lookupDependencies = hsPkgs : depends : exe-depends : {
668
667
depends = final . lib . concatMap ( lookupDependency hsPkgs ) depends ;
669
668
pre-existing = lookupPreExisting depends ;
@@ -679,6 +678,7 @@ final: prev: {
679
678
name = final . lib . removePrefix "${ prefix } :" n ;
680
679
value = ( if cabal2nixComponents == null then { } else cabal2nixComponents . ${ collectionName } . ${ name } ) // {
681
680
buildable = true ;
681
+ planned = final . lib . mkOverride 900 true ;
682
682
} // lookupDependencies hsPkgs c . depends c . exe-depends ;
683
683
in { inherit name value ; }
684
684
) ) components ) ) ;
@@ -687,10 +687,12 @@ final: prev: {
687
687
// final . lib . optionalAttrs ( components ? lib ) {
688
688
library = ( if cabal2nixComponents == null then { } else cabal2nixComponents . library ) // {
689
689
buildable = true ;
690
+ planned = final . lib . mkOverride 900 true ;
690
691
} // lookupDependencies hsPkgs components . lib . depends components . lib . exe-depends ;
691
692
} // final . lib . optionalAttrs ( components ? setup ) {
692
693
setup = {
693
694
buildable = true ;
695
+ planned = final . lib . mkOverride 900 true ;
694
696
} // lookupDependencies hsPkgs . pkgsBuildBuild ( components . setup . depends or [ ] ) ( components . setup . exe-depends or [ ] ) ;
695
697
} ;
696
698
callProjectResults = callCabalProjectToNix config ;
@@ -706,12 +708,12 @@ final: prev: {
706
708
packages = final . lib . listToAttrs (
707
709
final . lib . concatMap ( p :
708
710
final . lib . optional ( p . type == "pre-existing" ) {
709
- name = to-key p ;
711
+ name = p . id ;
710
712
value . revision = null ;
711
713
} ) plan-json . install-plan
712
714
++ final . lib . concatMap ( p :
713
715
final . lib . optional ( p . type == "configured" && ( p . style == "global" || p . style == "inplace" ) ) {
714
- name = to-key p ;
716
+ name = p . id ;
715
717
value . revision =
716
718
{ hsPkgs , ...} @args :
717
719
let cabal2nix = (
@@ -744,7 +746,7 @@ final: prev: {
744
746
packages = final . lib . listToAttrs (
745
747
final . lib . concatMap ( p :
746
748
final . lib . optional ( p . type == "configured" && p . style == "local" ) {
747
- name = to-key p ;
749
+ name = p . id ;
748
750
value =
749
751
{ hsPkgs , ...} @args :
750
752
let cabal2nix = import ( nixFilesDir + "/.plan.nix/${ p . pkg-name } .nix" ) ( args // { hsPkgs = { } ; } ) ;
@@ -776,94 +778,11 @@ final: prev: {
776
778
} ;
777
779
} ) plan-json . install-plan ) ;
778
780
} ) ;
779
- modules = [ ( { config , pkgs , ...} : {
780
- nonReinstallablePkgs = [ "rts" "base" "ghc-prim" "integer-gmp" "integer-simple" ]
781
- ++ final . lib . optionals ( builtins . compareVersions config . compiler . version "8.11" >= 0 ) [
782
- "ghc-bignum" ]
783
- ++ final . lib . optionals ( builtins . compareVersions config . compiler . version "9.9" >= 0 ) [
784
- "ghc-internal" ]
785
- ++ final . lib . optionals ( pkgs . stdenv . hostPlatform . isGhcjs ) ( [
786
- # ghci and its dependencies
787
- "ghci" "binary" "bytestring" "containers" "template-haskell" "array" "deepseq" "filepath" "ghc-boot" "ghc-boot-th" "ghc-heap" "transformers" "unix" "directory" "time" "ghc-platform" "os-string" ]
788
- ++ final . lib . optionals ( builtins . compareVersions config . compiler . version "8.11" < 0 ) [
789
- "ghcjs-prim" "ghcjs-th" ] ) ;
790
- } )
791
- ( { config , options , ...} : {
792
- use-package-keys = true ;
793
- package-keys = map ( p : p . pkg-name ) plan-json . install-plan ++ map ( p : to-key p ) plan-json . install-plan ;
794
- packages = final . lib . listToAttrs ( map ( p : {
795
- name = to-key p ;
796
- value = final . lib . modules . mkAliasDefinitions ( options . packages . ${ p . pkg-name } ) ;
797
- } ) ( final . lib . filter ( p : to-key p != p . pkg-name ) plan-json . install-plan ) ) ;
798
- } )
799
- ( { lib , ...} : {
800
- packages = final . lib . listToAttrs ( map ( p :
801
- let components =
802
- if p ? component-name
803
- then { ${ p . component-name } = { inherit ( p ) depends exe-depends ; } ; }
804
- else p . components or { } ;
805
- in {
806
- name = to-key p ;
807
- value . components = final . lib . mapAttrs ( type : x :
808
- if type == "library" || type == "setup"
809
- then { planned = lib . mkOverride 900 true ; }
810
- else
811
- final . lib . mapAttrs ( _ : _ : {
812
- planned = lib . mkOverride 900 true ;
813
- } ) x
814
- ) ( getComponents null { } p ) ;
815
- } ) plan-json . install-plan ) ;
816
- } )
817
- ( { config , ...} : {
818
- hsPkgs = builtins . removeAttrs ( builtins . mapAttrs ( packageName : packageTargets :
819
- let
820
- byVersion = builtins . groupBy ( x : x . pkg-version ) packageTargets ;
821
- versions = builtins . attrNames byVersion ;
822
- in if builtins . length versions != 1
823
- then let
824
- err = throw "Multiple versions for ${ packageName } ${ builtins . toJSON versions } " ;
825
- in {
826
- isRedirect = true ;
827
- identifier = { name = packageName ; version = err ; } ;
828
- components = err ;
829
- checks = err ;
830
- }
831
- else let
832
- componentsByName = builtins . listToAttrs ( map ( x : { name = x . component-name ; value = x . available ; } ) packageTargets ) ;
833
- lookupComponent = collectionName : name : available :
834
- let attrPath =
835
- if collectionName == ""
836
- then "${ packageName } .components.library"
837
- else "${ packageName } .components.${ collectionName } .${ name } " ;
838
- in if builtins . length available != 1
839
- then throw "Multiple avaialble targets for ${ attrPath } "
840
- else if builtins . isString ( builtins . head available )
841
- then throw "${ builtins . head available } looking for ${ attrPath } "
842
- else if collectionName == ""
843
- then config . hsPkgs . ${ ( builtins . head available ) . id } . components . library
844
- else config . hsPkgs . ${ ( builtins . head available ) . id } . components . ${ collectionName } . ${ name } ;
845
- componentsWithPrefix = collectionName : prefix :
846
- final . lib . listToAttrs ( final . lib . concatLists ( final . lib . mapAttrsToList ( n : available :
847
- final . lib . optional ( final . lib . hasPrefix "${ prefix } :" n && ( builtins . length available != 1 || ! builtins . elem ( builtins . head available ) [ "TargetNotBuildable" "TargetNotLocal" ] ) ) (
848
- let
849
- name = final . lib . removePrefix "${ prefix } :" n ;
850
- value = lookupComponent collectionName name available ;
851
- in { inherit name value ; }
852
- ) ) componentsByName ) ) ;
853
- in rec {
854
- isRedirect = true ;
855
- identifier = rec { name = packageName ; version = builtins . head versions ; id = "${ name } -${ version } " ; } ;
856
- components =
857
- final . lib . mapAttrs componentsWithPrefix haskellLib . componentPrefix
858
- // final . lib . optionalAttrs ( componentsByName ? lib ) {
859
- library = lookupComponent "" "" componentsByName . lib ;
860
- } ;
861
- checks = final . recurseIntoAttrs ( builtins . mapAttrs
862
- ( _ : d : haskellLib . check d )
863
- ( final . lib . filterAttrs ( _ : d : d . config . doCheck ) components . tests ) ) ;
864
- } )
865
- ( builtins . groupBy ( x : x . pkg-name ) plan-json . targets ) ) config . preExistingPkgs ;
866
- } )
781
+ modules = [
782
+ { inherit plan-json ; }
783
+ ( import ../modules/install-plan/non-reinstallable.nix )
784
+ ( import ../modules/install-plan/override-package-by-name.nix )
785
+ ( import ../modules/install-plan/redirect.nix )
867
786
] ;
868
787
} ;
869
788
buildProject = if final . stdenv . hostPlatform != final . stdenv . buildPlatform
0 commit comments