summary refs log tree commit diff
path: root/pkgs/build-support/dhall
diff options
context:
space:
mode:
author(cdep)illabout <cdep.illabout@gmail.com>2021-11-10 15:40:40 +0900
committer(cdep)illabout <cdep.illabout@gmail.com>2021-12-07 13:36:21 +0900
commit69bbd81c628133ceeed4f1eafaaae3c53215e126 (patch)
tree3547ab17fda801a84512fe432cb34d45155ca9f2 /pkgs/build-support/dhall
parent599e3c2e8370752f84bd985af5b1d36d304768d5 (diff)
downloadnixpkgs-69bbd81c628133ceeed4f1eafaaae3c53215e126.tar
nixpkgs-69bbd81c628133ceeed4f1eafaaae3c53215e126.tar.gz
nixpkgs-69bbd81c628133ceeed4f1eafaaae3c53215e126.tar.bz2
nixpkgs-69bbd81c628133ceeed4f1eafaaae3c53215e126.tar.lz
nixpkgs-69bbd81c628133ceeed4f1eafaaae3c53215e126.tar.xz
nixpkgs-69bbd81c628133ceeed4f1eafaaae3c53215e126.tar.zst
nixpkgs-69bbd81c628133ceeed4f1eafaaae3c53215e126.zip
dhallDirectoryToNix: add this utility function
Diffstat (limited to 'pkgs/build-support/dhall')
-rw-r--r--pkgs/build-support/dhall/directory-to-nix.nix25
1 files changed, 25 insertions, 0 deletions
diff --git a/pkgs/build-support/dhall/directory-to-nix.nix b/pkgs/build-support/dhall/directory-to-nix.nix
new file mode 100644
index 00000000000..d751e19df3f
--- /dev/null
+++ b/pkgs/build-support/dhall/directory-to-nix.nix
@@ -0,0 +1,25 @@
+{ dhallPackages, dhallPackageToNix}:
+
+# `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.
+
+{ src
+, # The file to import, relative to the src root directory
+  file ? "package.dhall"
+}@args:
+
+let
+  generatedPkg = dhallPackages.generateDhallDirectoryPackage args;
+
+  builtPkg = dhallPackages.callPackage generatedPkg { };
+
+in
+  dhallPackageToNix builtPkg