I’ve tried just about every type of setup I can find for a nix shell with python.

I don’t want to purely use nixpkgs for a lack of some packages and broken packages. I’m trying to use pyside6, but not everything in pyside6 is provided by the package, e.g. tools like uic.

Attempting to use a venv as normal leads to a disconnect between the env and system with libstdc++.so.6 unable to be found. There are a various different flakes I’ve tried to use like the-nix-way/dev-templates#python and others from forum discussions which add stdenv.cc.cc.lib to no avail.

I think the farthest I’ve gotten is with poetry/poetry2nix, where auto-patchelf warns about missing libQt6 libraries. Running with nix run fails to ‘find all the required dependencies’ even when adding qt6.qtbase or qt6.full to the packages. This is that flake, taken from the poetry2nix github with an added devshell:

{
  description = "Python application packaged using poetry2nix";

  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
    poetry2nix.url = "github:nix-community/poetry2nix";
  };

  outputs = { self, nixpkgs, poetry2nix }:
    let
      system = "x86_64-linux";  # Adjust for your system
      pkgs = nixpkgs.legacyPackages.${system};
      inherit (poetry2nix.lib.mkPoetry2Nix { inherit pkgs; }) mkPoetryApplication;
    in {
      packages.${system}.default = mkPoetryApplication {
        projectDir = ./.;
      };

      apps.${system}.default = {
        type = "app";
        program = "${self.packages.${system}.default}/bin/app";
      };

      devShells.${system}.default = pkgs.mkShell {
        packages = [ pkgs.poetry ];
        buildInputs = [ pkgs.qt6.qtbase pkgs.qt6.full pkgs.qt6.wrapQtAppsHook ];
      };
    };
}

It seems kind of hopeless to get it working on NixOS. Does anyone have a working setup I could use for inspiration, or any other tips? I love the nix paradigm, but I’m honestly considering distrohopping with all of the trouble.

  • FizzyOrange@programming.dev
    link
    fedilink
    English
    arrow-up
    3
    ·
    5 days ago

    This doesn’t surprise me in the least. For the longest time the only way to update Python was to compile it from source… They just don’t care too much about making their tooling work nicely. And that’s before you even add the complexity of Nix.

    I would maybe just not use Nix for this at all and try something like Rye, which is a third party attempt to fix the Python mess. It lets you specify a Python version and supports lock files so in theory everything is actually reproducible… so it’s at least part way to what you’d have with Nix.