I don’t recommend go install gcc to environment.systemPackages but always use a nix-shell for every project for the following reasons:
- Once you have all the build tools required for your project defined in a
shell.nixit is easy to move between machines or share your expression with colleges. - Compiling any C library installed with nix does not work unless you use a nix-shell. This is because our gcc package is actually a shell script that receives location of library/header paths through environment variables. These environment variables are only set if you add packages to
buildInputswithin ashell.nix. You can read more about this here
If it becomes to tedious to setup a shell.nix and run nix-shell in every project. Have a look at this page in particular nixify and nix-direnv