From c2cd2a52e02f1dfa1c88f95abeb89298d46023be Mon Sep 17 00:00:00 2001 From: name_snrl Date: Wed, 15 May 2024 04:49:17 +0500 Subject: [PATCH] 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; } ``` --- modules/misc/submodule-support.nix | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/modules/misc/submodule-support.nix b/modules/misc/submodule-support.nix index 400e234cb..82fbc0a30 100644 --- a/modules/misc/submodule-support.nix +++ b/modules/misc/submodule-support.nix @@ -29,4 +29,19 @@ with lib; ''; }; }; + + 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; + }; + }; }