nix-shell -p always includes a gcc #377
Labels
No labels
Area/build-packaging
Area/cli
Area/evaluator
Area/fetching
Area/flakes
Area/language
Area/profiles
Area/protocol
Area/releng
Area/remote-builds
Area/repl
Area/store
bug
crash 💥
Cross Compilation
devx
docs
Downstream Dependents
E/easy
E/hard
E/help wanted
E/reproducible
E/requires rearchitecture
imported
Needs Langver
OS/Linux
OS/macOS
performance
regression
release-blocker
RFD
stability
Status
blocked
Status
invalid
Status
postponed
Status
wontfix
testing
testing/flakey
ux
No milestone
No project
No assignees
4 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: lix-project/lix#377
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Describe the bug
Any invocation of
nix-shell -p <some-packages>
will always includegcc
in the shell it builds. Usually this isn't much of an issue, but it can become very annoying on disk-space constrained machines, on machines with a slow connection to the cache, or if one wants to use anothercc
which will get shadowed by anynix-shell
, with no hint on that in the documentation (or at least none that i could find).In particular, even
nix-shell -p clang
will still also include agcc
.An issue was filed on this for nix a while ago, but got no response: https://github.com/NixOS/nix/issues/5117
Steps To Reproduce
Expected behavior
The above should result in
cc: command not found
.nix --version
outputAdditional context
This is caused by using
pkgs.runCommandCC
in the templated nix expression used for-p
in https://git.lix.systems/lix-project/lix/src/branch/main/src/nix-build/nix-build.cc#L218. and fixing it requires only usingpkgs.runCommand
instead; but it seems this behaviour was added intentionally; so although afaict it is not documented anywhere it might be that some users depend on it?In either case, I do not think this should be the default behaviour, and it should certainly not be the only behaviour offered.
This is because
nix-shell -p
usespkgs.mkShell
under the hood, which is a wrapper aroundstdenv.mkDerivation
, and thus always gives youstdenv.cc
(GCC on Linux).Making
nix-shell -p
usepkgs.mkShellNoCC
would be a breaking change, and frankly this command is cursed to begin with, but we could maybe make it usemkShellNoCC
as a config option or something? And make that the default in 3.0?Oh oops we missed the whole part about
runCommandCC
and we were slightly wrong — sorry about that 😅. I agree that this is silly behavior, but changing it by default is a bit fraughtwe'd prefer to fix this in cooperation with nixpkgs, by having nixpkgs add a variant of
mkShell
that behaves likerunCommandCC
does currently except that the tools implicit pulled in by the*CC
bit print warnings when used. that shouldn't take any longer to become evident (since such a new variant would be backportable), and when we eventually do switch the default it'll have been visible for a while?Do you mean something other than
mkShellNoCC
?yes; we'd like to have a loud warning about
using cc from `nix-shell -p` without an explicit compiler package being requested is deprecated
when anything usescc
or something like that, whilemkShellNoCC
just doesn't have a compiler at all. we actually use this implicit-cc behavior of nix-shell quite a bit and suspect others might too, and a lix-level warning would be annoying to all those who don'tbut idk. just want to Very Avoid breaking this without adequate warning :/
we also use this extensively ourselves but concur it's very silly it's not selectable. it's not just a cc that you need, you also need a binutils and such, which
nix shell
actually can't do at present at all. it's a multi layered pile of sadness.