Building a python package that uses uv

I wanted to test out the Crewai library, for use in a new project. I tried to build it in a shell.nix file but failed, reading their README more closely I saw that they list UV as an dependency. I’ve searched for help with packaging an UV python package with nix, but found no help. How could I achieve this?

Here is my current shell.nix file:

let
  pkgs = import <nixpkgs> {};
  crewai =
    pkgs.python3Packages.buildPythonPackage rec {
      pname = "crewai";
      version = "0.83.0";
      src = pkgs.fetchFromGitHub {
        owner = "crewAIInc";
        repo = "crewAI";
        rev = "v${version}";
        sha256 = "sha256-o57PxTVXHm9OnuCfsNCNIZtAUxCkyRvNLb2sW8HxIGQ=";
      };
      doCheck = false;
    };
in pkgs.mkShell {
  name = "OpenAI";
  packages = [
    (pkgs.python3.withPackages (py-pkgs: [
      py-pkgs.openai
    ]))
    crewai
  ];

  shellHook = ''
    source .env
  '';
}

Maybe you should check out this PR:

1 Like