NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
18.35k stars 14.31k forks source link

Add Touché #212065

Open Zahrun opened 1 year ago

Zahrun commented 1 year ago

Project description The desktop application to configure Touchégg

Metadata

Zahrun commented 1 year ago

@davidak @bobby285271

ghost commented 11 months ago

I gave this a shot, but C++ has been my mortal enemy for years because they haven't been bother to come up with a proper dependency management system. You basically have to be on the same system as the developer to have a chance at having the same environment.

My attempt ends up with syntax errors in glib-2.0 :shrug: The amazing thing is that 2.0 somehow doesn't mean 2.0, but can be anything from 2.0 to 2.78 (the current actual version of glib in nixpkgs). Makes 0 sense.

{
  # With glib2-76-2 as on debian woody at the moment
  pkgs ? (import (builtins.fetchTarball 
    "https://github.com/nixos/nixpkgs/tarball/04af42f3b31dba0ef742d254456dc4c14eedac86"
  ) {})
}:

pkgs.buildNpmPackage {
  pname = "touche";
  version = "2.0.11";
  src = pkgs.fetchFromGitHub {
    owner = "JoseExposito";
    repo = "touche";
    rev = "2.0.11";
    hash = "sha256-/6qDCFNUyBY4+mATjYhiCVBI5yvZpyBc9O91+02nO0Y=";
  };

  npmDepsHash = "sha256-vqhpmj/6VkgsKWt0FoZ7AJ73ChP7O8IO4OO0yE/Xcs4=";
  nativeBuildInputs = with pkgs; [
    meson
    gjs
    gettext
    appstream-glib
    glib
    gobject-introspection
    gtk4
    pkg-config
    cmake
    ninja
    python3
    desktop-file-utils
  ];
  buildInputs = with pkgs; [
    xorg.libX11
  ];
}

logs.txt

I'll stop my attempts here. C++ desperately needs dependency management.

pinage404 commented 7 months ago

