Building Python Package with Dynamically Linked System Library, `attribute 'dev' missing`

I’m still pretty naive with Nix, but I’m trying to build and package a larger program and I’m having issues with one of the dependencies I also have to package. Namely pyzstd. I could let it use the copy of the zstd source as it mentions here, but for the sake of using system libraries if possible I decided try my hand at it.

I’m using pkgs/development/python-modules/indexed-zstd/default.nix as a reference since it also just simply needs zstd like how I do and using the documentation on packaging existing software, thus making my own version as pyzstd.nix

{ lib
, buildPythonPackage
, fetchPypi
, zstd
, cython
  _pinData = import ./pin.nix;
  pinData = _pinData.pyzstd;
buildPythonPackage rec {
  pname = "pyzstd";
  version = pinData.version;

  src = fetchPypi {
    inherit pname version;
    hash = pinData.hash;

  nativeBuildInputs = [

  buildInputs = [

  pythonImportsCheck = [

  setupPyBuildFlags = [

And the abridged pin.nix

  # [...] Other unrelated pins for the larger project.
  "pyzstd" = {
    "version" = "0.15.9";
    "hash" = "sha256-y/3ebFdo/6XS8UEnu8HXw8LQPAzq6wc2lGGX4GJ1zMc=";

and abridged default.nix

  pkgs = import <nixpkgs> { };
  # [...] Other unrelated packages for the larger project.
  pyzstd = pkgs.python3Packages.callPackage ./pyzstd.nix { };

But then it throws that the dev attribute for zstd does not exist. Copying and pasting the reference also results in the same error.

       … while evaluating the attribute 'drvPath'

         at /nix/store/91gykwfb9935iynbpyq0ykvr30lvb4ia-nixos/nixos/lib/customisation.nix:263:7:

          262|     in commonAttrs // {
          263|       drvPath = assert condition; drv.drvPath;
             |       ^
          264|       outPath = assert condition; drv.outPath;

       … while calling the 'derivationStrict' builtin

         at /builtin/derivation.nix:9:12: (source not available)

       (stack trace truncated; use '--show-trace' to show the full trace)

       error: attribute 'dev' missing

       at /home/jarrod/Workspace/XXX/pyzstd.nix:25:5:

           24|   buildInputs = [
             |     ^
           26|   ];

9hp71n from the Nix Matrix chat:

You need to pass inherit (pkgs) zstd to python3Packages.callPackage because apparently there is python310Packages.zstd (python bindings to zstd) that would get picked up instead of just pkgs.zstd by default.\n

So I added inherit (pkgs) zstd; in the let block and that seemed fix the issue.

1 Like