nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 buildDhallPackage,
3 fetchFromGitHub,
4 lib,
5}:
6
7# This function is used by `dhall-to-nixpkgs` when given a GitHub repository
8lib.makePackageOverridable (
9 {
10 # Arguments passed through to `buildDhallPackage`
11 name,
12 dependencies ? [ ],
13 source ? false,
14
15 # The directory containing the Dhall files, if other than the root of the
16 # repository
17 directory ? "",
18 # The file to import, relative to the above directory
19 file ? "package.dhall",
20 # Set to `true` to generate documentation for the package
21 document ? false,
22
23 # Arguments passed through to `fetchFromGitHub`
24 owner,
25 repo,
26 rev,
27 # Extra arguments passed through to `fetchFromGitHub`, such as the hash
28 # or `fetchSubmodules`
29 ...
30 }@args:
31
32 let
33 versionedName = "${name}-${rev}";
34
35 src = fetchFromGitHub (
36 {
37 name = "${versionedName}-source";
38
39 inherit owner repo rev;
40 }
41 // removeAttrs args [
42 "name"
43 "dependencies"
44 "document"
45 "source"
46 "directory"
47 "file"
48 "owner"
49 "repo"
50 "rev"
51 ]
52 );
53
54 prefix = lib.optionalString (directory != "") "/${directory}";
55
56 in
57 buildDhallPackage (
58 {
59 inherit dependencies source;
60
61 name = versionedName;
62
63 code = "${src}${prefix}/${file}";
64 }
65 // lib.optionalAttrs document {
66 documentationRoot = "${src}/${prefix}";
67
68 baseImportUrl = "https://raw.githubusercontent.com/${owner}/${repo}/${rev}${prefix}";
69 }
70 )
71)