core/pkgs/build-support/dhall/directory-to-nix.nix

23 lines
813 B
Nix
Raw Normal View History

2024-05-13 21:24:10 +00:00
{ dhallPackages, dhallPackageToNix }:
2024-05-02 00:46:19 +00:00
# `dhallDirectoryToNix is a utility function to take a directory of Dhall files
# and read them in as a Nix expression.
#
# This function is similar to `dhallToNix`, but takes a Nixpkgs Dhall package
# as input instead of raw Dhall code.
#
# Note that this uses "import from derivation" (IFD), meaning that Nix will
# perform a build during the evaluation phase if you use this
# `dhallDirectoryToNix` utility. It is not possible to use
# `dhallDirectoryToNix` in Nixpkgs, since the Nixpkgs Hydra doesn't allow IFD.
2024-05-13 21:24:10 +00:00
{ src, # The file to import, relative to the src root directory
file ? "package.dhall" }@args:
2024-05-02 00:46:19 +00:00
let
generatedPkg = dhallPackages.generateDhallDirectoryPackage args;
builtPkg = dhallPackages.callPackage generatedPkg { };
2024-05-13 21:24:10 +00:00
in dhallPackageToNix builtPkg