33 lines
716 B
Nix
33 lines
716 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 = ''
|
|
[ ! -d .venv ] && ${pythonWrapped}/bin/python3 -m venv .venv
|
|
[ -f .venv/bin/activate ] && source .venv/bin/activate
|
|
'';
|
|
}
|