Don't expose all functions in the top-level lib
, prefer sub-libraries
#266103
Labels
6.topic: lib
The Nixpkgs function library
lib
, prefer sub-libraries
#266103
lib
is a bit messy right now, where some functions are available inlib.*
, but some need to be accessed aslib.<sublibrary>.*
.Traditionally all functions were available under
lib.*
, but in recent years we've seen that it doesn't work that well. An example is howlib.hasPrefix
works on strings, it's aliased tolib.strings.hasPrefix
. But it also makes sense to have such functionality for lists and paths, we should be able to re-use the same name. This is now done:lib.lists.{hasPrefix,removePrefix}
: init #243511lib.path.hasPrefix
: init #237610But
lib.hasPrefix
still needs to point tolib.strings.hasPrefix
for backwards compat, and this previously caused problems when accidentally usinglib.hasPrefix
for paths:Furthermore,
lib
is tending towards the style more emphasised sincewhich makes sublibraries not much harder to use (no need to always use
lists.length
).We should establish a standard for sublibraries and make sure it's consistent.
Related issues/comments:
lib.cli
namespace tolib
#263969replicate
#261676 (comment)Ping @roberth @h7x4
The text was updated successfully, but these errors were encountered: