I was so confused after I got this warning when I was still using Determinate Nix. Currently Iām redoing my whole config to use upstream Nix and still got the same error after running the check.
At first I thought it was only related to determinate. I guess I didnāt keep up with the nixpkgs changes until recently lmao
final doesnāt depend on overlay ordering. This makes more sense for stdenv, and especiallystdenv.hostPlatform.system, because you want to get the āfinalā value of those, after all other overlays have been applied. In practice it should rarely make a difference, but itās one of those little details.
Stuff like system and stdenv are involved in bootstrap, so prev.system and prev.stdenv are not things you should rely on.
And in general itās always a best-practice to use final in an overlay, except for obvious infrec scenarios, e.g. for foobar = prev.foobar.override { ... } where youād have to use prev as final would infrec. You want your overlays to actually take effect - final is the nixpkgs instance that ensures that.
Iāve tried to substitute system both on the left and righthandside there, but got an error
error: attribute 'currentSystem' missing
at /nix/store/kfcxqcxb9hcq6x33sg4cmwakbb1ifwg9-source/pkgs/top-level/impure.nix:17:29:
16| localSystem ? {
17| system = args.system or builtins.currentSystem;
| ^
18| },
But just replacing the righthandside (see below) appears to work
nixpkgs.overlays = [
(final: prev: {
# unstable = nixpkgs-unstable.legacyPackages.${prev.system};
# use this variant if unfree packages are needed:
unstable = import nixpkgs-unstable {
inherit prev;
system = prev.stdenv.hostPlatform.system;
config.allowUnfree = true;
config.android_sdk.accept_license = true;
};
})
];
with this nix flake update and nixos-rebuild switch run without warnings.
But this seems still a bit weird to me, if system should be replaced with stdenv.hostPlatform.system, why do I still need to leave it just system on the left hand side?
I mean, the entire block makes almost zero sense, using an overlay just to pass a pkgs set into the module system, that pointless inherit prev that clearly shows the author has no idea what inherit does or what import nixpkgs does, the deprecated system.
But it is just copied from the wiki, unfortunately the well is poisoned.
I initially intended to ask if there was any particular reason why the wiki example used prev (I had a hunch there was no good reason, but I couldnāt directly map the previous discussion about final vs prev in this thread to this example. But forgot to actually add that to my initial comment).
Thanks for the clarification, that in this instance too prev was the wrong choice.
I hope this doesnāt go too much off topic here, but:
Despite having spent a good amount of time reading through the official and inofficial wiki, the nixpkgs manual, and forum posts, I am still learning. And my initial reply was also in trying to better understand the wiki snippet.
which appears to correspond to what was discussed in this thread here.
I assume the syntax (final.stdenv.hostPlatform) system; means basically system = final.stdenv.hostPlatform.system;.
I started reading Overlays - Official NixOS Wiki but this aspect of the inherent syntax appears to be still missing in that page.
For a newcomer I think the nix.dev tutorials are a bit nicer, especially the language one: Nix language basics ā nix.dev documentation (inherit is this heading). Itās really the first document you should read when learning about nix.