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