nixos-config/lib/env-specific/home-manager.nix

40 lines
1.1 KiB
Nix
Raw Normal View History

2023-12-19 09:59:55 +00:00
# Custom libraries for home-manager library.
{ pkgs, lib, self }:
2023-12-19 09:59:55 +00:00
rec {
2025-01-12 09:57:14 +00:00
/* Checks if there is the `osConfig` attribute and get the attribute path from
its system configuration.
2023-12-19 09:59:55 +00:00
*/
hasNixOSConfigAttr =
2023-12-19 09:59:55 +00:00
# The configuration attribute set of the home-manager configuration.
attrs:
# A list of strings representing the attribute path.
attrPath:
# The default value when `attrPath` is missing.
default:
attrs ? nixosConfig && lib.attrByPath attrPath default attrs.nixosConfig;
hasDarwinConfigAttr =
# The configuration attribute set of the home-manager configuration.
attrs:
# A list of strings representing the attribute path.
attrPath:
# The default value when `attrPath` is missing.
default:
2025-01-12 09:57:14 +00:00
attrs ? darwinConfig
&& pkgs.lib.attrByPath attrPath default attrs.darwinConfig;
2025-01-12 09:57:14 +00:00
# A quick function to check if the optional NixOS system module is enabled.
hasOSModuleEnabled =
# The configuration attribute set of the home-manager configuration.
attrs:
# A list of strings representing the attribute path.
attrPath:
hasNixOSConfigAttr attrs attrPath false;
2023-12-19 09:59:55 +00:00
}