From 9a8850aea97840dca1cc1087447ed89dbfe183dc Mon Sep 17 00:00:00 2001 From: Gabriella Gonzalez Date: Sat, 21 Aug 2021 19:25:01 -0700 Subject: [PATCH] dhallToNix: Permit inputs referring to derivations (#134459) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 { }; 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. --- pkgs/build-support/dhall-to-nix.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/build-support/dhall-to-nix.nix b/pkgs/build-support/dhall-to-nix.nix index 3805656dfa0e..96cc16e16f36 100644 --- a/pkgs/build-support/dhall-to-nix.nix +++ b/pkgs/build-support/dhall-to-nix.nix @@ -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";