summary refs log tree commit diff
path: root/nixos/modules
diff options
context:
space:
mode:
authorRobert Hensing <robert@roberthensing.nl>2022-07-14 11:57:37 +0200
committerRobert Hensing <robert@roberthensing.nl>2022-07-21 15:32:10 +0200
commit9aa588ecc394f140681a0d68b635b3cf45ade411 (patch)
tree9600b2f9517a359f8624c2d0682f1764429fa46c /nixos/modules
parentec3e1c6a3a19e1eaf14d8697e99922c192129574 (diff)
downloadnixpkgs-9aa588ecc394f140681a0d68b635b3cf45ade411.tar
nixpkgs-9aa588ecc394f140681a0d68b635b3cf45ade411.tar.gz
nixpkgs-9aa588ecc394f140681a0d68b635b3cf45ade411.tar.bz2
nixpkgs-9aa588ecc394f140681a0d68b635b3cf45ade411.tar.lz
nixpkgs-9aa588ecc394f140681a0d68b635b3cf45ade411.tar.xz
nixpkgs-9aa588ecc394f140681a0d68b635b3cf45ade411.tar.zst
nixpkgs-9aa588ecc394f140681a0d68b635b3cf45ade411.zip
nixos/documentation: Add unit test
Diffstat (limited to 'nixos/modules')
-rw-r--r--nixos/modules/misc/documentation/test-dummy.chapter.xml0
-rw-r--r--nixos/modules/misc/documentation/test.nix49
2 files changed, 49 insertions, 0 deletions
diff --git a/nixos/modules/misc/documentation/test-dummy.chapter.xml b/nixos/modules/misc/documentation/test-dummy.chapter.xml
new file mode 100644
index 00000000000..e69de29bb2d
--- /dev/null
+++ b/nixos/modules/misc/documentation/test-dummy.chapter.xml
diff --git a/nixos/modules/misc/documentation/test.nix b/nixos/modules/misc/documentation/test.nix
new file mode 100644
index 00000000000..1eaa63b1fb6
--- /dev/null
+++ b/nixos/modules/misc/documentation/test.nix
@@ -0,0 +1,49 @@
+{ nixosLib, pkgsModule, runCommand }:
+
+let
+  sys = nixosLib.evalModules rec {
+    modules = [
+      pkgsModule
+      ../documentation.nix
+      ../version.nix
+
+      ({ lib, someArg, ... }: {
+        # Make sure imports from specialArgs are respected
+        imports = [ someArg.myModule ];
+
+        # TODO test this
+        meta.doc = ./test-dummy.chapter.xml;
+      })
+
+      {
+        _module.args = {
+          baseModules = [
+            ../documentation.nix
+            ../version.nix
+          ];
+          extraModules = [ ];
+          inherit modules;
+        };
+        documentation.nixos.includeAllModules = true;
+      }
+    ];
+    specialArgs.someArg.myModule = { lib, ... }: {
+      options.foobar = lib.mkOption {
+        type = lib.types.str;
+        description = "The foobar option was added via specialArgs";
+        default = "qux";
+      };
+    };
+  };
+
+in
+runCommand "documentation-check"
+{
+  inherit (sys.config.system.build.manual) optionsJSON;
+} ''
+  json="$optionsJSON/share/doc/nixos/options.json"
+  echo checking $json
+
+  grep 'The foobar option was added via specialArgs' <"$json" >/dev/null
+  touch $out
+''