about summary refs log tree commit diff
path: root/pkgs/development/interpreters/dhall/build-dhall-github-package.nix
blob: 9289e9b656d305c72311d990a4e3361d2303bc09 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
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}";
    }
  )