From a88092202ccfdb981c6aef3270bdef20e7530f5f Mon Sep 17 00:00:00 2001 From: Azat Bahawi Date: Wed, 10 Jul 2024 14:02:06 +0300 Subject: 2024-07-10 --- lib/default.nix | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'lib/default.nix') 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 = [ -- cgit v1.2.3