[PATCH] lib: Add documentation for mkOverride

Patch
From 52ab14ad94892ca90441297a241bcde96f7bcff6 Mon Sep 17 00:00:00 2001
From: Do Nix <um2iai+9g233t397b57k@sharklasers.com>
Date: Thu, 13 Feb 2025 14:50:55 +0100
Subject: [PATCH] lib: Add documentation for mkOverride

mkOverride is used in many places, but to newcomers, it is unclear what
it does or how it works. This hopefully clears that up
---
 lib/modules.nix | 38 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)

diff --git a/lib/modules.nix b/lib/modules.nix
index 4d2d8e0b08b6..1b414380f658 100644
--- a/lib/modules.nix
+++ b/lib/modules.nix
@@ -1055,6 +1055,44 @@ let
       inherit contents;
     };
 
+  /**
+  Overrides the previous value of a NixOS option by changing its priority to a default value.
+
+  type: function
+
+  # Input 
+  
+  `priority` (number)\
+   How to prioritise the value (high number -> lower priority, low number -> higher priority )
+
+  `value` (any)\
+   The value to prioritise.
+
+  # Example
+
+  In one file the Nextcloud service could be enabled by default, but depending on some condition
+  that could be overridden.
+
+  **configuration.nix**
+  ```nix
+  {
+    services.nextcloud.enable = lib.mkDefault true;
+  }
+  ```
+
+  **my-module.nix**
+  ```nix
+  {
+    services.nextcloud.enable = lib.mkOverride 50 false;
+  }
+  ```
+
+  # How it works
+
+  Values have metadata attached to them. One of these fields is a number called "priority".
+  When evaluating the inputs assigned to an option, the value with the highest priority wins.
+  (Again, remember the lower the number, the higher the priority!)
+  */
   mkOverride = priority: content:
     { _type = "override";
       inherit priority content;
-- 
2.46.0