You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It creates interoperability issues that can not be reconciled by
`lib` or maintainers of projects that use the Nixpkgs library.
Occasionally, end users may be able to solve the problems they run
into, but most are not prepared to deal with this set of problems,
nor should they be.
Typical conflict:
- User wants to propagate their own lib, because it has some function
they like to use throughout their projects
- Project maintainer requires the project's lib to be used
No sane language uses a single namespace for combining all the things.
(Arguably not even C with its extensive use of prefixing)
Meanwhile, in Nix, all symbols are first class variables. We don't even
have the concept of a global top-level namespace to pour everything into.
With `lib` you can try to approximate that, I get the appeal of its
apparent simplicity, but since `lib` can't be global, we just don't even
get that apparent simplicity.
I apologize for not offering concrete solutions to this in the text.
The manuals are limited to reference documentation.
Alternatives - of which we have multiple - are best provided in
task-oriented documentation, e.g. nix.dev.
Copy file name to clipboardexpand all lines: doc/module-system/module-system.chapter.md
+9
Original file line number
Diff line number
Diff line change
@@ -31,6 +31,15 @@ An attribute set of module arguments that can be used in `imports`.
31
31
32
32
This is in contrast to `config._module.args`, which is only available after all `imports` have been resolved.
33
33
34
+
::: {.warning}
35
+
You may be tempted to use `specialArgs.lib` to provide extra library functions. Doing so limits the interoperability of modules, as well as the interoperability of Module System applications.
36
+
37
+
`lib` is reserved for the Nixpkgs library, and should not be used for custom functions.
38
+
39
+
Instead, you may create a new attribute in `specialArgs` to provide custom functions.
40
+
This clarifies their origin and avoids incompatibilities.
0 commit comments