How to use `gcc_multi` with a specific GCC version in nixpkgs?

Published by Philipp Schuster on

I recently came across the problem that pkgs.gcc_multi comes with gcc in version 12 but I needed version 11. While nixpkgs exports gcc in multiple versions (pkgs.gcc, pkgs.gcc11, pkgs.gcc12, pkgs.gcc13), pkgs.gcc_multi is only exported once, backed with the version coming from pkgs.gcc. However, using another, specific gcc version is fairly simple.

In <nixpkgs at NixOS 23.11>/pkgs/top-level/all-packages.nix we can find gcc_multi. This is aliased to pkgs.wrapCCMulti gcc (function call), which is defined in the same file. So to use a specific version, you just have to define:

gcc11_multi = pkgs.wrapCCMulti pkgs.gcc11;

// or

gcc13_multi = pkgs.wrapCCMulti pkgs.gcc13;

PS: I would much prefer publishing this in an official NixOS wiki post than on my blog, but unfortunately, I couldn’t find a document that already talks about gcc_multi. I might work on fixing this soon, but let’s see.

UPDATE: Added it to

Philipp Schuster

Hi, I'm Philipp and interested in Computer Science. I especially like low level development, making ugly things nice, and de-mystify "low level magic".


Leave a Reply

Your email address will not be published. Required fields are marked *