From ef0a42347efad85481aa91482e303808bfaca85d Mon Sep 17 00:00:00 2001 From: Gabriel Gonzalez Date: Tue, 29 Jun 2021 19:09:29 -0700 Subject: [PATCH] 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. --- .../dhall/build-dhall-github-package.nix | 9 ++++++--- .../interpreters/dhall/build-dhall-package.nix | 14 +++++++++++++- 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 53adc5a9b125..8f9e4d835511 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 9fc9a4412156..86797e9f136f 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; + }} ''} ''