Issue with python runtime dependencies in flake

Hello,

I am trying to package a python script of mine in a flake but I can’t get the runtime dependencies to work properly. The package depends on the python 3 packages pyserial and paho-mqtt, which are both in nixpkgs.

Building the flake succeeds but running the flake results in the error ModuleNotFoundError: No module named 'serial'. I would greatly appreciate help in getting the modules correctly linked at runtime.

Here’s the layout of the repo:

.
├── flake.nix
├── README.md
├── setup.py
└── src
    └── thruster_io_mqtt.py

setup.py:

from setuptools import setup

setup(
    name='thruster-io-mqtt',
    version='v1.1',
    entry_points={
        'console_scripts': ['thruster-io-mqtt = thruster_io_mqtt:main']
    },
)

flake.nix:

{
  description = "MQTT communication relay for ******";
  
  inputs.nixpkgs.url = "nixpkgs/nixos-23.11";

  outputs = { self, nixpkgs }: 
  let 
    allSystems = [
      "x86_64-linux"
      "aarch64-linux"
    ];

    forAllSystems = f: nixpkgs.lib.genAttrs allSystems (system: f {
      pkgs = import nixpkgs { inherit system; };
    });
  in
  {
    packages = forAllSystems ({ pkgs }: {
      default = pkgs.python3Packages.buildPythonApplication rec {
        pname = "thruster-io-mqtt";
        src = self;
        version = "v1.1";
        propogatedBuildInputs = with pkgs.python3Packages; [
          pyserial
          paho-mqtt
        ];
        doCheck = false;
      };
    });
  };
}

Just checking – do you have propagatedBuildInputs misspelled in the actual flake, or just in what you pasted here? That might cause an issue, if so.

@bowmanjd that was it lol :melting_face:

Thanks for the help!

1 Like

Oh, good job! Glad it is working!