@@ -168,39 +168,7 @@ builtinsList = sequence
168168 , add0 Normal " currentSystem" currentSystem
169169 , add0 Normal " currentTime" currentTime_
170170 , add2 Normal " deepSeq" deepSeq
171-
172- -- This is compiled in so that we only parse and evaluate it once, at
173- -- compile-time.
174- , add0 TopLevel " derivation" $ (do
175- let Success expr = parseNixText [text |
176- drvAttrs @ { outputs ? [ "out" ], ... }:
177-
178- let
179-
180- strict = derivationStrict drvAttrs;
181-
182- commonAttrs = drvAttrs
183- // (builtins.listToAttrs outputsList)
184- // { all = map (x: x.value) outputsList;
185- inherit drvAttrs;
186- };
187-
188- outputToAttrListElement = outputName:
189- { name = outputName;
190- value = commonAttrs // {
191- outPath = builtins.getAttr outputName strict;
192- drvPath = strict.drvPath;
193- type = "derivation";
194- inherit outputName;
195- };
196- };
197-
198- outputsList = map outputToAttrListElement outputs;
199-
200- in (builtins.head outputsList).value|]
201- [| foldFix Eval. eval expr | ]
202- )
203-
171+ , add0 TopLevel " derivation" derivation
204172 , add TopLevel " derivationStrict" derivationStrict_
205173 , add TopLevel " dirOf" dirOf
206174 , add2 Normal " div" div_
@@ -306,6 +274,40 @@ builtinsList = sequence
306274
307275-- Primops
308276
277+ derivation
278+ :: forall e t f m . (MonadNix e t f m , Scoped (NValue t f m ) m )
279+ => m (NValue t f m )
280+ derivation = foldFix Eval. eval $$ (do
281+ -- This is compiled in so that we only parse it once at compile-time.
282+ let Success expr = parseNixText [text |
283+ drvAttrs @ { outputs ? [ "out" ], ... }:
284+
285+ let
286+
287+ strict = derivationStrict drvAttrs;
288+
289+ commonAttrs = drvAttrs
290+ // (builtins.listToAttrs outputsList)
291+ // { all = map (x: x.value) outputsList;
292+ inherit drvAttrs;
293+ };
294+
295+ outputToAttrListElement = outputName:
296+ { name = outputName;
297+ value = commonAttrs // {
298+ outPath = builtins.getAttr outputName strict;
299+ drvPath = strict.drvPath;
300+ type = "derivation";
301+ inherit outputName;
302+ };
303+ };
304+
305+ outputsList = map outputToAttrListElement outputs;
306+
307+ in (builtins.head outputsList).value|]
308+ [|| expr || ]
309+ )
310+
309311foldNixPath
310312 :: forall e t f m r
311313 . MonadNix e t f m
0 commit comments