1
- { pkgs
2
- , lib
1
+ { pkgs , lib
3
2
, cardanoNodePackages
4
3
, cardanoNodeProject
5
4
} :
6
5
7
6
with lib ;
8
7
9
8
let
9
+
10
10
# recover CHaP location from cardano's project
11
11
chap = cardanoNodeProject . args . inputMap . "https://chap.intersectmbo.org/" ;
12
12
# build plan as computed by nix
13
13
nixPlanJson = cardanoNodeProject . plan-nix . json ;
14
14
15
+ # Workbench derivation and functions to create derivations from `wb` commands.
16
+ ##############################################################################
17
+
15
18
workbench' = tools :
16
19
pkgs . stdenv . mkDerivation {
17
20
pname = "workbench" ;
45
48
dontStrip = true ;
46
49
} ;
47
50
48
- workbench = with cardanoNodePackages ; with pkgs ; workbench' (
49
- [ git graphviz
50
- jq
51
- moreutils
52
- procps
53
- cardano-cli
54
- cardano-profile
55
- cardano-topology
56
- ] ++ lib . optional ( ! pkgs . stdenv . hostPlatform . isDarwin ) db-analyser
57
- ++ [ locli ]
51
+ # Workbench with its dependencies to call from Nix.
52
+ workbench = workbench' (
53
+ ( with pkgs ;
54
+ [ git graphviz
55
+ jq
56
+ moreutils
57
+ procps
58
+ ]
59
+ )
60
+ ++
61
+ ( with cardanoNodePackages ;
62
+ [
63
+ cardano-cli
64
+ cardano-profile
65
+ cardano-topology
66
+ locli
67
+ ]
68
+ )
69
+ ++
70
+ lib . optional ( ! pkgs . stdenv . hostPlatform . isDarwin ) pkgs . db-analyser
58
71
) ;
59
72
60
73
runWorkbench =
61
- name : command :
74
+ name : command : # Name of the derivation and `wb` command to run.
62
75
pkgs . runCommand name { } ''
63
76
${ workbench } /bin/wb ${ command } > $out
64
77
'' ;
65
78
79
+ # Helper functions.
80
+ ##############################################################################
81
+
66
82
runJq =
67
83
name : args : query :
68
84
pkgs . runCommand name { } ''
69
85
args=(${ args } )
70
86
${ pkgs . jq } /bin/jq '${ query } ' "'' ${args[@]}" > $out
71
87
'' ;
72
88
73
- profile-names-json =
74
- runWorkbench "profile-names.json" "profiles list" ;
89
+ # Auxiliary functions of `wb` commands.
90
+ ##############################################################################
75
91
76
- profile-names =
77
- __fromJSON ( __readFile profile-names-json ) ;
92
+ profile-names = __fromJSON ( __readFile profile-names-json ) ;
93
+
94
+ profile-names-json = runWorkbench "profile-names.json" "profiles list" ;
95
+
96
+ # Output
97
+ ################################################################################
78
98
79
99
in pkgs . lib . fix ( self : {
100
+
80
101
inherit cardanoNodePackages ;
81
102
inherit workbench' workbench runWorkbench ;
82
103
inherit runJq ;
83
-
84
104
inherit profile-names-json profile-names ;
85
105
106
+ # Return a profile attr with a `materialise-profile` function.
107
+ # profileName -> profiling -> profile
108
+ profile =
109
+ { profileName
110
+ , profiling
111
+ } :
112
+ ( import ./profile/profile.nix
113
+ { inherit pkgs lib ;
114
+ workbenchNix = self ;
115
+ inherit profileName profiling ;
116
+ }
117
+ )
118
+ ;
119
+
86
120
# Return a backend attr with a `materialise-profile` function.
87
121
# backendName -> stateDir -> basePort -> useCabalRun -> backend
88
122
backend =
@@ -106,43 +140,27 @@ in pkgs.lib.fix (self: {
106
140
{ inherit pkgs lib stateDir basePort useCabalRun ; }
107
141
;
108
142
109
- # Return a profile attr with a `materialise-profile` function.
110
- # profileName -> profiling -> profile
111
- profile =
112
- { profileName
113
- , profiling
114
- } :
115
- ( import ./profile/profile.nix
116
- { inherit pkgs lib ;
117
- workbenchNix = self ;
118
- inherit profileName profiling ;
119
- }
120
- )
121
- ;
122
-
123
143
# A conveniently-parametrisable workbench preset.
124
144
# See https://input-output-hk.github.io/haskell.nix/user-guide/development/
125
145
# The general idea is:
126
146
# 1. profileName -> profiling -> profile
127
147
# 2. backendName -> stateDir -> basePort -> useCabalRun -> backend
128
148
# 3. profile -> backend -> batchName -> runner
129
149
runner =
130
- { stateDir
131
- , batchName
132
- , profileName
150
+ { profileName
151
+ , profiling
133
152
, backendName
153
+ , stateDir
134
154
, basePort
135
155
, useCabalRun
136
156
, workbenchDevMode
157
+ , batchName
137
158
, workbenchStartArgs
138
- , profiling
139
159
, cardano-node-rev
140
160
} :
141
161
let
142
162
# Only a name needed to create a profile attrset.
143
- profile = self . profile
144
- { inherit profileName profiling ; }
145
- ;
163
+ profile = self . profile { inherit profileName profiling ; } ;
146
164
# The `useCabalRun` flag is set in the backend to allow the backend to
147
165
# override its value. The runner uses the value of `useCabalRun` from
148
166
# the backend to prevent a runner using a different value.
@@ -153,10 +171,8 @@ in pkgs.lib.fix (self: {
153
171
{
154
172
inherit pkgs lib ;
155
173
inherit profile backend ;
156
- inherit batchName ;
174
+ inherit workbench workbenchDevMode cardanoNodePackages ;
175
+ inherit batchName workbenchStartArgs ;
157
176
inherit cardano-node-rev ;
158
- inherit workbench ; # The derivation.
159
- inherit cardanoNodePackages ;
160
- inherit workbenchDevMode workbenchStartArgs ;
161
177
} ;
162
178
} )
0 commit comments