35
35
] ;
36
36
37
37
foldrAttrVals = f : z : attrs :
38
- lib . foldr ( g : acc : g acc ) z ( lib . mapAttrsToList ( _name : f ) attrs ) ;
38
+ lib . foldr f z ( builtins . attrValues attrs ) ;
39
39
40
40
foldComponents = tys : f : z : conf :
41
41
let
91
91
isExe componentId
92
92
|| isTest componentId
93
93
|| isBenchmark componentId ;
94
- mayHaveExecutable = componentId :
95
- isExecutableType componentId ;
94
+ mayHaveExecutable = isExecutableType ;
96
95
97
96
# Was there a reference to the package source in the `cabal.project` or `stack.yaml` file.
98
97
# This is used to make the default `packages` list for `shellFor`.
99
98
isLocalPackage = p : p . isLocal or false ;
100
- selectLocalPackages = ps : lib . filterAttrs ( n : p : p != null && isLocalPackage p ) ps ;
99
+ selectLocalPackages = lib . filterAttrs ( n : p : p != null && isLocalPackage p ) ;
101
100
102
101
# if it's a project package it has a src attribute set with an origSubDir attribute.
103
102
# project packages are a subset of localPackages
104
103
isProjectPackage = p : p . isProject or false ;
105
- selectProjectPackages = ps : lib . filterAttrs ( n : p : p != null && isLocalPackage p && isProjectPackage p ) ps ;
104
+ selectProjectPackages = lib . filterAttrs ( n : p : p != null && isLocalPackage p && isProjectPackage p ) ;
106
105
107
106
# Format a componentId as it should appear as a target on the
108
107
# command line of the setup script.
133
132
## flatLibDepends :: Component -> [Package]
134
133
flatLibDepends = component :
135
134
let
136
- makePairs = map ( p : rec { key = val . name ; val = ( p . components . library or p ) ; } ) ;
135
+ makePairs = map ( p : rec { key = val . name ; val = p . components . library or p ; } ) ;
137
136
closure = builtins . genericClosure {
138
137
startSet = makePairs component . depends ;
139
138
operator = { val , ...} : makePairs val . config . depends ;
@@ -427,35 +426,24 @@ in {
427
426
# Flake package names that are flat and match the cabal component names.
428
427
mkFlakePackages = haskellPackages : builtins . listToAttrs (
429
428
lib . concatLists ( lib . mapAttrsToList ( packageName : package :
430
- lib . optional ( package . components ? library )
431
- { name = "${ packageName } :lib:${ packageName } " ; value = package . components . library ; }
432
- ++ lib . mapAttrsToList ( n : v :
433
- { name = "${ packageName } :lib:${ n } " ; value = v ; } )
434
- ( package . components . sublibs )
435
- ++ lib . mapAttrsToList ( n : v :
436
- { name = "${ packageName } :exe:${ n } " ; value = v ; } )
437
- ( package . components . exes )
438
- ++ lib . mapAttrsToList ( n : v :
439
- { name = "${ packageName } :test:${ n } " ; value = v ; } )
440
- ( package . components . tests )
441
- ++ lib . mapAttrsToList ( n : v :
442
- { name = "${ packageName } :bench:${ n } " ; value = v ; } )
443
- ( package . components . benchmarks )
444
- ) haskellPackages ) ) ;
429
+ builtins . groupBy
430
+ ( c : c . passthru . identifier . component-id )
431
+ ( ( lib . optional ( package . components ? library ) package . components . library )
432
+ ++ package . components . sublibs
433
+ ++ package . components . exes
434
+ ++ package . components . tests
435
+ ++ package . components . benchmarks )
436
+ ) haskellPackages ) ) ;
445
437
446
438
# Flake package names that are flat and match the cabal component names.
447
439
mkFlakeApps = haskellPackages : builtins . listToAttrs (
448
440
lib . concatLists ( lib . mapAttrsToList ( packageName : package :
449
- lib . mapAttrsToList ( n : v :
450
- { name = "${ packageName } :exe:${ n } " ; value = { type = "app" ; program = v . exePath ; } ; } )
451
- ( package . components . exes )
452
- ++ lib . mapAttrsToList ( n : v :
453
- { name = "${ packageName } :test:${ n } " ; value = { type = "app" ; program = v . exePath ; } ; } )
454
- ( package . components . tests )
455
- ++ lib . mapAttrsToList ( n : v :
456
- { name = "${ packageName } :benchmark:${ n } " ; value = { type = "app" ; program = v . exePath ; } ; } )
457
- ( package . components . benchmarks )
458
- ) haskellPackages ) ) ;
441
+ builtins . groupBy
442
+ ( c : c . passthru . identifier . component-id )
443
+ ( package . components . exes
444
+ ++ package . components . tests
445
+ ++ package . components . benchmarks )
446
+ ) haskellPackages ) ) ;
459
447
460
448
# Flatten the result of collectChecks or collectChecks' for use in flake `checks`
461
449
mkFlakeChecks = allChecks : builtins . listToAttrs (
464
452
lib . optionals ( lib . isAttrs checks ) (
465
453
lib . mapAttrsToList ( n : v :
466
454
{ name = "${ packageName } :test:${ n } " ; value = v ; } )
467
- ( lib . filterAttrs ( _ : v : lib . isDerivation v ) checks ) )
455
+ ( lib . filterAttrs ( _ : lib . isDerivation ) checks ) )
468
456
) allChecks ) ) ;
469
457
470
458
removeRecurseForDerivations = x :
@@ -494,11 +482,11 @@ in {
494
482
}
495
483
# Build the plan-nix and check it if materialized
496
484
// lib . optionalAttrs ( checkedProject ? plan-nix ) {
497
- plan-nix = checkedProject . plan-nix ;
485
+ inherit ( checkedProject ) plan-nix ;
498
486
}
499
487
# Build the stack-nix and check it if materialized
500
488
// lib . optionalAttrs ( checkedProject ? stack-nix ) {
501
- stack-nix = checkedProject . stack-nix ;
489
+ inherit ( checkedProject ) stack-nix ;
502
490
} ;
503
491
504
492
mkFlake = project : {
0 commit comments