mirror of
https://github.com/DreamMaoMao/maomaowm.git
synced 2026-06-19 14:33:16 -04:00
39 lines
1.1 KiB
Nix
39 lines
1.1 KiB
Nix
self: {
|
|
pkgs,
|
|
lib ? pkgs.lib,
|
|
module,
|
|
optionPrefix,
|
|
}: let
|
|
# Absolute store path of the flake root, used to compute relative subpaths
|
|
repoPath = toString self;
|
|
|
|
eval = lib.evalModules {
|
|
modules = [
|
|
(import module self.packages.${pkgs.stdenv.hostPlatform.system}.default)
|
|
{_module.check = false;}
|
|
];
|
|
specialArgs = {inherit pkgs;};
|
|
};
|
|
|
|
# Relative path of the module file within the repo (e.g. "nix/hm-modules.nix")
|
|
moduleSubpath = lib.removePrefix "/" (lib.removePrefix repoPath (toString module));
|
|
|
|
# Declaration entry linking each option back to its source file on GitHub
|
|
moduleDeclaration = {
|
|
url = "https://github.com/mangowm/mango/blob/main/${moduleSubpath}";
|
|
name = "<mango/${moduleSubpath}>";
|
|
};
|
|
|
|
optionsDoc = pkgs.nixosOptionsDoc {
|
|
options = eval.options;
|
|
transformOptions = opt:
|
|
opt
|
|
// {
|
|
visible = opt.visible && !opt.internal;
|
|
# Strip the option prefix so docs show "enable" instead of "programs.mango.enable"
|
|
name = lib.removePrefix optionPrefix opt.name;
|
|
declarations = [moduleDeclaration];
|
|
};
|
|
};
|
|
in
|
|
optionsDoc.optionsJSON
|