afarkas
afarkas

Reputation: 61

Nix: How to override stdenv.cc with overlay globally?

I would like to override stdenv.cc to a specific GCC version (not necessarily in nixpkgs) globally using an overlay (i.e. without changing nixpkgs). Is there a way to do that?

An overlay like this causes an infinite recursion (since package gcc49 has stdenv as input):

self: super:
{
  stdenv = super.overrideCC super.stdenv super.gcc49;
}

What is the correct way to change the stdenv.cc globally?

Setting manually stdenv = ... in import nixpkgs is not feasible, since I would like to replace the cc not only when building/using nix expressions but also in e.g. nix-shell -p package.

Can someone help me with this?

Upvotes: 6

Views: 2618

Answers (1)

luc65r
luc65r

Reputation: 21

(import <nixpkgs> { overlays = [(self: super: { gcc = self.gcc10; })]; }).stdenv.cc

This returns a derivation for gcc-10.1.0, so it could work.

Upvotes: 2

Related Questions