Trying to update a Package for polychromatic, getting common.py missing

{ lib
, fetchFromGitHub
, bash
, glib
, gdk-pixbuf
, gettext
, imagemagick
, ninja
, meson
, sassc
, python3Packages
, gobject-introspection
, wrapGAppsHook
, libappindicator-gtk3
, libxcb
, qt5
, ibus
, usbutils
}:

python3Packages.buildPythonApplication rec {
  name = "polychromatic";
  version = "0.8.0";
  format = "other";

  src = fetchFromGitHub {
    owner = "polychromatic";
    repo = "polychromatic";
    rev = "v${version}";
    #sha256 = "sha256-H++kQ3Fxw56avEsSE1ctu5p0s50s0eQ+jL5zXS3AA94=";
    sha256 = "sha256-ym2pcGUWM5zCUx/lYs+WECj+wbyBtWnx04W/NRXNKlw=";
  };

  postPatch = ''
    patchShebangs scripts
    substituteInPlace scripts/build-styles.sh \
      --replace '$(which sassc 2>/dev/null)' '${sassc}/bin/sassc' \
      --replace '$(which sass 2>/dev/null)' '${sassc}/bin/sass'
    substituteInPlace pylib/common.py \
      --replace "/usr/share/polychromatic" "$out/share/polychromatic"
  '';

  preConfigure = ''
    scripts/build-styles.sh
  '';

  propagatedBuildInputs = with python3Packages; [
    colorama
    colour
    openrazer
    pyqt5
    pyqtwebengine
    requests
    setproctitle
    libxcb
    openrazer-daemon
    libappindicator-gtk3
    ibus
    usbutils
  ];

  nativeBuildInputs = with python3Packages; [
    gettext
    gobject-introspection
    meson
    ninja
    sassc
    wrapGAppsHook
    qt5.wrapQtAppsHook
  ];



  dontWrapGapps = true;
  dontWrapQtApps = true;

  makeWrapperArgs = [
    "\${gappsWrapperArgs[@]}"
    "\${qtWrapperArgs[@]}"
  ];

  meta = with lib; {
    homepage = "https://polychromatic.app/";
    description = "Graphical front-end and tray applet for configuring Razer peripherals on GNU/Linux.";
    longDescription = ''
      Polychromatic is a frontend for OpenRazer that enables Razer devices
      to control lighting effects and more on GNU/Linux.
    '';
    license = licenses.gpl3;
    platforms = platforms.linux;
    maintainers = with maintainers; [ evanjs ];
  };
}

With the following error:

[jrgiacone@nixos:~/flake]$ uswitch
warning: Git tree '/home/jrgiacone/.config/.dotfiles' is dirty
building the system configuration...
warning: Git tree '/home/jrgiacone/.config/.dotfiles' is dirty
error: builder for '/nix/store/d543a0jh13gy40dj9k3j21b6y3cxvvbf-polychromatic.drv' failed with exit code 1;
       last 10 log lines:
       > scripts/build-man-pages.sh: interpreter directive changed from "#!/bin/bash" to "/nix/store/dsd5gz46hdbdk2rfdimqddhq6m8m8fqs-bash-5.1-p16/bin/bash"
       > scripts/validate-scdoc.sh: interpreter directive changed from "#!/bin/bash" to "/nix/store/dsd5gz46hdbdk2rfdimqddhq6m8m8fqs-bash-5.1-p16/bin/bash"
       > scripts/create-locales.sh: interpreter directive changed from "#!/bin/bash" to "/nix/store/dsd5gz46hdbdk2rfdimqddhq6m8m8fqs-bash-5.1-p16/bin/bash"
       > scripts/validate-py.sh: interpreter directive changed from "#!/bin/bash" to "/nix/store/dsd5gz46hdbdk2rfdimqddhq6m8m8fqs-bash-5.1-p16/bin/bash"
       > scripts/validate-scss.sh: interpreter directive changed from "#!/bin/bash" to "/nix/store/dsd5gz46hdbdk2rfdimqddhq6m8m8fqs-bash-5.1-p16/bin/bash"
       > scripts/create-files-for-opt.sh: interpreter directive changed from "#!/bin/bash" to "/nix/store/dsd5gz46hdbdk2rfdimqddhq6m8m8fqs-bash-5.1-p16/bin/bash"
       > scripts/build-locales.sh: interpreter directive changed from "#!/bin/bash" to "/nix/store/dsd5gz46hdbdk2rfdimqddhq6m8m8fqs-bash-5.1-p16/bin/bash"
       > scripts/packaging/generate-debian-changelog.py: interpreter directive changed from "#!/usr/bin/python3" to "/nix/store/zdba9frlxj2ba8ca095win3nphsiiqhb-python3-3.10.8/bin/python3"
       > scripts/packaging/prepare-preview-ppa.sh: interpreter directive changed from "#!/bin/bash" to "/nix/store/dsd5gz46hdbdk2rfdimqddhq6m8m8fqs-bash-5.1-p16/bin/bash"
       > substitute(): ERROR: file 'pylib/common.py' does not exist
       For full logs, run 'nix log /nix/store/d543a0jh13gy40dj9k3j21b6y3cxvvbf-polychromatic.drv'.
error: 1 dependencies of derivation '/nix/store/j4ha42p0wqzcp1j0s24bdk74v7clyvvs-home-manager-path.drv' failed to build
error: 1 dependencies of derivation '/nix/store/7p8n645026kwar7wmgicx0y3my4mh1ig-home-manager-generation.drv' failed to build
error: 1 dependencies of derivation '/nix/store/f73b0rg03pdw32x1mdrbg25ya35v26bl-user-environment.drv' failed to build
error: 1 dependencies of derivation '/nix/store/s1wb0bp781ls1nq5cadqn8i7dfmmjim2-etc.drv' failed to build
error: 1 dependencies of derivation '/nix/store/cmac4l9yxxaaci54nrkxwiq2bnk4m86c-nixos-system-nixos-23.05.20221203.61a8a98.drv' failed to build

that part no longer works and please use code blocks when pasting code.

Sorry about that! What would be the correct or new approach in this case, I am still very new to nix and learning. Would like to contribute in any way I can!

I don’t know. The source code upstream changed and maybe the file was just renamed.

Looking through the source it may have been renamed to polychromatic instead of pylib, I will give that a try later

Hi it worked by renaming it and compiling, however, I get an error now stating “cannot locate data directory” and to please reinstall the package. One step forward and another sideways, unsure how to proceed from here as I did not see a lot of cases online that ran into this, I tried looking at the package build from the AUR but couldn’t notice anything majorly different.

They are looking at some relative paths and hardcoding some. That likely needs to be adjusted.

I had asked on polychromatic and it looked like as you noteded he extracted it from common.py and moved it into paths.py I will try it out and upload a PR if it works! Thanks for the help!