about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/interpreters/dhall/generate-dhall-directory-package.nix
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/pkgs/development/interpreters/dhall/generate-dhall-directory-package.nix')
-rw-r--r--nixpkgs/pkgs/development/interpreters/dhall/generate-dhall-directory-package.nix27
1 files changed, 27 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/development/interpreters/dhall/generate-dhall-directory-package.nix b/nixpkgs/pkgs/development/interpreters/dhall/generate-dhall-directory-package.nix
new file mode 100644
index 000000000000..03dfb72d7aba
--- /dev/null
+++ b/nixpkgs/pkgs/development/interpreters/dhall/generate-dhall-directory-package.nix
@@ -0,0 +1,27 @@
+{ dhall-nixpkgs, lib, stdenv }:
+
+# This function calls `dhall-to-nixpkgs directory --fixed-output-derivations`
+# within a Nix derivation.
+#
+# This is possible because
+# `dhall-to-nixpkgs directory --fixed-output-derivations` will turn remote
+# Dhall imports protected with Dhall integrity checksinto fixed-output
+# derivations (with the `buildDhallUrl` function), so no unrestricted network
+# access is necessary.
+lib.makePackageOverridable
+  ( { src
+    , # The file to import, relative to the root directory
+      file ? "package.dhall"
+    , # Set to `true` to generate documentation for the package
+      document ? false
+    }:
+    stdenv.mkDerivation {
+      name = "dhall-directory-package.nix";
+
+      buildCommand = ''
+        dhall-to-nixpkgs directory --fixed-output-derivations --file "${file}" "${src}" ${if document then "--document" else ""} > $out
+      '';
+
+      nativeBuildInputs = [ dhall-nixpkgs ];
+    }
+  )