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.
launchpad/nixpkgs/master
Gabriella Gonzalez 3 years ago committed by GitHub
parent 1c145df9ae
commit 9a8850aea9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      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";

Loading…
Cancel
Save