summaryrefslogtreecommitdiff
path: root/lib
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
parent31ab954db3dbc0a07e7b58c59da003088ee7943d (diff)
2024-07-10
Diffstat (limited to 'lib')
-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 = [