aliases: warnOnInstantiate all aliases if config.warnAliases=true#414658
aliases: warnOnInstantiate all aliases if config.warnAliases=true#414658pbsds wants to merge 2 commits intoNixOS:masterfrom
config.warnAliases=true#414658Conversation
This makes use of 'self' explicit in the let block, and communicates that 'super' should not generally be used in this file.
8689eeb to
3b5db57
Compare
|
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: |
hsjobeki
left a comment
There was a problem hiding this comment.
Neat change.
I see two open questions:
libofpkgsshould be strictly equal to just importinglibotherwise that could open the box of pandora. cc @roberth @infinisil- Should there be a more granular decision for
warnAliases?
| else | ||
| name: alias: alias; | ||
|
|
||
| lib = lib'.extend ( |
There was a problem hiding this comment.
use of extend was discouraged. cc @roberth.
possibly extend lib without calling extend,
I am a bit worried about this because after this PR:
pkgs.lib != lib
A similar change was made in flake.nix and was highly regreted. We have to maintain that parallelism now and people are confused because about why lib is having different functions sometimes - depending how you import it.
Maybe bind __aliasWarningAttrName = { warnAliases = true; } ? That would also allow perPackage decisions which by default inherit true from the config of pkgs ?
(Just playing with ideas here)
There was a problem hiding this comment.
How about renaming lib to _lib in the file with a comment about how only using the "whitelisted" functions from a inherit (_lib) ...; in the let binding is allowed? Then we're free to make custom versions of some of the lib functions.
Maybe bind
__aliasWarningAttrName = { warnAliases = true; }? That would also allow perPackage decisions which by default inherit true from the config of pkgs ?
(Just playing with ideas here)
I don't quite understand what you mean by this nor what it achieves.
Wouldn't adding simple nixos module {
lib,
...
}:
{
config.nixpkgs.config.warnAliases = lib.mkOptionDefault true;
}work? |
|
Some aliases (e.g.
|
|
This is a very welcome change in behavior, but I think it needs to be a bit bolder, so that it can avoid complicated workarounds. let inherit (pkgs) handleAlias;
#...
foo = handleAlias { old = "foo"; new = "bar"; value = bar; release = 2511; };Then Speaking of smuggling ;), I've snuck a |
Another alias related draft PR can be found at #442066, where I intend to introduce "structured aliases" to solve some of these same problems (eventually). |
|
I'm much more interested in mass-migrating the current aliases to that system once it is ready |
The problem with ever dropping aliases from
aliases.nixis that downstream users have no idea that certain attributes they rely on have been an alias for years. With warnings however we can expect users to be able to migrate, which in turn enables dropping aliases a lot quicker. With this merged i believe #414656 is very much possibleTested with
nix-envand on my nixos config.I wanted to make
config.warnAliasesdefault tofalsefor normal nixpkgs buttruefor nixos, but i could not figure out how to set that default without it then ignoring whatever the user configures in their nixos config.I took extra care to make sure the implementation is performant and that there are no huge footguns in
aliases.nix. It is possible for.__aliasWarningAttrNameto leak, which is the case forvamp.vampSDK, but i believe this is not a real issue.Showcase:
The
jami-clientalias is defined as:If you try to use it you wouldn't know it is an alias unless you use the nuclear option
allowAliases=false:but with this PR you will instead see
Here is the stderr output of
nix-env --extra-experimental-features no-url-literals --option system x86_64-linux -f ./. -qaP --json --meta:https://gist.github.com/pbsds/bd6b4211086db4d6707cba98e0fcf5c7
(all of these examples had
.outputNameand.systemexcluded fromwarnOnInstantiate)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.