Hi there,
I’d like to package the App Boxflat for the use with NixOS. I tried using pkgs.buildPythonPackage
but couldn’t get it to work and then tried to copy and adjust the Oversteer package and couldn’t get it to work.
Then with the help of LLMs I got something like this:
{
lib,
stdenv,
fetchFromGitHub,
python3,
gtk4,
libadwaita,
cairo,
gobject-introspection,
pkg-config,
wrapGAppsHook4,
pkexec ? null,
makeWrapper,
graphene,
glib,
pango,
gdk-pixbuf,
}:
let
version = "v1.25.2";
pythonEnv = python3.withPackages (
ps: with ps; [
pyyaml
psutil
pyserial
pycairo
pygobject3
evdev
]
);
in
stdenv.mkDerivation {
inherit version;
pname = "boxflat";
src = fetchFromGitHub {
owner = "lawstorant";
repo = "boxflat";
rev = version;
sha256 = "sha256-EB4Q8BeTZTmjfA+LRUUHdTBxoH+RpOroZZFmsbDk49U=";
};
nativeBuildInputs = [
pkg-config
wrapGAppsHook4
gobject-introspection
makeWrapper
pythonEnv
];
buildInputs = [
gtk4
libadwaita
cairo
glib
graphene
pango
gdk-pixbuf
];
installPhase = ''
# Create necessary directories
mkdir -p $out/bin
mkdir -p $out/lib/python${pythonEnv.pythonVersion}/site-packages/boxflat
mkdir -p $out/share/boxflat/data
mkdir -p $out/lib/udev/rules.d
# Copy all project files to site-packages
cp -r ./* $out/lib/python${pythonEnv.pythonVersion}/site-packages/boxflat/
# Install the data folder to the correct location
cp -r data/* $out/share/boxflat/data/
# Install udev rules
cp udev/99-boxflat.rules $out/lib/udev/rules.d/99-boxflat.rules
# Create wrapper script
makeWrapper ${pythonEnv}/bin/python $out/bin/boxflat \
--set PYTHONPATH "$out/lib/python${pythonEnv.pythonVersion}/site-packages:${pythonEnv}/${pythonEnv.sitePackages}" \
--set GI_TYPELIB_PATH "$GI_TYPELIB_PATH:${glib}/lib/girepository-1.0:${gtk4}/lib/girepository-1.0:${libadwaita}/lib/girepository-1.0:${graphene}/lib/girepository-1.0:${glib}/lib/girepository-1.0:${pango}/lib/girepository-1.0:${gdk-pixbuf}/lib/girepository-1.0" \
--add-flags "$out/lib/python${pythonEnv.pythonVersion}/site-packages/boxflat/entrypoint.py --data-path $out/share/boxflat/data"
'';
meta = with lib; {
homepage = "https://github.com/Lawstorant/boxflat";
changelog = "https://github.com/Lawstorant/boxflat/releases/tag/${version}";
description = "Boxflat for Moza Racing. Control your Moza gear settings!";
mainProgram = "boxflat";
license = licenses.gpl3;
maintainers = [ maintainers.jensereal ];
platforms = platforms.unix;
};
}
it is now packaging but I’m getting an error when trying to run the program
Data path: /nix/store/96hrr3h4gcskhmg989mzdzfmxlh7q71r-boxflat-v1.25.2/share/boxflat/data
(process:96176): Gtk-WARNING **: 15:27:23.436: Unknown key gtk-modules in /home/<user>/.config/gtk-4.0/settings.ini
(python:96176): Adwaita-WARNING **: 15:27:23.589: Using GtkSettings:gtk-application-prefer-dark-theme with libadwaita is unsupported. Please use AdwStyleManager:color-scheme instead.
Segmentation fault (core dumped)
Someone has an idea what I can do about it? And I’m sure that you can optimize the package, but this is the first time for me trying to package an app.
Any help is appreciated