I can build with this bad piece of code (i have tried stuff without understanding, i haven't cleaned it)

{ lib
, stdenv
, fetchFromGitHub
, meson
, ninja
, gjs
, nodePackages
, nodejs
, gobject-introspection
, desktop-file-utils
, appstream-glib
, pkg-config
, cmake
, xorg
, npmHooks
, buildNpmPackage
, python3
, gtk4
, gtk3
, glib
, wrapGAppsHook
, gsettings-desktop-schemas
, gettext
, gdk-pixbuf
, fetchpatch
, nix-update-script
, systemd
, libinput
, pugixml
, cairo
, gtk3-x11
, pcre
, pantheon
, webkitgtk
, gnome
, adw-gtk3
, adwaita-qt
}:

buildNpmPackage rec {
  pname = "touche";
  version = "2.0.11";

  src = fetchFromGitHub {
    owner = "JoseExposito";
    repo = "touche";
    rev = version;
    hash = "sha256-/6qDCFNUyBY4+mATjYhiCVBI5yvZpyBc9O91+02nO0Y=";
  };

  npmDepsHash = "sha256-vqhpmj/6VkgsKWt0FoZ7AJ73ChP7O8IO4OO0yE/Xcs4=";

  nativeBuildInputs = [
    meson
    ninja
    gjs
    gobject-introspection
    gsettings-desktop-schemas
    desktop-file-utils
    appstream-glib
    pkg-config
    cmake
    xorg.libX11
    python3
    gettext
    glib
    glib.dev
    gtk4
    gtk3
    gdk-pixbuf
    wrapGAppsHook
    adw-gtk3
    adwaita-qt
  ];

  buildInputs = [
    adwaita-qt
    adw-gtk3
    gnome.adwaita-icon-theme
    systemd
    libinput
    pugixml
    gettext
    cairo
    gtk4
    gjs
    glib
    webkitgtk
    glib.dev
    gtk3
    gtk3-x11
    pcre
    xorg.libX11
    python3
  ] ++ (with xorg; [
    libX11
    libXtst
    libXrandr
    libXi
    libXdmcp
    libpthreadstubs
    libxcb
  ]);

  preInstall = ''
    ls -l /build
    ls -l /build/source
    ls -l /build/source/bundle
    ls -l /build/source/bundle/scripts
    set -x
    ls -l /build/source/bundle/scripts/postinstall.py
    cat /build/source/bundle/scripts/postinstall.py
    # /build/source/bundle/scripts/postinstall.py
    # exit 1 # to see logs
  '';

  postPatch = ''
    patchShebangs bundle/scripts/postinstall.py
  '';

  postFixup = ''
    sed -i "1 a imports.package._findEffectiveEntryPointName = () => 'com.github.joseexposito.touche';" $out/bin/.com.github.joseexposito.touche-wrapped
    ln -s $out/bin/com.github.joseexposito.touche $out/bin/touche
  '';

  meta = {
    description = "The desktop application to configure Touchégg";
    homepage = "https://github.com/JoseExposito/touche";
    license = lib.licenses.gpl3Only;
    maintainers = [ ];
    mainProgram = "touche";
    platforms = lib.platforms.all;
  };
}

Then execute the program

com.github.joseexposito.touche

But crash with

(com.github.joseexposito.touche:2106459): Gjs-CRITICAL **: 19:26:56.837: JS ERROR: Error: Requiring Adw, version none: Typelib file for namespace 'Adw' (any version) not found
@webpack:///../src/not-installed-view/index.js?:24:9
../src/not-installed-view/index.js@resource:///com/github/joseexposito/touche/js/com.github.joseexposito.touche.js:338:1
__webpack_require__@resource:///com/github/joseexposito/touche/js/com.github.joseexposito.touche.js:1849:42
@webpack:///../src/app-window.js?:5:96
../src/app-window.js@resource:///com/github/joseexposito/touche/js/com.github.joseexposito.touche.js:30:1
__webpack_require__@resource:///com/github/joseexposito/touche/js/com.github.joseexposito.touche.js:1849:42
@webpack:///../src/index.js?:4:88
../src/index.js@resource:///com/github/joseexposito/touche/js/com.github.joseexposito.touche.js:140:1
__webpack_require__@resource:///com/github/joseexposito/touche/js/com.github.joseexposito.touche.js:1849:42
@resource:///com/github/joseexposito/touche/js/com.github.joseexposito.touche.js:1913:56
@resource:///com/github/joseexposito/touche/js/com.github.joseexposito.touche.js:1915:12
@/nix/store/asip1vlwdfmky2bxrgmwqinqfjs7khg6-touche-2.0.11/bin/.com.github.joseexposito.touche-wrapped:12:1

(com.github.joseexposito.touche:2106459): Gjs-CRITICAL **: 19:26:56.837: Script /nix/store/asip1vlwdfmky2bxrgmwqinqfjs7khg6-touche-2.0.11/bin/.com.github.joseexposito.touche-wrapped threw an exception

I give up

I hope someone more competent than me will succeed

SiliconWolley commented 3 weeks ago

I can build with this bad piece of code (i have tried stuff without understanding, i haven't cleaned it)

...
buildNpmPackage rec {
  pname = "touche";
  version = "2.0.11";
...
  nativeBuildInputs = [
    meson ninja  gjs gobject-introspection  gsettings-desktop-schemas
    desktop-file-utils appstream-glib pkg-config cmake xorg.libX11
    python3  gettext glib glib.dev gtk4 gtk3 gdk-pixbuf
    wrapGAppsHook adw-gtk3 adwaita-qt
  ];

  buildInputs = [
    adwaita-qt adw-gtk3 gnome.adwaita-icon-theme systemd  libinput
    pugixml gettext cairo gtk4 gjs glib webkitgtk glib.dev gtk3
    gtk3-x11 pcre xorg.libX11  python3
  ] ++ (with xorg; [ libX11 libXtst libXrandr libXi libXdmcp libpthreadstubs libxcb ]);
...
}

Then execute the program

com.github.joseexposito.touche

But crash with

(com.github.joseexposito.touche:2106459): Gjs-CRITICAL **: 19:26:56.837: JS ERROR: Error: Requiring Adw, version none: Typelib file for namespace 'Adw' (any version) not found
...

I give up

I hope someone more competent than me will succeed

Hey, I just quickly tested your code and I got it working! To fix the Adw issue I only needed to add libadwaita to the build inputs. The issue I'm now tackling is that after getting it running it can't find the touchegg installation. Will circle back if I figure anything out.


UPDATE: For anyone making a proper implementation, touche determines if touchegg is installed by checking if a valid system config file touchegg/touchegg.conf exists in one of $XDG_CONFIG_DIRS (relevant touche code) I copied the default touchegg config from my Nix store to /etc/xdg/touchegg/, after which touchegg started working correctly and was able to create a user config in ~/.config/touchegg/touchegg.conf. Note: creating an empty file at /etc/xdg/touchegg/touchegg.conf caused touche to error out. I only wanted to test touche out, so I won’t be doing any further work on it and will be deleting it from my setup. Hopefully, this helps others get it working!