From 459cf94991754d391f7808bbc306f52653298ada Mon Sep 17 00:00:00 2001 From: Gabriel Gonzalez Date: Sat, 9 May 2020 19:16:06 -0700 Subject: Nixpkgs support for `dhall-to-nixpkgs` The motivation for this change is to enable a new Dhall command-line utility called `dhall-to-nixpkgs` which converts Dhall packages to buildable Nix packages. You can think of `dhall-to-nixpkgs` as the Dhall analog of `cabal2nix`. You can find the matching pull request for `dhall-to-nixpkgs` here: https://github.com/dhall-lang/dhall-haskell/pull/1826 The two main changes required to support `dhall-to-nixpkgs` are: * Two new `buildDhall{Directory,GitHub}Package` utilities are added `dhall-to-nixpkgs` uses these in the generated output * `pkgs.dhallPackages` now selects a default version for each package using the `prefer` utility All other versions are still buildable via a `passthru` attribute --- .../dhall/build-dhall-github-package.nix | 50 ++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 pkgs/development/interpreters/dhall/build-dhall-github-package.nix (limited to 'pkgs/development/interpreters/dhall/build-dhall-github-package.nix') 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}"; + } + ) -- cgit 1.4.1