Add buildDhall*Package
support for generating documentation
The `buildDhall{Directory,GitHub}Package` utilities now take an optional `document` argument for generating documentation using `dhall-docs`. The documentation is stored underneath the `./docs` subdirectory of the build product.
This commit is contained in:
parent
86b651f169
commit
6dac8e6817
4 changed files with 57 additions and 29 deletions
|
@ -14,12 +14,17 @@ lib.makePackageOverridable
|
||||||
, src
|
, src
|
||||||
, # The file to import, relative to the root directory
|
, # The file to import, relative to the root directory
|
||||||
file ? "package.dhall"
|
file ? "package.dhall"
|
||||||
|
# Set to `true` to generate documentation for the package
|
||||||
|
, document ? false
|
||||||
}:
|
}:
|
||||||
|
|
||||||
buildDhallPackage {
|
buildDhallPackage
|
||||||
inherit name dependencies source;
|
( { inherit name dependencies source;
|
||||||
|
|
||||||
code = "${src}/${file}";
|
code = "${src}/${file}";
|
||||||
}
|
|
||||||
|
}
|
||||||
|
// lib.optionalAttrs document { documentationRoot = src; }
|
||||||
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,8 @@ lib.makePackageOverridable
|
||||||
directory ? ""
|
directory ? ""
|
||||||
, # The file to import, relative to the above directory
|
, # The file to import, relative to the above directory
|
||||||
file ? "package.dhall"
|
file ? "package.dhall"
|
||||||
|
# Set to `true` to generate documentation for the package
|
||||||
|
, document ? false
|
||||||
|
|
||||||
# Arguments passed through to `fetchFromGitHub`
|
# Arguments passed through to `fetchFromGitHub`
|
||||||
, owner
|
, owner
|
||||||
|
@ -22,29 +24,32 @@ lib.makePackageOverridable
|
||||||
, ...
|
, ...
|
||||||
}@args:
|
}@args:
|
||||||
|
|
||||||
buildDhallPackage {
|
let
|
||||||
inherit name dependencies source;
|
src = fetchFromGitHub ({
|
||||||
|
name = "${name}-source";
|
||||||
|
|
||||||
code =
|
inherit owner repo rev;
|
||||||
let
|
} // removeAttrs args [
|
||||||
src = fetchFromGitHub ({
|
"name"
|
||||||
name = "${name}-source";
|
"dependencies"
|
||||||
|
"document"
|
||||||
|
"source"
|
||||||
|
"directory"
|
||||||
|
"file"
|
||||||
|
"owner"
|
||||||
|
"repo"
|
||||||
|
"rev"
|
||||||
|
]);
|
||||||
|
|
||||||
inherit owner repo rev;
|
prefix = lib.optionalString (directory != "") "${directory}/";
|
||||||
} // removeAttrs args [
|
|
||||||
"name"
|
|
||||||
"dependencies"
|
|
||||||
"source"
|
|
||||||
"directory"
|
|
||||||
"file"
|
|
||||||
"owner"
|
|
||||||
"repo"
|
|
||||||
"rev"
|
|
||||||
]);
|
|
||||||
|
|
||||||
prefix = lib.optionalString (directory != "") "${directory}/";
|
in
|
||||||
|
buildDhallPackage
|
||||||
|
( { inherit name dependencies source;
|
||||||
|
|
||||||
in
|
code = "${src}/${prefix}${file}";
|
||||||
"${src}/${prefix}${file}";
|
}
|
||||||
}
|
// lib.optionalAttrs document
|
||||||
|
{ documentationRoot = "${src}/${prefix}"; }
|
||||||
|
)
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{ dhall, haskell, lib, lndir, runCommand, writeText }:
|
{ dhall, dhall-docs, haskell, lib, lndir, runCommand, writeText }:
|
||||||
|
|
||||||
{ name
|
{ name
|
||||||
|
|
||||||
|
@ -31,6 +31,12 @@
|
||||||
# space within the Nix store, but if you set the following `source` option to
|
# space within the Nix store, but if you set the following `source` option to
|
||||||
# `true` then the package will also include `source.dhall`.
|
# `true` then the package will also include `source.dhall`.
|
||||||
, source ? false
|
, source ? false
|
||||||
|
|
||||||
|
# Directory to generate documentation for (i.e. as the `--input` option to the
|
||||||
|
# `dhall-docs` command.)
|
||||||
|
#
|
||||||
|
# If `null`, then no documentation is generated.
|
||||||
|
, documentationRoot ? null
|
||||||
}:
|
}:
|
||||||
|
|
||||||
let
|
let
|
||||||
|
@ -42,8 +48,12 @@ let
|
||||||
|
|
||||||
cache = ".cache";
|
cache = ".cache";
|
||||||
|
|
||||||
|
data = ".local/share";
|
||||||
|
|
||||||
cacheDhall = "${cache}/dhall";
|
cacheDhall = "${cache}/dhall";
|
||||||
|
|
||||||
|
dataDhall = "${data}/dhall";
|
||||||
|
|
||||||
sourceFile = "source.dhall";
|
sourceFile = "source.dhall";
|
||||||
|
|
||||||
in
|
in
|
||||||
|
@ -71,4 +81,10 @@ in
|
||||||
echo "missing $SHA_HASH" > $out/binary.dhall
|
echo "missing $SHA_HASH" > $out/binary.dhall
|
||||||
|
|
||||||
${lib.optionalString (!source) "rm $out/${sourceFile}"}
|
${lib.optionalString (!source) "rm $out/${sourceFile}"}
|
||||||
|
|
||||||
|
${lib.optionalString (documentationRoot != null) ''
|
||||||
|
mkdir -p $out/${dataDhall}
|
||||||
|
|
||||||
|
XDG_DATA_HOME=$out/${data} ${dhall-docs}/bin/dhall-docs --input '${documentationRoot}' --output-link $out/docs
|
||||||
|
''}
|
||||||
''
|
''
|
||||||
|
|
|
@ -10310,13 +10310,15 @@ in
|
||||||
|
|
||||||
dhall = haskell.lib.justStaticExecutables haskellPackages.dhall;
|
dhall = haskell.lib.justStaticExecutables haskellPackages.dhall;
|
||||||
|
|
||||||
dhall-nix = haskell.lib.justStaticExecutables haskellPackages.dhall-nix;
|
|
||||||
|
|
||||||
dhall-bash = haskell.lib.justStaticExecutables haskellPackages.dhall-bash;
|
dhall-bash = haskell.lib.justStaticExecutables haskellPackages.dhall-bash;
|
||||||
|
|
||||||
|
dhall-docs = haskell.lib.justStaticExecutables haskellPackages.dhall-docs;
|
||||||
|
|
||||||
|
dhall-lsp-server = haskell.lib.justStaticExecutables haskellPackages.dhall-lsp-server;
|
||||||
|
|
||||||
dhall-json = haskell.lib.justStaticExecutables haskellPackages.dhall-json;
|
dhall-json = haskell.lib.justStaticExecutables haskellPackages.dhall-json;
|
||||||
|
|
||||||
dhall-lsp-server = haskell.lib.justStaticExecutables haskellPackages.dhall-lsp-server;
|
dhall-nix = haskell.lib.justStaticExecutables haskellPackages.dhall-nix;
|
||||||
|
|
||||||
dhall-text = haskell.lib.justStaticExecutables haskellPackages.dhall-text;
|
dhall-text = haskell.lib.justStaticExecutables haskellPackages.dhall-text;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue