Unverified Commit 9a8850ae authored by Gabriella Gonzalez's avatar Gabriella Gonzalez Committed by GitHub
Browse files

dhallToNix: Permit inputs referring to derivations (#134459)

Fixes https://github.com/dhall-lang/dhall-haskell/issues/2267

`pkgs.dhallToNix` currently fails when a Dhall package is
interpolated into the input source code, like this:

```nix
let
  pkgs = import <nixpkgs> { };

  f = { buildDhallPackage }: buildDhallPackage {
    name = "not";
    code = "λ(x : Bool) → x == False";
    source = true;
  };

  not = pkgs.dhallPackages.callPackage f {};

in
  pkgs.dhallToNix "${not}/source.dhall True"
```

This is because `dhallToNix` was using `builtins.toFile`, which
does not permit inputs with interpolated derivations.  However,
`pkgs.writeText` does not have this limitation, so we can switch
to using that instead.
parent 1c145df9
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -15,12 +15,12 @@
    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 }:
{ stdenv, dhall-nix, writeText }:

let
  dhallToNix = code :
    let
      file = builtins.toFile "dhall-expression" code;
      file = writeText "dhall-expression" code;

      drv = stdenv.mkDerivation {
        name = "dhall-compiled.nix";