From cf5ad9ce3c5a14479a00ea09c9744895cc3d775f Mon Sep 17 00:00:00 2001 From: Gabriel Arazas Date: Sat, 23 Dec 2023 18:40:12 +0800 Subject: [PATCH] lib/home-manager: add `hasOSModuleEnabled` --- lib/home-manager.nix | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/home-manager.nix b/lib/home-manager.nix index 42637868..ad963bf5 100644 --- a/lib/home-manager.nix +++ b/lib/home-manager.nix @@ -1,7 +1,7 @@ # Custom libraries for home-manager library. { lib }: -{ +rec { /* Checks if there is the `osConfig` attribute and get the attribute path from its system configuration. @@ -16,4 +16,15 @@ # The default value when `attrPath` is missing. default: attrs ? osConfig && lib.attrByPath attrPath default attrs; + + /* + A quick function to check if the optional system module is enabled. + */ + hasOSModuleEnabled = + # The configuration attribute set of the home-manager configuration. + attrs: + + # A list of strings representing the attribute path. + attrPath: + getOSConfigPath attrs attrPath false; }