extract-options.nix (1019B)
1 { eval, lib, pkgs }: 2 let 3 inherit (lib) types; 4 conf = eval.config; 5 rootDir = builtins.toPath ./..; 6 stripAnyPrefixes = lib.flip (lib.fold lib.removePrefix) 7 ["${rootDir}/"]; 8 optToDoc = name: opt : { 9 inherit name; 10 description = opt.description or null; 11 default = opt.default or null; 12 visible = 13 if (opt ? visible && opt.visible == "shallow") 14 then true 15 else opt.visible or true; 16 readOnly = opt.readOnly or false; 17 type = opt.type.description or "unspecified"; 18 }; 19 spliceServiceDefn = item : 20 if item.type == "parametrisable s6-rc service definition" 21 then 22 let sd = lib.attrByPath item.loc ["not found"] conf; 23 in item // { 24 declarations = map stripAnyPrefixes item.declarations; 25 parameters = 26 let x = lib.mapAttrsToList optToDoc sd.parameters; in x; 27 } 28 else 29 item // { declarations = map stripAnyPrefixes item.declarations; }; 30 in 31 builtins.map spliceServiceDefn 32 (pkgs.lib.optionAttrSetToDocList eval.options)