nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1/*
2 `dhallToNix` is a utility function to convert expressions in the Dhall
3 configuration language to their corresponding Nix expressions.
4
5 Example:
6 dhallToNix "{ foo = 1, bar = True }"
7 => { foo = 1; bar = true; }
8 dhallToNix "λ(x : Bool) → x == False"
9 => x : x == false
10 dhallToNix "λ(x : Bool) → x == False" false
11 => true
12
13 See https://hackage.haskell.org/package/dhall-nix/docs/Dhall-Nix.html for
14 a longer tutorial
15
16 Note that this uses "import from derivation", meaning that Nix will perform
17 a build during the evaluation phase if you use this `dhallToNix` utility
18*/
19{
20 stdenv,
21 dhall-nix,
22 writeText,
23}:
24
25let
26 dhallToNix =
27 code:
28 let
29 file = writeText "dhall-expression" code;
30
31 drv = stdenv.mkDerivation {
32 name = "dhall-compiled.nix";
33
34 buildCommand = ''
35 dhall-to-nix <<< "${file}" > $out
36 '';
37
38 buildInputs = [ dhall-nix ];
39 };
40
41 in
42 import drv;
43in
44dhallToNix