aboutsummaryrefslogtreecommitdiff
path: root/infra/libkookie/nixpkgs/pkgs/development/interpreters/dhall/build-dhall-github-package.nix
blob: 0978e47754b90fcf8fbab6b3dbd4fda5399abf19 (plain)
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
51
52
53
54
55
{ buildDhallPackage, fetchFromGitHub, lib }:

# This function is used by `dhall-to-nixpkgs` when given a GitHub repository
lib.makePackageOverridable
  ( { # 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"
      # Set to `true` to generate documentation for the package
    , document ? false

      # Arguments passed through to `fetchFromGitHub`
    , owner
    , repo
    , rev
      # Extra arguments passed through to `fetchFromGitHub`, such as the hash
      # or `fetchSubmodules`
    , ...
    }@args:

    let
      src = fetchFromGitHub ({
        name = "${name}-source";

        inherit owner repo rev;
      } // removeAttrs args [
        "name"
        "dependencies"
        "document"
        "source"
        "directory"
        "file"
        "owner"
        "repo"
        "rev"
      ]);

      prefix = lib.optionalString (directory != "") "${directory}/";

    in
      buildDhallPackage
        ( { inherit name dependencies source;

            code = "${src}/${prefix}${file}";
          }
        // lib.optionalAttrs document
          { documentationRoot = "${src}/${prefix}"; }
        )
  )