about summary refs log tree commit diff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--lib/default.nix35
1 files changed, 35 insertions, 0 deletions
diff --git a/lib/default.nix b/lib/default.nix
index a6a25c9..4bd731e 100644
--- a/lib/default.nix
+++ b/lib/default.nix
@@ -27,6 +27,17 @@ lib: _: with lib; rec {
       ]
     );
 
+  # Load all files from directory (partially recursively).
+  #
+  # Usage: Assuming other Nix files are present in a directory:
+  # ```
+  # { ... }: {
+  #   imports = attrValue (modulesIn ./.);
+  #
+  #   services.foobar.enable = true;
+  # }
+  # ```
+  #
   modulesIn =
     dir:
     pipe dir [
@@ -47,6 +58,30 @@ lib: _: with lib; rec {
       listToAttrs
     ];
 
+  # Override a module using another Nixpkgs source tree.
+  #
+  # Usage: Assuming we want to override "services.foobar.enable":
+  # ```
+  # { config, lib, ... }:
+  # (lib.modulesFromRef
+  #   "services/security/foobar.nix"
+  #   "azahi:fix-foobar"
+  #   "sha256-AAA..."
+  # ) // {
+  #   config = {
+  #     serices.foobar.enable = true;
+  #   };
+  # }
+  # ```
+  # or
+  # ```
+  # nixosConfigurations.machine = nixosSystem {
+  #   modules = [
+  #     (_: modulesFromRef "services/security/foobar.nix" "azahi:foobar-fix" "sha256-AAA...")
+  #   ];
+  # };
+  # ```
+  #
   moduleFromRef = module: ref: sha256: {
     disabledModules = [ module ];
     imports = [

Consider giving Nix/NixOS a try! <3