about summary refs log tree commit diff
path: root/pkgs/development/interpreters/dhall/build-dhall-github-package.nix
diff options
context:
space:
mode:
authorBenjamin Staffin <benley@gmail.com>2020-06-17 17:22:24 -0400
committerGitHub <noreply@github.com>2020-06-17 17:22:24 -0400
commit19d3665b75f59eb98ca656c2b643a4adc0f0744e (patch)
tree455aed025973e748f264df336d5dc0e7ae40dad5 /pkgs/development/interpreters/dhall/build-dhall-github-package.nix
parent13a14e2bfe4ff3b7da222624ce5749218105e465 (diff)
parent19dfc1b01149e5d60860cd0f4b0f8abcb3faabbf (diff)
downloadnixlib-19d3665b75f59eb98ca656c2b643a4adc0f0744e.tar
nixlib-19d3665b75f59eb98ca656c2b643a4adc0f0744e.tar.gz
nixlib-19d3665b75f59eb98ca656c2b643a4adc0f0744e.tar.bz2
nixlib-19d3665b75f59eb98ca656c2b643a4adc0f0744e.tar.lz
nixlib-19d3665b75f59eb98ca656c2b643a4adc0f0744e.tar.xz
nixlib-19d3665b75f59eb98ca656c2b643a4adc0f0744e.tar.zst
nixlib-19d3665b75f59eb98ca656c2b643a4adc0f0744e.zip
Merge branch 'master' into benley/melonDS
Diffstat (limited to 'pkgs/development/interpreters/dhall/build-dhall-github-package.nix')
-rw-r--r--pkgs/development/interpreters/dhall/build-dhall-github-package.nix50
1 files changed, 50 insertions, 0 deletions
diff --git a/pkgs/development/interpreters/dhall/build-dhall-github-package.nix b/pkgs/development/interpreters/dhall/build-dhall-github-package.nix
new file mode 100644
index 000000000000..9289e9b656d3
--- /dev/null
+++ b/pkgs/development/interpreters/dhall/build-dhall-github-package.nix
@@ -0,0 +1,50 @@
+{ buildDhallPackage, fetchFromGitHub, lib }:
+
+# This function is used by `dhall-to-nixpkgs` when given a GitHub repository
+lib.makeOverridable
+  ( { # Arguments passed through to `buildDhallPackage`
+      name
+    , dependencies ? []
+    , source ? false
+
+    , # The directory containing the Dhall files, if other than the root of the
+      # repository
+      directory ? ""
+    , # The file to import, relative to the above directory
+      file ? "package.dhall"
+
+      # Arguments passed through to `fetchFromGitHub`
+    , owner
+    , repo
+    , rev
+      # Extra arguments passed through to `fetchFromGitHub`, such as the hash
+      # or `fetchSubmodules`
+    , ...
+    }@args:
+
+    buildDhallPackage {
+      inherit name dependencies source;
+
+      code =
+        let
+          src = fetchFromGitHub ({
+            name = "${name}-source";
+
+            inherit owner repo rev;
+          } // removeAttrs args [
+            "name"
+            "dependencies"
+            "source"
+            "directory"
+            "file"
+            "owner"
+            "repo"
+            "rev"
+          ]);
+
+          prefix = lib.optionalString (directory != "") "${directory}/";
+
+        in
+          "${src}/${prefix}${file}";
+    }
+  )