File tree Expand file tree Collapse file tree 4 files changed +57
-13
lines changed Expand file tree Collapse file tree 4 files changed +57
-13
lines changed Original file line number Diff line number Diff line change
1
+ { lib , config , pkgs , ... } :
2
+
3
+ with lib ;
4
+
5
+ ############################################################################
6
+ # this is an attempt to use mkMerge for combining package options
7
+ ############################################################################
8
+ let
9
+ haskellLib = let hl = import ../lib { inherit lib ; haskellLib = hl ; } ; in hl ;
10
+
11
+ subComponents = packageConfig : sub : attrValues ( packageConfig . components . ${ sub } or { } ) ;
12
+
13
+ allComponent = packageConfig : {
14
+ components . all = mkMerge ( [ packageConfig . components . library ] ++
15
+ concatMap ( subComponents packageConfig ) haskellLib . subComponentTypes ) ;
16
+ } ;
17
+
18
+ in {
19
+ # Does not work -- infinite recursion
20
+ # packages = mapAttrs (name: packageConfig: allComponent packageConfig) config.packages;
21
+
22
+ # A single package works
23
+ # packages.cabal-simple = allComponent (config.packages.cabal-simple);
24
+ }
Original file line number Diff line number Diff line change @@ -175,18 +175,20 @@ in {
175
175
type = attrsOf ( componentType { } ) ;
176
176
default = { } ;
177
177
} ;
178
+ # Try merging component options by setting the default to mkMerge [...].
179
+ # This does not work.
178
180
all = let
179
- subComponentsDepends = sub : concatLists
180
- ( mapAttrsToList ( _ : c : c . depends or [ ] ) config . components . ${ sub } or { } ) ;
181
- default = {
182
- depends = config . components . library . depends ++
183
- concatMap subComponentsDepends haskellLib . subComponentTypes ;
184
- } ;
181
+ subComponents = sub : attrValues ( config . components . ${ sub } or { } ) ;
182
+ default = mkMerge ( [ config . components . library ] ++
183
+ concatMap subComponents haskellLib . subComponentTypes ) ;
185
184
in mkOption {
186
- type = componentType default ;
185
+ type = componentType { } ;
187
186
inherit default ;
188
- defaultText = "The merged dependencies of all other components" ;
187
+ defaultText = "The merged options of all other components" ;
189
188
} ;
189
+ # all = mkOption {
190
+ # type = componentType {};
191
+ # };
190
192
} ;
191
193
192
194
name = mkOption {
Original file line number Diff line number Diff line change @@ -71,6 +71,8 @@ in pkgs.lib.evalModules {
71
71
# Supplies metadata
72
72
./modules/cabal.nix
73
73
74
+ ./modules/all-component.nix
75
+
74
76
# Converts config.packages into config.hsPkgs
75
77
# Replace this with compat-driver.nix to use nixpkgs haskell build infra
76
78
./modules/component-driver.nix
Original file line number Diff line number Diff line change 39
39
buildInputs = ( oldAttrs . buildInputs or [ ] ) ++ [ pkgs . cabal-install ] ;
40
40
} ) ;
41
41
42
+
43
+ package = packages . test-with-packages ;
44
+ inherit ( package . components ) library ;
45
+
46
+ pkgId = p : "${ p . identifier . name } -${ p . identifier . version } " ;
47
+ showDepends = component : concatMapStringsSep " " pkgId component . depends ;
48
+
42
49
in
43
50
stdenv . mkDerivation {
44
51
name = "with-packages-test" ;
52
+ libraryDepends = showDepends pkgSet . config . packages . test-with-packages . components . library ;
53
+ allDepends = showDepends pkgSet . config . packages . test-with-packages . components . all ;
45
54
46
- buildCommand = let
47
- package = packages . test-with-packages ;
48
- inherit ( package . components ) library ;
49
- in ''
55
+ buildCommand = ''
50
56
########################################################################
51
57
# test with-packages
52
58
59
+ printf "checking merging of the 'all' component depends ... " >& 2
60
+ if [ -n "$libraryDepends" -a "$libraryDepends" = "$allDepends" ]; then
61
+ echo "PASS" >& 2
62
+ else
63
+ echo "FAIL" >& 2
64
+ echo "libraryDepends = $libraryDepends"
65
+ echo "allDepends = $allDepends"
66
+ exit 1
67
+ fi
68
+
53
69
printf "checking that the 'all' component works... " >& 2
54
70
echo ${ package . components . all } >& 2
55
71
62
78
63
79
printf "checking that components.library.env has the dependencies... " >& 2
64
80
${ library . env } /bin/runghc ${ ./Point.hs }
65
- # echo >& 2
81
+ echo >& 2
66
82
67
83
touch $out
68
84
'' ;
You can’t perform that action at this time.
0 commit comments