mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-11 04:05:40 +03:00
lib/modules: Allow an "anonymous" module with key in disabledModules
This makes the following work disabledModules = [ foo.nixosModules.bar ]; even if `bar` is not a path, but rather a module such as { key = "/path/to/foo#nixosModules.bar"; config = ...; } By supporting this, the user will often be able to use the same syntax for both importing and disabling a module. This is becoming more relevant because flakes promote the use of attributes to reference modules. Not all of these modules in flake attributes will be identifiable, but with the help of a framework such as flake-parts, these attributes can be guaranteed to be identifiable (by outPath + attribute path).
This commit is contained in:
parent
82b4c24705
commit
118bdf25a6
7 changed files with 183 additions and 7 deletions
34
lib/tests/modules/disable-module-with-toString-key.nix
Normal file
34
lib/tests/modules/disable-module-with-toString-key.nix
Normal file
|
@ -0,0 +1,34 @@
|
|||
{ lib, ... }:
|
||||
let
|
||||
inherit (lib) mkOption types;
|
||||
|
||||
moduleWithKey = {
|
||||
key = 123;
|
||||
config = {
|
||||
enable = true;
|
||||
};
|
||||
};
|
||||
in
|
||||
{
|
||||
options = {
|
||||
positive = mkOption {
|
||||
type = types.submodule {
|
||||
imports = [
|
||||
./declare-enable.nix
|
||||
moduleWithKey
|
||||
];
|
||||
};
|
||||
default = {};
|
||||
};
|
||||
negative = mkOption {
|
||||
type = types.submodule {
|
||||
imports = [
|
||||
./declare-enable.nix
|
||||
moduleWithKey
|
||||
];
|
||||
disabledModules = [ 123 ];
|
||||
};
|
||||
default = {};
|
||||
};
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue