Skip to content

Instantly share code, notes, and snippets.

@tshipenchko
Created November 14, 2023 12:30
Show Gist options
  • Save tshipenchko/db9fcf9da3f2613d185e2ea4a86f073d to your computer and use it in GitHub Desktop.
Save tshipenchko/db9fcf9da3f2613d185e2ea4a86f073d to your computer and use it in GitHub Desktop.
nix-shell + python w/ integrated dependencies
{ pkgs ? import <nixpkgs> { } }:
let
ld_library_path = pkgs.lib.makeLibraryPath (with pkgs; [
stdenv.cc.cc # for greenlet support
]);
in
pkgs.symlinkJoin {
name = "dev-env-python311-cc-libpq";
paths = with pkgs; [ python311 postgresql ];
nativeBuildInputs = [ pkgs.makeWrapper ];
postBuild = ''
wrapProgram $out/bin/python3.11 --set LD_LIBRARY_PATH "${ld_library_path}"
'';
}
{ pkgs ? import <nixpkgs> { } }:
pkgs.mkShell {
buildInputs = [ (import ./default.nix { inherit pkgs; }) ];
}
@tshipenchko
Copy link
Author

Option without LD_LIBRARY_PATH

{ pkgs ? import <nixpkgs> { } }:

pkgs.symlinkJoin {
  name = "dev-env-python311-libpq";
  paths = with pkgs; [ python311 postgresql ];
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment