Open babbaj opened 3 years ago
I also noticed that pointing cc
to clang is not very easy via nix-shell -p clang
due to always-present gcc
:
$ nix-shell -p gcc -p clang --command 'cc --version'
gcc (GCC) 10.3.0
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ nix-shell -p clang -p gcc --command 'cc --version'
gcc (GCC) 10.3.0
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
I marked this as stale due to inactivity. → More info
This issue has been mentioned on NixOS Discourse. There might be relevant details there:
Is your feature request related to a problem? Please describe. When creating a nix-shell with -p, even with --pure, gcc will be included in the $PATH and it will take precedence over any explicitly listed package. This makes it very annoying to try to build a program with clang instead of gcc and requires creating a shell.nix or setting cmake variables to work around.
Describe the solution you'd like nix-shell is currently created with pkgs.runCommandCC, use pkgs.runCommand instead to just remove gcc
Describe alternatives you've considered Getting the package arguments to be in the $PATH before the default packages would also work without being a potentially breaking change