about summary refs log tree commit diff
path: root/lib/default.nix
diff options
context:
space:
mode:
authorAzat Bahawi <azat@bahawi.net>2024-07-10 14:02:06 +0300
committerAzat Bahawi <azat@bahawi.net>2024-07-10 14:02:06 +0300
commita88092202ccfdb981c6aef3270bdef20e7530f5f (patch)
treef6f2f82e7575aeead163bcf0c93bab494e7e70ce /lib/default.nix
parent2024-06-29 (diff)
2024-07-10
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