Conversation
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.
hsjobeki
left a comment
There was a problem hiding this comment.
lgtm.
I dont know how to display the doc-comment in the repl or on noogle for this yet.
Seems to work in the repl, Nix 2.25 I guess for nixdoc we'd have to construct a fake sublibrary to represent the top level or something to make it work? We can't just do |
Co-authored-by: Johannes Kirschbauer <[email protected]>
304df2b to
55a11de
Compare
|
Is there a way to make |
|
lib = {
lib = import ./lib;
nixos = ...;
nixosSystem = ...;
};Has that ship sailed? Possibly. Alternatively, we could make lib = lib // {
nixos = ...;
nixosSystem = ...;
};Maybe add a deprecation warning: lib = lib.extend (this: old: { nixos = ...; nixosSystem = ...; }) // {
nixos = ...;
nixosSystem = ...;
};Doing the lib =
let
nixpkgsLib = import ./lib;
warnOnce =
lib.warnIf
( # auto-enables after 24.11 EOL
lib.oldestSupportedReleaseIsAtLeast 2505)
# Needs better writing, maybe on nix.dev.
"The Nixpkgs library is moving into `nixpkgs.lib.lib`. `nixpkgs.lib` is a standard flake output to expose functions and libraries. Nixpkgs exposes its standard library, as well as NixOS functions, such as the `nixos` library and `nixosSystem` function. These remain in `nixpkgs.lib`." null;
in
mapAttrs (k: v: builtins.seq warnOnce v) nixpkgsLib // {
lib = nixpkgsLib;
nixos = ...;
nixosSystem = ...;
}What do you think? Before doing any of this, we should have guides for handling dependencies on nix.dev. Things like how do you write a module file that uses bog standard lexical scope stuff instead of fancy tricks like |
|
I think in general the situation currently is quite broken and inconsistent. e.g. a lot of people do not use So I think a breaking change that introduces a The injecting into the global |
|
NixOS/amis@ac17880 is a good example of why I'd love to get rid of all of this. The amount of hoops I need to jump to build a tool for helping release management in nixpkgs due to the oddness of our flake interface is not nice. |
A simple preparation for plans discussed in - NixOS#376033 Crucially, without these changes, the identifier `lib` has too many meanings and therefore doesn't mean anything, making it unmaintainable.
This will then also need changes to |
It creates interoperability issues that can not be reconciled by
libor 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:
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
libyou can try to approximate that, I get the appeal of its apparent simplicity, but sincelibcan'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.
Things done
nix.conf? (See Nix manual)sandbox = relaxedsandbox = truenix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/)Add a 👍 reaction to pull requests you find important.