1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-27 05:29:46 +01:00
home-manager/modules/misc/submodule-support.nix
name_snrl c2cd2a52e0
submodule-support: add default values for top-level configs
This way the end user can easily check whether the home-manager
configuration is part of the module or not. Example of use:

```nix
{ lib, nixosConfig, ... }:
let
  mkIfNixos = lib.mkIf nixosConfig != null;
in
{
  programs.foot.enable = mkIfNixos true;
}
```
2024-08-23 19:56:03 +02:00

47 lines
1.4 KiB
Nix
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{ lib, ... }:
with lib;
{
meta.maintainers = [ maintainers.rycee ];
options.submoduleSupport = {
enable = mkOption {
type = types.bool;
default = false;
internal = true;
description = ''
Whether the Home Manager module system is used as a submodule
in, for example, NixOS or nix-darwin.
'';
};
externalPackageInstall = mkOption {
type = types.bool;
default = false;
internal = true;
description = ''
Whether the packages of {option}`home.packages` are
installed separately from the Home Manager activation script.
In NixOS, for example, this may be accomplished by installing
the packages through
{option}`users.users.name?.packages`.
'';
};
};
config = {
# To make it easier for the end user to override the values in the
# configuration depending on the installation method, we set default values
# for the arguments that are defined in the NixOS/nix-darwin modules.
#
# Without these defaults, these attributes would simply not exist, and the
# module system can not inform modules about their non-existence; see
# https://github.com/NixOS/nixpkgs/issues/311709#issuecomment-2110861842
_module.args = {
osConfig = mkDefault null;
nixosConfig = mkDefault null;
darwinConfig = mkDefault null;
};
};
}