Set-flag priority Example and/or Issue

When installing gcc, I try to set the priority, but get the following result:

I searched for examples found a couple, but they seem similar. Is there something I’m doing wrong?

$ nix-env --version                               
nix-env (Nix) 2.11.1

Related Reading:

What is already installed via nix-env?

Please use nix-env -q to check.

As the message clearly says, that you shall set the priority of the already installed package.

Despite this questions, why are you trying to install gcc at all via nix-env, especially as there seems to be already a gcc available on the system.

Why don’t use the gcc you already have?

It says “of one of the conflicting packages” and lists the not-installed one as conflicting. So I’d have to disagree. If it did say “set the priority of the already installed package” I would’ve known what to do.

Because I want a different version


$ nix-env -iA nixpkgs.THING1

Blah blah priority of `/nix/store/blahblahblah-thing1-0.0.1` 
conflicts with        `/nix/store/blahblahblah-thing2-2.2.2`

$ nix-env --set-flag priority 9 thing2-2.2.2
$ nix-env -iA nixpkgs.THING1
$ nix-env --set-flag priority 0 thing1-0.0.1
$ nix-env --set-flag priority 10 thing2-2.2.2

It seems rather round-about but I don’t see another way

It says nix-env --set-flag priority NUMBER INSTALLED_PKGNAME

Then use a nix-shell for the project that requires the different version.