devshell
devshell copied to clipboard
Generate the Go datastructure
It would be good to be able to generate the Go struct from the Nix module to guarantee that they stay in sync.
The schema defined in mkDevShell/options.nix is the canonical version and devshell/config.go needs to be kept in sync with it. To avoid unnecessary discrepancy, it would be great if the latter could be derived from the former.
Breadcrumb:
- https://github.com/dave/jennifer/
- https://github.com/aloder/tojen
(this might be a precursor to taking this issue, or not... no commitment at this time possible)
Another option to add here is rycee/nmd.
I'm using it to convert modules nix to markdown files and document some modules
Something like this:
# simplified from https://github.com/cruel-intentions/devshell-files/blob/master/modules/docs.nix
let
modules = [
./myModulePath.nix
{
_module.check = false;
_module.args.pkgs = lib.mkForce (nmd.scrubDerivations "pkgs" pkgs);
}
];
docs = mnd.buildModulesDocs {
channelName = "";
docBook = {};
mkModuleUrl = path: path;
moduleRootPaths = [ ./. ];
modules = modules;
};
in (import ./docs/markdown.nix) docs.optionsDocs
# simplified from https://github.com/cruel-intentions/devshell-files/blob/master/modules/docs/markdown.nix
moduleDocs:
let
optionToMd = opt:
''
## ${opt.name}
${opt.description}
#### type
${opt.type}
${opt.example}
${opt.default}
'';
in builtins.concatStringsSep "\n" (builtins.map optionToMd moduleDocs)