I’m trying to run trelby, some screenwriting software. I actually bricked my Ubuntu install when trying to set this up there because wxPython didn’t install, I tried creating venvs and that didn’t work either, and I ended up trying to delete Python entirely… So I ended up here.

I cloned the repo, set up a shell.nix with the required packages, and am now stuck with the same problem I had before: wxPython doesn’t install.

More info
# shell.nix
let
  # We pin to a specific nixpkgs commit for reproducibility.
  # Last updated: 2024-04-29. Check for new commits at https://status.nixos.org/.
  pkgs = import (fetchTarball "https://github.com/NixOS/nixpkgs/archive/cf8cc1201be8bc71b7cbbbdaf349b22f4f99c7ae.tar.gz") {};
in pkgs.mkShell {
  packages = [
    (pkgs.python3.withPackages (python-pkgs: with python-pkgs; [
      # select Python packages here
      setuptools
      wxPython
      lxml
      reportlab
      pytest
    ]))
  ];
}

Output from attempting to run nix-shell:

unpacking 'https://github.com/NixOS/nixpkgs/archive/cf8cc1201be8bc71b7cbbbdaf349b22f4f99c7ae.tar.gz' into the Git cache...
error:
       … while calling the 'derivationStrict' builtin
         at <nix/derivation-internal.nix>:37:12:
           36|
           37|   strict = derivationStrict drvAttrs;
             |            ^
           38|

       … while evaluating derivation 'nix-shell'
         whose name attribute is located at /nix/store/4ab6vrcph07w6ra79bc04fy8bbcmb9r0-source/pkgs/stdenv/generic/make-derivation.nix:331:7

       … while evaluating attribute 'nativeBuildInputs' of derivation 'nix-shell'
         at /nix/store/4ab6vrcph07w6ra79bc04fy8bbcmb9r0-source/pkgs/stdenv/generic/make-derivation.nix:375:7:
          374|       depsBuildBuild              = elemAt (elemAt dependencies 0) 0;
          375|       nativeBuildInputs           = elemAt (elemAt dependencies 0) 1;
             |       ^
          376|       depsBuildTarget             = elemAt (elemAt dependencies 0) 2;

       (stack trace truncated; use '--show-trace' to show the full, detailed trace)

       error: undefined variable 'wxPython'
       at /home/edwinc/Documents/code/trelby/shell.nix:11:7:
           10|       setuptools
           11|       wxPython
             |       ^
           12|       lxml

Cheers!

Edit: solved! Just change the wxPython to wxpython on the shell.nix file, and probably also change the manual fetch from an outdated repo to <nixpkgs> as @[email protected] recommended.

  • hello_hello [comrade/them]@hexbear.netM
    link
    fedilink
    English
    arrow-up
    4
    ·
    edit-2
    5 days ago

    Use a docker/podman container for managing python projects in NixOS NixOS doesn’t follow the filesystem hierarchy standard so a lot of standard tooling won’t work without extra steps.

    The issue here is that the attribute “wxPython” does not exist in nixpkgs and you’ll have to package it yourself. Trelby is also not packaged either.

    Also: https://www.trelby.org/download/

    There are pre-built binaries for Ubuntu, Fedora and flatpak from FlatHub. On NixOS you can setup flatpak via a module in your system config and its my recommendation if you’re not going the docker/distrobox route. You don’t need NixOS for this and I would just recommend something like Fedora Atomic with KDE (Fedora Kinoite)

    The pypi installation method seems like more trouble than its worth.