Error when trying to run nbdkit python plugin "nbdkit-python-plugin.so: cannot open shared object file: No such file or directory"

Hi, I’m trying to get a basic python plugin for nbdkit to work.

I’m using this shell:

# shell.nix
{ pkgs ? import <nixpkgs> {} }:

let
in pkgs.mkShell {
    buildInputs = with pkgs; [
        nbdkit
        # nbdkit.overrideAttrs (finaAttrs: previousAttrs: {
        #     configureFlags = previousAttrs.configureFlags ++ "--enable-python";
        # })

        (python313.withPackages (ps: with ps; [
            libnbd
            pyserial
        ]))
    ];
}

as you can see, I’ve tried overriding the Flags (which didn’t work, but it doesn’t really matter anyway, since python is enabled by default (configure.ac · master · nbdkit / nbdkit · GitLab), and it’s not disabled in nixpkgs (nixpkgs/pkgs/by-name/nb/nbdkit/package.nix at aae39856f5020c0b5ac80e5dea20508ce40a7e86 · NixOS/nixpkgs · GitHub) from what I can tell.

This is the error with the first line being the command that is run:

# nbdkit --verbose --foreground --tls=off python src/main.py
nbdkit: debug: nbdkit 1.42.1
nbdkit: debug: service mode: TCP/IP
nbdkit: debug: NBD URI: nbd://localhost
nbdkit: error: cannot open plugin "/nix/store/wsnmp47yqmkwhgbm7bi5hl16jy6a222v-nbdkit-1.42.1/lib/nbdkit/plugins/nbdkit-python-plugin.so": /nix/store/wsnmp47yqmkwhgbm7bi5hl16jy6a222v-nbdkit-1.42.1/lib/nbdkit/plugins/nbdkit-python-plugin.so: cannot open shared object file: No such file or directory

To add this functionality you might need to install a separate
plugin package such as nbdkit-python-plugin (Fedora) or
nbdkit-plugin-python (Debian).

Use 'nbdkit --help' or read the nbdkit(1) manual page for documentation.

I don’t think it matters really, but this is the python file:

# src/main.py
API_VERSION = 2

def open(readonly):
    return True

def get_size(h):
    print(h)
    return 1024

def pread(h, buffer, offset, flags):
    buffer[:] = "A" * len(buffer)

So yeah, there’s no other package that has nbdkit in it (from what I can tell). Any ideas what I’m doing wrong?

Figured it out.

# shell.nix
{ pkgs ? import <nixpkgs> {} }:

let
in pkgs.mkShell {
    buildInputs = with pkgs; [
        # nbdkit
        (nbdkit.overrideAttrs (old: {
            buildInputs = old.buildInputs ++ [python313];
            configureFlags = old.configureFlags ++ [
                "--enable-python"
                "PYTHON=${python313}/bin/python3.13"
            ];
        }))

        (python313.withPackages (ps: with ps; [
            libnbd
            pyserial
        ]))
    ];
}

The buildinput is obv. missing python3, so adding and setting it, fixes the issue.

Yeah, it’s kinda obvious…