···1+{ dhallPackages, dhallPackageToNix}:
2+3+# `dhallDirectoryToNix is a utility function to take a directory of Dhall files
4+# and read them in as a Nix expression.
5+#
6+# This function is similar to `dhallToNix`, but takes a Nixpkgs Dhall package
7+# as input instead of raw Dhall code.
8+#
9+# Note that this uses "import from derivation" (IFD), meaning that Nix will
10+# perform a build during the evaluation phase if you use this
11+# `dhallDirectoryToNix` utility. It is not possible to use
12+# `dhallDirectoryToNix` in Nixpkgs, since the Nixpkgs Hydra doesn't allow IFD.
13+14+{ src
15+, # The file to import, relative to the src root directory
16+ file ? "package.dhall"
17+}@args:
18+19+let
20+ generatedPkg = dhallPackages.generateDhallDirectoryPackage args;
21+22+ builtPkg = dhallPackages.callPackage generatedPkg { };
23+24+in
25+ dhallPackageToNix builtPkg
+36
pkgs/build-support/dhall/package-to-nix.nix
···000000000000000000000000000000000000
···1+2+# `dhallPackageToNix` is a utility function to take a Nixpkgs Dhall package
3+# (created with a function like `dhallPackages.buildDhallDirectoryPackage`)
4+# and read it in as a Nix expression.
5+#
6+# This function is similar to `dhallToNix`, but takes a Nixpkgs Dhall package
7+# as input instead of raw Dhall code.
8+#
9+# Note that this uses "import from derivation" (IFD), meaning that Nix will
10+# perform a build during the evaluation phase if you use this
11+# `dhallPackageToNix` utility. It is not possible to use `dhallPackageToNix`
12+# in Nixpkgs, since the Nixpkgs Hydra doesn't allow IFD.
13+14+{ stdenv, dhall-nix }:
15+16+dhallPackage:
17+ let
18+ drv = stdenv.mkDerivation {
19+ name = "dhall-compiled-package.nix";
20+21+ buildCommand = ''
22+ # Dhall requires that the cache is writable, even if it is never written to.
23+ # We copy the cache from the input package to the current directory and
24+ # set the cache as writable.
25+ cp -r "${dhallPackage}/.cache" ./
26+ export XDG_CACHE_HOME=$PWD/.cache
27+ chmod -R +w ./.cache
28+29+ dhall-to-nix <<< "${dhallPackage}/binary.dhall" > $out
30+ '';
31+32+ nativeBuildInputs = [ dhall-nix ];
33+ };
34+35+ in
36+ import drv
···1+{ dhallPackages, fetchFromGitHub }:
2+3+# This file tests that dhallPackages.generateDhallDirectoryPackage works.
4+#
5+# TODO: It would be nice to extend this test to make sure that the resulting
6+# Nix file has the expected contents, but it might be tough to do that easily
7+# without IFD.
8+9+dhallPackages.generateDhallDirectoryPackage {
10+ src = fetchFromGitHub {
11+ owner = "cdepillabout";
12+ repo = "example-dhall-nix";
13+ rev = "e6a675c72ecd4dd23d254a02aea8181fe875747f";
14+ sha256 = "sha256-c/EZq76s/+hmLkaeJWKqgh2KrHuJRYI6kWry0E0YQ6s=";
15+ };
16+ file = "mydhallfile.dhall";
17+}
···23stdenv.mkDerivation rec {
4 pname = "jdupes";
5- version = "1.20.1";
67 src = fetchFromGitHub {
8 owner = "jbruchon";
9 repo = "jdupes";
10 rev = "v${version}";
11- sha256 = "sha256-qGYMLLksbC6bKbK+iRkZ2eSNU5J/wEvTfzT0IkKukvA=";
12 # Unicode file names lead to different checksums on HFS+ vs. other
13 # filesystems because of unicode normalisation. The testdir
14 # directories have such files and will be removed.
···23stdenv.mkDerivation rec {
4 pname = "jdupes";
5+ version = "1.20.2";
67 src = fetchFromGitHub {
8 owner = "jbruchon";
9 repo = "jdupes";
10 rev = "v${version}";
11+ sha256 = "sha256-3hKO+hNwYiJZ9Wn53vM7DHZmtvDhtgtSbW7bCMCT7s0=";
12 # Unicode file names lead to different checksums on HFS+ vs. other
13 # filesystems because of unicode normalisation. The testdir
14 # directories have such files and will be removed.