2 # `dhallPackageToNix` is a utility function to take a Nixpkgs Dhall package
3 # (created with a function like `dhallPackages.buildDhallDirectoryPackage`)
4 # and read it in as a Nix expression.
6 # This function is similar to `dhallToNix`, but takes a Nixpkgs Dhall package
7 # as input instead of raw Dhall code.
9 # Note that this uses "import from derivation" (IFD), meaning that Nix will
10 # perform a build during the evaluation phase if you use this
11 # `dhallPackageToNix` utility. It is not possible to use `dhallPackageToNix`
12 # in Nixpkgs, since the Nixpkgs Hydra doesn't allow IFD.
14 { stdenv, dhall-nix }:
18 drv = stdenv.mkDerivation {
19 name = "dhall-compiled-package.nix";
22 # Dhall requires that the cache is writable, even if it is never written to.
23 # We copy the cache from the input package to the current directory and
24 # set the cache as writable.
25 cp -r "${dhallPackage}/.cache" ./
26 export XDG_CACHE_HOME=$PWD/.cache
29 dhall-to-nix <<< "${dhallPackage}/binary.dhall" > $out
32 nativeBuildInputs = [ dhall-nix ];