nixos/system/home/programming/python/pyshell.nix
Evie Litherland-Smith e6873dbd77 Add pyshell.nix helper function for making wrapped python shells
Just import, optionally changing python version or adding extra
packages (e.g. poetry) to the shell

Update default python env

Remove pyshell template from Emacs templates due to new change
2024-12-17 11:54:22 +00:00

32 lines
651 B
Nix

{
pkgs ? import <nixpkgs> { },
python3 ? pkgs.python3,
extraPackages ? with pkgs; [ uv ],
}:
let
inherit (pkgs) lib;
ldlibs = lib.makeLibraryPath (
with pkgs;
[
stdenv.cc.cc
glibc
zlib
zstd
]
);
pythonWrapped = pkgs.symlinkJoin {
name = "python";
paths = [ python3 ];
buildInputs = [ pkgs.makeWrapper ];
postBuild = ''
for file in $out/bin/*; do wrapProgram "$file" --prefix LD_LIBRARY_PATH : "${ldlibs}"; done
'';
};
in
pkgs.mkShellNoCC {
packages = [ pythonWrapped ] ++ extraPackages;
shellHook = ''
[ -f .venv/bin/activate ] && source .venv/bin/activate
'';
}