Skip to content

Commit

Permalink
replace hideSubOptions with more granular approach.
Browse files Browse the repository at this point in the history
Since we are introspecting only options, we don't need all modules, but
only modules with extra options. When `null` we'll use all the modules.

This should cover `containers` usecase, and most others.
  • Loading branch information
danbst committed Dec 15, 2019
1 parent 729bfbf commit cd74159
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
9 changes: 6 additions & 3 deletions lib/types.nix
Original file line number Diff line number Diff line change
Expand Up @@ -366,8 +366,8 @@ rec {
fullSubmodule =
{ configDefault ? false
, modules ? []
, optionsModules ? null
, specialArgs ? {}
, hideSubOptions ? false
}@attrs:
let
inherit (lib.modules) evalModules;
Expand All @@ -391,8 +391,11 @@ rec {
args.name = last loc;
prefix = loc;
}).config;
getSubOptions = prefix: optionalAttrs (!hideSubOptions) (evalModules
{ inherit modules prefix specialArgs;
getSubOptions = prefix: (evalModules
{ inherit prefix specialArgs;
modules = if optionsModules == null
then modules
else optionsModules;
# This is a work-around due to the fact that some sub-modules,
# such as the one included in an attribute set, expects a "args"
# attribute to be given to the sub-module. As the option
Expand Down
1 change: 1 addition & 0 deletions nixos/modules/virtualisation/containers.nix
Original file line number Diff line number Diff line change
Expand Up @@ -634,6 +634,7 @@ in
in mkOption {
type = types.attrsOf (types.fullSubmodule {
modules = [ containerDefaults containerParamsModule ] ++ baseModules;
optionsModules = [ containerParamsModule ];
specialArgs.modulesPath = builtins.toString ../.;
});
default = {};
Expand Down

0 comments on commit cd74159

Please sign in to comment.