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.

  • rutrum@lm.paradisus.day
    link
    fedilink
    English
    arrow-up
    4
    ·
    6 months ago

    I’ve had the same problem running numpy. Shockingly with a library so popular I havent found a way to make an environment with it work. I also had the most success with poetry, so I think you’re on the right track.

    • degenOP
      link
      fedilink
      English
      arrow-up
      2
      ·
      6 months ago

      Funny story, the full project uses pandas which pulls in numpy and I was running into issues there too. I think it was saying I was trying to import numpy from within it’s own source tree, which was weird.

      Although I couldn’t get any venv approach working with it, having the pandas package in my flake allowed it to import.

      There’s just such a mix of different issues with each approach that it’s so hard to navigate. I feel close with poetry2nix though, just gotta get it runnable lol

      • rutrum@lm.paradisus.day
        link
        fedilink
        English
        arrow-up
        2
        ·
        6 months ago

        Pff, if pandas gets me numpy that works that may not be a bad hack. I’ll try this! Sorry I dont know how to fix qt!