Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update nix-build.cc: don't add gcc automatically #9836

Closed
wants to merge 1 commit into from

Conversation

phip1611
Copy link
Contributor

Motivation

nix-shell -p gcc13 --run "gcc --version" always prints the version of gcc12, the current default gcc. This doesn't work as expected. In a flake shell however, it works as expected.

With this change, this doesn't happen anymore.

Context

This changes arises from this upstream discussion:

NixOS/nixpkgs#283248 (comment)

I didn't test this but it looks as it would work.

Priorities and Process

Add 👍 to pull requests you find important.

The Nix maintainer team uses a GitHub project board to schedule and track reviews.

`nix-shell -p gcc13 --run "gcc --version"` always prints the version of gcc12, the current default gcc. This doesn't work as expected. In a flake shell however, it works as expected.

With this change, this doesn't happen anymore.
@phip1611 phip1611 requested a review from edolstra as a code owner January 23, 2024 16:42
@roberth roberth added the nix-shell nix-shell, nix develop, nix print-dev-env, etc label Jan 23, 2024
@roberth
Copy link
Member

roberth commented Jan 27, 2024

nix-shell -p should never have been hardcoded into Nix, because changes like this will break some users' shells when they update Nix. That's not how Nix is supposed to work.
I think this behavior should be behind a --no-cc flag for that reason.
Long term, we want to empower Nixpkgs and other expressions to provide such behavior; e.g.

--no-cc is obviously not great either, because it's something to be learned and easy to forget. Perhaps we could warn when one of the parameters starts with gcc or clang? That's terribly ad hoc, but such is the nature of nix-shell -p.

@edolstra
Copy link
Member

I think we shouldn't change the legacy interface at this point. You can use nix shell, which doesn't include gcc.

@phip1611
Copy link
Contributor Author

Makes sense. I'm just used to nix-shell :D

Thanks!

@szmarczak
Copy link

@phip1611 @roberth @edolstra The issue is that https://nixos.org/ does use nix-shell -p which is extremely confusing for newcomers. It shouldn't be that hard to use GCC 14. People might use Docker or some other distro and install brew instead...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
nix-shell nix-shell, nix develop, nix print-dev-env, etc
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants