From 24dbb2b3231b5a9f4a9aae57ef90436d59db300b Mon Sep 17 00:00:00 2001 From: Pacman99 Date: Sun, 11 Apr 2021 22:27:59 -0700 Subject: [PATCH] add mkFlakeDoc to pkgs-lib to build options doc --- lib/flake.nix | 3 +++ lib/jobs/default.nix | 5 +++++ lib/jobs/mkFlakeDoc.nix | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 43 insertions(+) create mode 100644 lib/jobs/default.nix create mode 100644 lib/jobs/mkFlakeDoc.nix diff --git a/lib/flake.nix b/lib/flake.nix index 14e2947a..4120e83a 100644 --- a/lib/flake.nix +++ b/lib/flake.nix @@ -57,9 +57,12 @@ } ); + jobs = import ./jobs { inherit nixpkgs; lib = nixpkgs.lib // lib; }; + in { + inherit jobs; lib = utils.lib // { inherit (lib) diff --git a/lib/jobs/default.nix b/lib/jobs/default.nix new file mode 100644 index 00000000..2f108ed7 --- /dev/null +++ b/lib/jobs/default.nix @@ -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; }; +} diff --git a/lib/jobs/mkFlakeDoc.nix b/lib/jobs/mkFlakeDoc.nix new file mode 100644 index 00000000..45ddeed5 --- /dev/null +++ b/lib/jobs/mkFlakeDoc.nix @@ -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 +