diff options
author | Joachim F <joachifm@users.noreply.github.com> | 2017-01-27 13:21:30 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-01-27 13:21:30 +0100 |
commit | da1cd49747bb83ac41f49a58b3b7a2624be551cd (patch) | |
tree | 9ca25e3fe44e979939f0cb5834741d4e4d29ec5d /pkgs | |
parent | df1fee320cce10f9c9f44b01718b4b2dfc50dc72 (diff) | |
parent | c791c0fd16abea669d3aaa082a9174d6d3ad77f4 (diff) | |
download | nixlib-da1cd49747bb83ac41f49a58b3b7a2624be551cd.tar nixlib-da1cd49747bb83ac41f49a58b3b7a2624be551cd.tar.gz nixlib-da1cd49747bb83ac41f49a58b3b7a2624be551cd.tar.bz2 nixlib-da1cd49747bb83ac41f49a58b3b7a2624be551cd.tar.lz nixlib-da1cd49747bb83ac41f49a58b3b7a2624be551cd.tar.xz nixlib-da1cd49747bb83ac41f49a58b3b7a2624be551cd.tar.zst nixlib-da1cd49747bb83ac41f49a58b3b7a2624be551cd.zip |
Merge pull request #22193 from Gabriel439/gabriel/dhallToNix
Add a `pkgs.dhallToNix` utility
Diffstat (limited to 'pkgs')
-rw-r--r-- | pkgs/build-support/dhall-to-nix.nix | 38 | ||||
-rw-r--r-- | pkgs/top-level/all-packages.nix | 4 |
2 files changed, 42 insertions, 0 deletions
diff --git a/pkgs/build-support/dhall-to-nix.nix b/pkgs/build-support/dhall-to-nix.nix new file mode 100644 index 000000000000..c563b34ff3bc --- /dev/null +++ b/pkgs/build-support/dhall-to-nix.nix @@ -0,0 +1,38 @@ +/* `dhallToNix` is a utility function to convert expressions in the Dhall + configuration language to their corresponding Nix expressions. + + Example: + dhallToNix "{ foo = 1, bar = True }" + => { foo = 1; bar = true; } + dhallToNix "λ(x : Bool) → x == False" + => x : x == false + dhallToNix "λ(x : Bool) → x == False" false + => true + + See https://hackage.haskell.org/package/dhall-nix/docs/Dhall-Nix.html for + a longer tutorial + + Note that this uses "import from derivation", meaning that Nix will perform + a build during the evaluation phase if you use this `dhallToNix` utility +*/ +{ stdenv, dhall-nix }: + +let + dhallToNix = code : + let + file = builtins.toFile "dhall-expression" code; + + drv = stdenv.mkDerivation { + name = "dhall-compiled.nix"; + + buildCommand = '' + dhall-to-nix <<< "${file}" > $out + ''; + + buildInputs = [ dhall-nix ]; + }; + + in + import "${drv}"; +in + dhallToNix diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index e53a30b81d95..4d08239d40f4 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -91,6 +91,10 @@ with pkgs; cmark = callPackage ../development/libraries/cmark { }; + dhallToNix = callPackage ../build-support/dhall-to-nix.nix { + inherit (haskellPackages) dhall-nix; + }; + dockerTools = callPackage ../build-support/docker { }; dotnetenv = callPackage ../build-support/dotnetenv { |