about summary refs log tree commit diff
path: root/pkgs/development/interpreters/dhall
diff options
context:
space:
mode:
authorGabriel Gonzalez <Gabriel439@gmail.com>2021-06-29 19:09:29 -0700
committerGitHub <noreply@github.com>2021-06-29 19:09:29 -0700
commitef0a42347efad85481aa91482e303808bfaca85d (patch)
treeecf51d5a2e0a64d0a405f4d415a679204dce9950 /pkgs/development/interpreters/dhall
parentc865d03690afed7813dbb7abeb8d84e9b4568d01 (diff)
dhall: Use --base-import-url flag for documentation (#128588)
This updates `pkgs.dhallPackages.buildDhallGitHubPackage` to use the
newly added `--base-import-url` `dhall-docs` flag.  This flag is used
by the generated documentation so that paths copied to the clipboard
represent complete URLs that can be imported instead of only the
relative path to the import.
Diffstat (limited to 'pkgs/development/interpreters/dhall')
-rw-r--r--pkgs/development/interpreters/dhall/build-dhall-github-package.nix9
-rw-r--r--pkgs/development/interpreters/dhall/build-dhall-package.nix14
2 files changed, 19 insertions, 4 deletions
diff --git a/pkgs/development/interpreters/dhall/build-dhall-github-package.nix b/pkgs/development/interpreters/dhall/build-dhall-github-package.nix
index 53adc5a9b1258..8f9e4d835511c 100644
--- a/pkgs/development/interpreters/dhall/build-dhall-github-package.nix
+++ b/pkgs/development/interpreters/dhall/build-dhall-github-package.nix
@@ -43,7 +43,7 @@ lib.makePackageOverridable
         "rev"
       ]);
 
-      prefix = lib.optionalString (directory != "") "${directory}/";
+      prefix = lib.optionalString (directory != "") "/${directory}";
 
     in
       buildDhallPackage
@@ -51,9 +51,12 @@ lib.makePackageOverridable
 
             name = versionedName;
 
-            code = "${src}/${prefix}${file}";
+            code = "${src}${prefix}/${file}";
           }
         // lib.optionalAttrs document
-          { documentationRoot = "${src}/${prefix}"; }
+          { documentationRoot = "${src}/${prefix}";
+
+            baseImportUrl = "https://raw.githubusercontent.com/${owner}/${repo}/${rev}${prefix}";
+          }
         )
   )
diff --git a/pkgs/development/interpreters/dhall/build-dhall-package.nix b/pkgs/development/interpreters/dhall/build-dhall-package.nix
index 9fc9a44121560..86797e9f136f6 100644
--- a/pkgs/development/interpreters/dhall/build-dhall-package.nix
+++ b/pkgs/development/interpreters/dhall/build-dhall-package.nix
@@ -37,6 +37,12 @@
   #
   # If `null`, then no documentation is generated.
 , documentationRoot ? null
+
+  # Base URL prepended to paths copied to the clipboard
+  #
+  # This is used in conjunction with `documentationRoot`, and is unused if
+  # `documentationRoot` is `null`.
+, baseImportUrl ? null
 }:
 
 let
@@ -85,6 +91,12 @@ in
     ${lib.optionalString (documentationRoot != null) ''
     mkdir -p $out/${dataDhall}
 
-    XDG_DATA_HOME=$out/${data} ${dhall-docs}/bin/dhall-docs --input '${documentationRoot}' --package-name '${name}' --output-link $out/docs
+    XDG_DATA_HOME=$out/${data} ${dhall-docs}/bin/dhall-docs --output-link $out/docs ${lib.cli.toGNUCommandLineShell { } {
+      base-import-url = baseImportUrl;
+
+      input = documentationRoot;
+
+      package-name = name;
+    }}
     ''}
   ''