init
.
This commit is contained in:
commit
4d711e5002
3 changed files with 841 additions and 0 deletions
95
flake.nix
Normal file
95
flake.nix
Normal file
|
@ -0,0 +1,95 @@
|
|||
{
|
||||
inputs = {
|
||||
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
|
||||
ndg.url = "github:feel-co/ndg";
|
||||
};
|
||||
|
||||
# cheerfully lifted from nixos + hjem-rum doc gen
|
||||
outputs =
|
||||
inputs: with inputs; {
|
||||
lib.pak-chooie =
|
||||
{
|
||||
pkgs,
|
||||
lib,
|
||||
projectName ? "unf",
|
||||
self ? null,
|
||||
newPath ? "https://my.site/unf/docs",
|
||||
specialArgs ? { },
|
||||
modules ? [ ],
|
||||
}:
|
||||
let
|
||||
basePath = self.outPath;
|
||||
eval = lib.evalModules {
|
||||
inherit specialArgs;
|
||||
modules = [
|
||||
(
|
||||
let
|
||||
scrubDerivations =
|
||||
namePrefix: pkgSet:
|
||||
mapAttrs (
|
||||
name: value:
|
||||
let
|
||||
wholeName = "${namePrefix}.${name}";
|
||||
in
|
||||
if isAttrs value then
|
||||
scrubDerivations wholeName value
|
||||
// optionalAttrs (isDerivation value) {
|
||||
inherit (value) drvPath;
|
||||
outPath = "\${${wholeName}}";
|
||||
}
|
||||
else
|
||||
value
|
||||
) pkgSet;
|
||||
in
|
||||
{
|
||||
_module = {
|
||||
check = false;
|
||||
args.pkgs = mkForce (scrubDerivations "pkgs" pkgs);
|
||||
};
|
||||
}
|
||||
)
|
||||
{
|
||||
options._module.args = lib.mkOption {
|
||||
internal = true;
|
||||
};
|
||||
}
|
||||
] ++ modules;
|
||||
};
|
||||
optionsDoc = pkgs.nixosOptionsDoc {
|
||||
inherit (eval) options;
|
||||
|
||||
transformOptions =
|
||||
opt:
|
||||
opt
|
||||
// {
|
||||
declarations =
|
||||
let
|
||||
devDir = toString basePath;
|
||||
inherit (lib) hasPrefix removePrefix;
|
||||
in
|
||||
map (
|
||||
decl:
|
||||
if hasPrefix (toString devDir) (toString decl) then
|
||||
let
|
||||
subpath = removePrefix "/" (removePrefix (toString devDir) (toString decl));
|
||||
in
|
||||
{
|
||||
url = "${newPath}/${subpath}";
|
||||
name = subpath;
|
||||
}
|
||||
else
|
||||
decl
|
||||
) opt.declarations;
|
||||
};
|
||||
};
|
||||
in
|
||||
pkgs.runCommandLocal "${projectName}-docs"
|
||||
{ nativeBuildInputs = [ ndg.packages.${pkgs.system}.ndg ]; }
|
||||
''
|
||||
ndg --verbose html --jobs $NIX_BUILD_CORES --title "${projectName}" \
|
||||
--module-options "${optionsDoc.optionsJSON}/share/doc/nixos/options.json" \
|
||||
--generate-search true \
|
||||
--output-dir "$out"
|
||||
'';
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue