add mkFlakeDoc to pkgs-lib to build options doc

This commit is contained in:
Pacman99 2021-04-11 22:27:59 -07:00 committed by David Arnold
parent 239386b5f8
commit 24dbb2b323
No known key found for this signature in database
GPG key ID: 6D6A936E69C59D08
3 changed files with 43 additions and 0 deletions

View file

@ -57,9 +57,12 @@
} }
); );
jobs = import ./jobs { inherit nixpkgs; lib = nixpkgs.lib // lib; };
in in
{ {
inherit jobs;
lib = utils.lib // { lib = utils.lib // {
inherit (lib) inherit (lib)

5
lib/jobs/default.nix Normal file
View file

@ -0,0 +1,5 @@
{ nixpkgs, lib, system ? "x86_64-linux" }: let
pkgs = import nixpkgs { inherit system; overlays = []; config = {}; };
in {
mkFlakeDoc = import ./mkFlakeDoc.nix { inherit pkgs lib; };
}

35
lib/jobs/mkFlakeDoc.nix Normal file
View file

@ -0,0 +1,35 @@
{ pkgs, lib, ... }:
let
singleDoc = name: value: ''
## ${name}
${value.description}
${lib.optionalString (value ? type) ''
*_Type_*:
${value.type}
''}
${lib.optionalString (value ? default) ''
*_Default_*
```
${builtins.toJSON value.default}
```
''}
${lib.optionalString (value ? example) ''
*_Example_*
```
${value.example}
```
''}
'';
options = (
lib.mkFlake.evalArgs
{ userFlakeSelf = {}; userFlakeNixOS = {}; }
{ args = { }; }
).options;
processedOptions = (pkgs.nixosOptionsDoc { inherit options; }).optionsNix;
fullDoc = lib.concatStringsSep "" (lib.mapAttrsToList singleDoc processedOptions);
in
pkgs.writeText "devosOptions.md" fullDoc