about summary refs log tree commit diff
path: root/pkgs
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs')
-rw-r--r--pkgs/data/icons/whitesur-icon-theme/default.nix4
-rw-r--r--pkgs/development/interpreters/dhall/build-dhall-url.nix96
-rw-r--r--pkgs/test/default.nix2
-rw-r--r--pkgs/test/dhall/buildDhallUrl/default.nix14
-rw-r--r--pkgs/test/dhall/default.nix5
-rw-r--r--pkgs/top-level/dhall-packages.nix4
6 files changed, 123 insertions, 2 deletions
diff --git a/pkgs/data/icons/whitesur-icon-theme/default.nix b/pkgs/data/icons/whitesur-icon-theme/default.nix
index 157ff6d3eac9a..27465b828a615 100644
--- a/pkgs/data/icons/whitesur-icon-theme/default.nix
+++ b/pkgs/data/icons/whitesur-icon-theme/default.nix
@@ -2,13 +2,13 @@
 
 stdenvNoCC.mkDerivation rec {
   pname = "Whitesur-icon-theme";
-  version = "2021-10-13";
+  version = "2021-11-08";
 
   src = fetchFromGitHub {
     owner = "vinceliuice";
     repo = pname;
     rev = version;
-    sha256 = "BP5hGi3G9zNUSfeCbwYUvd3jMcWhstXiDeZCJ6Hgey8=";
+    sha256 = "LZ0GLJFUUvzsPhU2sBkfy5mPpQHuPzYhbumwFKnogoA=";
   };
 
   nativeBuildInputs = [ gtk3 ];
diff --git a/pkgs/development/interpreters/dhall/build-dhall-url.nix b/pkgs/development/interpreters/dhall/build-dhall-url.nix
new file mode 100644
index 0000000000000..766fe3c1c2e3f
--- /dev/null
+++ b/pkgs/development/interpreters/dhall/build-dhall-url.nix
@@ -0,0 +1,96 @@
+{ cacert, dhall, dhall-docs, haskell, lib, runCommand }:
+
+# `buildDhallUrl` is similar to `buildDhallDirectoryPackage` or
+# `buildDhallGitHubPackage`, but instead builds a Nixpkgs Dhall package
+# based on a hashed URL.  This will generally be a URL that has an integrity
+# check in a Dhall file.
+#
+# Similar to `buildDhallDirectoryPackage` and `buildDhallGitHubPackage`, the output
+# of this function is a derivation that has a `binary.dhall` file, along with
+# a `.cache/` directory with the actual contents of the Dhall file from the
+# suppiled URL.
+#
+# This function is primarily used by `dhall-to-nixpkgs directory --fixed-output-derivations`.
+
+{ # URL of the input Dhall file.
+  # example: "https://raw.githubusercontent.com/cdepillabout/example-dhall-repo/c1b0d0327146648dcf8de997b2aa32758f2ed735/example1.dhall"
+  url
+
+  # Nix hash of the input Dhall file.
+  # example: "sha256-ZTSiQUXpPbPfPvS8OeK6dDQE6j6NbP27ho1cg9YfENI="
+, hash
+
+  # Dhall hash of the input Dhall file.
+  # example: "sha256:6534a24145e93db3df3ef4bc39e2ba743404ea3e8d6cfdbb868d5c83d61f10d2"
+, dhallHash
+
+  # Name for this derivation.
+, name ? (baseNameOf url + "-cache")
+
+  # `buildDhallUrl` can include both a "source distribution" in
+  # `source.dhall` and a "binary distribution" in `binary.dhall`:
+  #
+  # * `source.dhall` is a dependency-free αβ-normalized Dhall expression
+  #
+  # * `binary.dhall` is an expression of the form: `missing sha256:${HASH}`
+  #
+  #   This expression requires you to install the cache product located at
+  #   `.cache/dhall/1220${HASH}` to successfully resolve
+  #
+  # By default, `buildDhallUrl` only includes "binary.dhall" to conserve
+  # space within the Nix store, but if you set the following `source` option to
+  # `true` then the package will also include `source.dhall`.
+, source ? false
+}:
+
+let
+  # HTTP support is disabled in order to force that HTTP dependencies are built
+  # using Nix instead of using Dhall's support for HTTP imports.
+  dhallNoHTTP = haskell.lib.appendConfigureFlag dhall "-f-with-http";
+
+  # This uses Dhall's remote importing capabilities for downloading a Dhall file.
+  # The output Dhall file has all imports resolved, and then is
+  # alpha-normalized and binary-encoded.
+  downloadedEncodedFile =
+    runCommand
+      (baseNameOf url)
+      {
+        outputHashAlgo = null;
+        outputHash = hash;
+        name = baseNameOf url;
+        nativeBuildInputs = [ cacert ];
+      }
+      ''
+        echo "${url} ${dhallHash}" > in-dhall-file
+        ${dhall}/bin/dhall --alpha --plain --file in-dhall-file | ${dhallNoHTTP}/bin/dhall encode > $out
+      '';
+
+   cache = ".cache";
+
+   data = ".local/share";
+
+   cacheDhall = "${cache}/dhall";
+
+   dataDhall = "${data}/dhall";
+
+   sourceFile = "source.dhall";
+
+in
+  runCommand name { } (''
+    set -eu
+
+    mkdir -p ${cacheDhall} $out/${cacheDhall}
+
+    export XDG_CACHE_HOME=$PWD/${cache}
+
+    SHA_HASH="${dhallHash}"
+
+    HASH_FILE="''${SHA_HASH/sha256:/1220}"
+
+    cp ${downloadedEncodedFile} $out/${cacheDhall}/$HASH_FILE
+
+    echo "missing $SHA_HASH" > $out/binary.dhall
+  '' +
+  lib.optionalString source ''
+    ${dhallNoHTTP}/bin/dhall decode --file ${downloadedEncodedFile} > $out/${sourceFile}
+  '')
diff --git a/pkgs/test/default.nix b/pkgs/test/default.nix
index 80d82e5bee07d..d1ec7169e1709 100644
--- a/pkgs/test/default.nix
+++ b/pkgs/test/default.nix
@@ -58,4 +58,6 @@ with pkgs;
   };
 
   writers = callPackage ../build-support/writers/test.nix {};
