mirror of
https://github.com/ilyakooo0/nixpkgs.git
synced 2024-12-27 22:03:54 +03:00
lib.modules: Make option injection work when shorthandOnlyDefinesConfig
This commit is contained in:
parent
11537c9c02
commit
8baea8b82c
@ -496,6 +496,7 @@ rec {
|
|||||||
options = mkOption {
|
options = mkOption {
|
||||||
type = types.submoduleWith {
|
type = types.submoduleWith {
|
||||||
modules = [ { options = decl.options; } ];
|
modules = [ { options = decl.options; } ];
|
||||||
|
shorthandOnlyDefinesConfig = null;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -66,6 +66,7 @@ checkConfigOutput '^1$' config.bare-submodule.nested ./declare-bare-submodule.ni
|
|||||||
checkConfigOutput '^2$' config.bare-submodule.deep ./declare-bare-submodule.nix ./declare-bare-submodule-deep-option.nix
|
checkConfigOutput '^2$' config.bare-submodule.deep ./declare-bare-submodule.nix ./declare-bare-submodule-deep-option.nix
|
||||||
checkConfigOutput '^42$' config.bare-submodule.nested ./declare-bare-submodule.nix ./declare-bare-submodule-nested-option.nix ./declare-bare-submodule-deep-option.nix ./define-bare-submodule-values.nix
|
checkConfigOutput '^42$' config.bare-submodule.nested ./declare-bare-submodule.nix ./declare-bare-submodule-nested-option.nix ./declare-bare-submodule-deep-option.nix ./define-bare-submodule-values.nix
|
||||||
checkConfigOutput '^420$' config.bare-submodule.deep ./declare-bare-submodule.nix ./declare-bare-submodule-nested-option.nix ./declare-bare-submodule-deep-option.nix ./define-bare-submodule-values.nix
|
checkConfigOutput '^420$' config.bare-submodule.deep ./declare-bare-submodule.nix ./declare-bare-submodule-nested-option.nix ./declare-bare-submodule-deep-option.nix ./define-bare-submodule-values.nix
|
||||||
|
checkConfigOutput '^2$' config.bare-submodule.deep ./declare-bare-submodule.nix ./declare-bare-submodule-deep-option.nix ./define-shorthandOnlyDefinesConfig-true.nix
|
||||||
|
|
||||||
# Check integer types.
|
# Check integer types.
|
||||||
# unsigned
|
# unsigned
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
{ lib, ... }:
|
{ config, lib, ... }:
|
||||||
let
|
let
|
||||||
inherit (lib) mkOption types;
|
inherit (lib) mkOption types;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
options.bare-submodule = mkOption {
|
options.bare-submodule = mkOption {
|
||||||
type = types.submoduleWith {
|
type = types.submoduleWith {
|
||||||
|
shorthandOnlyDefinesConfig = config.shorthandOnlyDefinesConfig;
|
||||||
modules = [
|
modules = [
|
||||||
{
|
{
|
||||||
options.nested = mkOption {
|
options.nested = mkOption {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
{ lib, ... }:
|
{ config, lib, ... }:
|
||||||
let
|
let
|
||||||
inherit (lib) mkOption types;
|
inherit (lib) mkOption types;
|
||||||
in
|
in
|
||||||
@ -6,7 +6,13 @@ in
|
|||||||
options.bare-submodule = mkOption {
|
options.bare-submodule = mkOption {
|
||||||
type = types.submoduleWith {
|
type = types.submoduleWith {
|
||||||
modules = [ ];
|
modules = [ ];
|
||||||
|
shorthandOnlyDefinesConfig = config.shorthandOnlyDefinesConfig;
|
||||||
};
|
};
|
||||||
default = {};
|
default = {};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
# config-dependent options: won't recommend, but useful for making this test parameterized
|
||||||
|
options.shorthandOnlyDefinesConfig = mkOption {
|
||||||
|
default = false;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1 @@
|
|||||||
|
{ shorthandOnlyDefinesConfig = true; }
|
@ -637,7 +637,11 @@ rec {
|
|||||||
then lhs.specialArgs // rhs.specialArgs
|
then lhs.specialArgs // rhs.specialArgs
|
||||||
else throw "A submoduleWith option is declared multiple times with the same specialArgs \"${toString (attrNames intersecting)}\"";
|
else throw "A submoduleWith option is declared multiple times with the same specialArgs \"${toString (attrNames intersecting)}\"";
|
||||||
shorthandOnlyDefinesConfig =
|
shorthandOnlyDefinesConfig =
|
||||||
if lhs.shorthandOnlyDefinesConfig == rhs.shorthandOnlyDefinesConfig
|
if lhs.shorthandOnlyDefinesConfig == null
|
||||||
|
then rhs.shorthandOnlyDefinesConfig
|
||||||
|
else if rhs.shorthandOnlyDefinesConfig == null
|
||||||
|
then lhs.shorthandOnlyDefinesConfig
|
||||||
|
else if lhs.shorthandOnlyDefinesConfig == rhs.shorthandOnlyDefinesConfig
|
||||||
then lhs.shorthandOnlyDefinesConfig
|
then lhs.shorthandOnlyDefinesConfig
|
||||||
else throw "A submoduleWith option is declared multiple times with conflicting shorthandOnlyDefinesConfig values";
|
else throw "A submoduleWith option is declared multiple times with conflicting shorthandOnlyDefinesConfig values";
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user