How to fix `evaluation warning: 'system' has been renamed to/replaced by 'stdenv.hostPlatform.system'`

okay, I switched it to:

              (
                {
                  pkgs,
                  inputs,
                  ...
                }:
                {
                  _module.args = {
                    unstablePkgs = import inputs.unstable {
                      inherit (pkgs) config overlays;
                      localSystem = pkgs.stdenv.hostPlatform;

                    };
                  };
                }
              )

and it does work indeed. Thank you very much !

1 Like

@Erwyn also see specialArgs

_module.args is preferable over specialArgs, where possible. (In this case, it’s possible.)

1 Like

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

1 Like

Thanks for the helpful information! In my case it was caused by this:

https://gitlab.com/ahoneybun/nix-configs/-/blob/main/flake.nix?ref_type=heads#L89

Changing:

${prev.system}

to this:

${prev.stdenv.hostPlatform.system}

fixed it for me.

Use final not prev, whenever possible.

1 Like

What is the difference in this context? It does seem to replace the version of helix from nixpkgs with the upstream tagged version.

final doesn’t depend on overlay ordering. This makes more sense for stdenv, and especially stdenv.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.

See also the wiki entry for this, it’s actually one of the better pages: Overlays - Official NixOS Wiki

2 Likes

Here’s an example where it really mattered: Packages in overlay arguments are different from regular package-set?

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.

2 Likes