Closed skeggse closed 1 month ago
Use nix-shell -p "python3.withPackages (ps: [ ps.bcc ])"
.
Explanation: python3.pkgs.bcc != bcc. The first one acts as a python module that will set the python path correctly whereas the later is more like a python application that doesn't pollute PYTHONPATH in case you want to mix it into a python project.
Hmmm, ok. I guess the explanation kinda makes sense (still trying to figure out this ecosystem), but how do I actually get that to work? The command provided doesn't, and my attempts to integrate it into my shell.nix
have also been unsuccessful.
It's worth noting that - to my knowledge - there isn't a bcc
package available on pypi.org.
$ nix-shell -p 'python3.withPackages (ps: [ ps.bcc ])'
error:
… while calling the 'derivationStrict' builtin
at /builtin/derivation.nix:9:12: (source not available)
… while evaluating derivation 'shell'
whose name attribute is located at /nix/store/07qksi2rpnqxxl2rbxzgifrfki698rr3-nixos-24.05/nixos/pkgs/stdenv/generic/make-derivation.nix:333:7
… while evaluating attribute 'buildInputs' of derivation 'shell'
at /nix/store/07qksi2rpnqxxl2rbxzgifrfki698rr3-nixos-24.05/nixos/pkgs/stdenv/generic/make-derivation.nix:380:7:
379| depsHostHost = elemAt (elemAt dependencies 1) 0;
380| buildInputs = elemAt (elemAt dependencies 1) 1;
| ^
381| depsTargetTarget = elemAt (elemAt dependencies 2) 0;
(stack trace truncated; use '--show-trace' to show the full trace)
error: attribute 'bcc' missing
at «string»:1:135:
1| {...}@args: with import <nixpkgs> args; (pkgs.runCommandCC or pkgs.runCommand) "shell" { buildInputs = [ (python3.withPackages (ps: [ ps.bcc ])) ]; } ""
| ^
Did you mean one of bcf, bcg, bch, bap or bcdoc?
You need a recent-ish nixos unstable for this to work, the python package was added recently in 05a7a89754284d320157e6c0325e4d8442dbd35b and this was not backported to 24.05
I see, ok. I'm not on unstable (it's seeming like maybe most NixOS users are on unstable?) and I'd rather not be, so I'll keep my workaround for now.
it's seeming like maybe most NixOS users are on unstable
I mix and match but we've been years without the bcc python package so I think it's more of a "very few people try to actually use bcc" thing.
I see no reason not to backport this now we know someone actually cares about this, so I've opened https://github.com/NixOS/nixpkgs/pull/349088 -- it'll (probably) make it to stable eventually. Until then that workaround is probably a good idea.
Thanks!
Describe the bug
If I
nix-shell -p python3 bcc
, I cannotimport bcc
without manually tweaking thePYTHONPATH
.Steps To Reproduce
Steps to reproduce the behavior:
nix-shell -p python3 bcc
python3 -c 'import bcc'
Expected behavior
No import error.
Additional context
I can fix this by running:
Notify maintainers
@ragge @Mic92 @thoughtpolice @martinetd
Metadata
Please run
nix-shell -p nix-info --run "nix-info -m"
and paste the result.Add a :+1: reaction to issues you find important.