diff options
author | Azat Bahawi <azat@bahawi.net> | 2024-07-10 14:02:06 +0300 |
---|---|---|
committer | Azat Bahawi <azat@bahawi.net> | 2024-07-10 14:02:06 +0300 |
commit | a88092202ccfdb981c6aef3270bdef20e7530f5f (patch) | |
tree | f6f2f82e7575aeead163bcf0c93bab494e7e70ce /lib | |
parent | 2024-06-29 (diff) |
2024-07-10
Diffstat (limited to '')
-rw-r--r-- | lib/default.nix | 35 |
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 = [ |