forked from NixOS/nixpkgs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
lib/modules: Use fixed lib instead of args.lib
The practical use for this should be very limited because I don't think anyone should change `lib`, let alone change `lib.functionArgs`, but, but it would be even stranger to rely on `args.lib` (or really `specialArgs.lib` for what's clearly a behavior of the current `evalModules`, which uses its own ambient lib for basically everything. The shadowing of `lib` by `args.lib` here seems to be a small mistake, which is easy to make.
- Loading branch information
Showing
3 changed files
with
32 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{ config, lib, ... }: | ||
|
||
{ | ||
options = { | ||
result = lib.mkOption { }; | ||
weird = lib.mkOption { | ||
type = lib.types.submoduleWith { | ||
# I generally recommend against overriding lib, because that leads to | ||
# slightly incompatible dialects of the module system. | ||
# Nonetheless, it's worth guarding the property that the module system | ||
# evaluates with a completely custom lib, as a matter of separation of | ||
# concerns. | ||
specialArgs.lib = { }; | ||
modules = [ ]; | ||
}; | ||
}; | ||
}; | ||
config.weird = args@{ ... /* note the lack of a `lib` argument */ }: | ||
assert args.lib == { }; | ||
assert args.specialArgs == { lib = { }; }; | ||
{ | ||
options.foo = lib.mkOption { }; | ||
config.foo = lib.mkIf true "alright"; | ||
}; | ||
config.result = | ||
assert config.weird.foo == "alright"; | ||
"ok"; | ||
} |