at 25.11-pre 1.3 kB view raw
1# Run tests: nix-build -A tests.nixosOptionsDoc 2 3{ 4 lib, 5 nixosOptionsDoc, 6 runCommand, 7}: 8let 9 inherit (lib) mkOption types; 10 11 eval = lib.evalModules { 12 modules = [ 13 { 14 options.foo.bar.enable = mkOption { 15 type = types.bool; 16 default = false; 17 description = '' 18 Enable the foo bar feature. 19 ''; 20 }; 21 } 22 ]; 23 }; 24 25 doc = nixosOptionsDoc { 26 inherit (eval) options; 27 }; 28in 29{ 30 /** 31 Test that 32 - the `nixosOptionsDoc` function can be invoked 33 - integration of the module system and `nixosOptionsDoc` (limited coverage) 34 35 The more interesting tests happen in the `nixos-render-docs` package. 36 */ 37 commonMark = 38 runCommand "test-nixosOptionsDoc-commonMark" 39 { 40 commonMarkDefault = doc.optionsCommonMark; 41 commonMarkAnchors = doc.optionsCommonMark.overrideAttrs { 42 extraArgs = [ 43 "--anchor-prefix" 44 "my-opt-" 45 "--anchor-style" 46 "legacy" 47 ]; 48 }; 49 } 50 '' 51 env | grep ^commonMark | sed -e 's/=/ = /' 52 ( 53 set -x 54 grep -F 'foo\.bar\.enable' $commonMarkDefault >/dev/null 55 grep -F '{#my-opt-foo.bar.enable}' $commonMarkAnchors >/dev/null 56 ) 57 touch $out 58 ''; 59}