Skip to content

Commit

Permalink
submodule-support: add default values for top-level configs
Browse files Browse the repository at this point in the history
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;
}
```
  • Loading branch information
name-snrl authored and rycee committed Aug 23, 2024
1 parent 5dc2535 commit c2cd2a5
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions modules/misc/submodule-support.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
};
}

0 comments on commit c2cd2a5

Please sign in to comment.