-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
68 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# lowRISC Nix Libraries | ||
|
||
## The Documentation Library | ||
|
||
The `doc` library contains `buildMdbookSite`, which is a helper function for creating mdBook site builds. | ||
An example of it's use is below. | ||
|
||
```nix | ||
let | ||
fs = pkgs.lib.fileset; | ||
in { | ||
docs_build = doc.buildMdbookSite { | ||
pname = "documentation"; | ||
version = "0.0.1"; | ||
nativeBuildInputs = [pkgs.python311]; | ||
src = fs.toSource { | ||
root = ./.; | ||
fileset = fs.unions [ | ||
(doc.standardMdbookFileset ./.) | ||
./util/mdbook | ||
./util/mdbook_wavejson.py | ||
]; | ||
}; | ||
}; | ||
} | ||
``` | ||
|
||
*Note: `pkgs.mdbook` is not required in nativeBuildInputs.* | ||
|
||
`standardMdbookFileset` and `hasExts` are also provided to further help in creating derivations. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# Copyright lowRISC Contributors. | ||
# Licensed under the MIT License, see LICENSE for details. | ||
# SPDX-License-Identifier: MIT | ||
{pkgs}: let | ||
fs = pkgs.lib.fileset; | ||
# Returns true if a file has an extension in the array `exts`. | ||
hasExts = exts: file: builtins.any file.hasExt exts; | ||
in { | ||
inherit hasExts; | ||
|
||
standardMdbookFileset = root: | ||
fs.unions [ | ||
(root + /book.toml) | ||
(fs.fileFilter (hasExts ["md" "svg" "png"]) root) | ||
]; | ||
|
||
# A helper function to create mdBook site builds. | ||
buildMdbookSite = { | ||
pname, | ||
version, | ||
src, | ||
... | ||
} @ inputs: | ||
pkgs.stdenv.mkDerivation ({ | ||
dontFixup = true; | ||
buildPhase = "${pkgs.mdbook}/bin/mdbook build"; | ||
installPhase = '' | ||
mkdir $out | ||
cp -r book/* $out | ||
''; | ||
} | ||
// inputs); | ||
} |