about summary refs log tree commit diff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/tests/release.nix4
-rw-r--r--lib/trivial.nix60
2 files changed, 63 insertions, 1 deletions
diff --git a/lib/tests/release.nix b/lib/tests/release.nix
index 1447e88170913..084fbd94d34c2 100644
--- a/lib/tests/release.nix
+++ b/lib/tests/release.nix
@@ -24,7 +24,9 @@ in
       #
       #   https://github.com/NixOS/nixpkgs/issues/272591
       #
-      [(import ../../pkgs/test/release {})]
+      [(import ../../pkgs/test/release {
+        inherit pkgs lib nix;
+      })]
     ;
 
   }
diff --git a/lib/trivial.nix b/lib/trivial.nix
index 3d97770357915..20a3ffebbc2bb 100644
--- a/lib/trivial.nix
+++ b/lib/trivial.nix
@@ -623,6 +623,37 @@ in {
   /**
     Reads a JSON file.
 
+    # Examples
+    :::{.example}
+    ## `lib.trivial.importJSON` usage example
+
+    example.json
+    ```json
+    {
+      "title": "Example JSON",
+      "hello": {
+        "world": "foo",
+        "bar": {
+          "foobar": true
+        }
+      }
+    }
+    ```
+
+    ```nix
+    importJSON ./example.json
+    => {
+      title = "Example JSON";
+      hello = {
+        world = "foo";
+        bar = {
+          foobar = true;
+        };
+      };
+    }
+    ```
+
+    :::
 
     # Inputs
 
@@ -642,6 +673,35 @@ in {
   /**
     Reads a TOML file.
 
+    # Examples
+    :::{.example}
+    ## `lib.trivial.importTOML` usage example
+
+    example.toml
+    ```toml
+    title = "TOML Example"
+
+    [hello]
+    world = "foo"
+
+    [hello.bar]
+    foobar = true
+    ```
+
+    ```nix
+    importTOML ./example.toml
+    => {
+      title = "TOML Example";
+      hello = {
+        world = "foo";
+        bar = {
+          foobar = true;
+        };
+      };
+    }
+    ```
+
+    :::
 
     # Inputs