+
+  dhall = callPackage ./dhall { };
 }
diff --git a/pkgs/test/dhall/buildDhallUrl/default.nix b/pkgs/test/dhall/buildDhallUrl/default.nix
new file mode 100644
index 0000000000000..d2e214fb9770c
--- /dev/null
+++ b/pkgs/test/dhall/buildDhallUrl/default.nix
@@ -0,0 +1,14 @@
+{ dhallPackages, lib }:
+
+# This file tests that dhallPackages.buildDhallUrl is able to successfully
+# build a Nix Dhall package for a given remote Dhall import.
+#
+# TODO: It would be nice to extend this test to make sure that the resulting
+# Nix Dhall package is has the expected contents.
+
+dhallPackages.buildDhallUrl {
+  url = "https://raw.githubusercontent.com/cdepillabout/example-dhall-nix/e6a675c72ecd4dd23d254a02aea8181fe875747f/mydhallfile.dhall";
+  hash = "sha256-434x+QjHRzuprBdw0h6wmwB1Zj6yZqQb533me8XdO4c=";
+  dhallHash = "sha256:e37e31f908c7473ba9ac1770d21eb09b0075663eb266a41be77de67bc5dd3b87";
+  source = true;
+}
diff --git a/pkgs/test/dhall/default.nix b/pkgs/test/dhall/default.nix
new file mode 100644
index 0000000000000..bdb33acf0238e
--- /dev/null
+++ b/pkgs/test/dhall/default.nix
@@ -0,0 +1,5 @@
+{ lib, callPackage }:
+
+lib.recurseIntoAttrs {
+  buildDhallUrl = callPackage ./buildDhallUrl { };
+}
diff --git a/pkgs/top-level/dhall-packages.nix b/pkgs/top-level/dhall-packages.nix
index 1be67f2a4dea0..1910cb3727419 100644
--- a/pkgs/top-level/dhall-packages.nix
+++ b/pkgs/top-level/dhall-packages.nix
@@ -17,12 +17,16 @@ let
       buildDhallDirectoryPackage =
         callPackage ../development/interpreters/dhall/build-dhall-directory-package.nix { };
 
+      buildDhallUrl =
+        callPackage ../development/interpreters/dhall/build-dhall-url.nix { };
+
     in
       { inherit
           callPackage
           buildDhallPackage
           buildDhallGitHubPackage
           buildDhallDirectoryPackage
+          buildDhallUrl
         ;
 
         lib = import ../development/dhall-modules/lib.nix { inherit lib; };