mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-23 07:23:20 +00:00
118bdf25a6
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).
50 lines
732 B
Nix
50 lines
732 B
Nix
{ lib, ... }:
|
|
let
|
|
inherit (lib) mkOption types;
|
|
|
|
moduleWithoutKey = {
|
|
config = {
|
|
raw = "pear";
|
|
};
|
|
};
|
|
|
|
moduleWithKey = {
|
|
key = __curPos.file + "#moduleWithKey";
|
|
config = {
|
|
raw = "pear";
|
|
};
|
|
};
|
|
|
|
decl = {
|
|
options = {
|
|
raw = mkOption {
|
|
type = types.lines;
|
|
};
|
|
};
|
|
};
|
|
in
|
|
{
|
|
options = {
|
|
once = mkOption {
|
|
type = types.submodule {
|
|
imports = [
|
|
decl
|
|
moduleWithKey
|
|
moduleWithKey
|
|
];
|
|
};
|
|
default = {};
|
|
};
|
|
twice = mkOption {
|
|
type = types.submodule {
|
|
imports = [
|
|
decl
|
|
moduleWithoutKey
|
|
moduleWithoutKey
|
|
];
|
|
};
|
|
default = {};
|
|
};
|
|
};
|
|
}
|