Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xppen: init package with nixos module #285660

Open
wants to merge 18 commits into
base: master
Choose a base branch
from

Conversation

nasrally
Copy link
Contributor

@nasrally nasrally commented Feb 1, 2024

Description of changes

Added XPPen PenTablet package and a program.xppen module for it

Things done

I've initially made this for my friend who asked me if I could port XPPen on NixOS, I did, so now I'd like to add it to nixpkgs.
I have a few concerns however, the primary is that I'm not quite sure about the licensing of XPPen, there is practically no information I could find and the only way to contact XPPen is through mail which, if I'm completely honest, I just don't want to do.

I also don't own an XPPen tablet and don't really know much about them unlike my friend but he's not quite there yet in terms of being able to package it himself.

Do my changes relate to #213263 and the pentablet-driver package???

Also this is my very first time trying to add a package/module to nixpkgs so please tell me if I'm doing things wrong, I tried my best but I suppose there are things that can be improved.

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 24.05 Release Notes (or backporting 23.05 and 23.11 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

@nasrally
Copy link
Contributor Author

nasrally commented Feb 1, 2024

Also please anyone with an actual XPPen tablet tell me if what I've made actually works, I have no means of testing it myself, I just know that the app is running and the udev rules are applied 🙏🙏

nixos/modules/programs/xppen.nix Outdated Show resolved Hide resolved
nixos/modules/programs/xppen.nix Outdated Show resolved Hide resolved
pkgs/tools/misc/xppen/default.nix Outdated Show resolved Hide resolved
pkgs/tools/misc/xppen/default.nix Outdated Show resolved Hide resolved
pkgs/top-level/all-packages.nix Outdated Show resolved Hide resolved
@nasrally
Copy link
Contributor Author

nasrally commented Feb 2, 2024

I tested the module, looks like I didn't break anything

@nasrally
Copy link
Contributor Author

nasrally commented Feb 2, 2024

Oh and also one other question. Is it maybe possible to backport this change to 23.11?

@h7x4
Copy link
Member

h7x4 commented Feb 2, 2024

Yes, I think so, but I'm a bit unsure about how to deal with backporting release notes. I'll ask around to see if I can find some answers.

In the meanwhile, could you squash your changes into the first three commits? If you're unsure about how to do it, feel free to ask. I might be a good idea to mark the PR as draft before push, because a rebase gone wrong will ping a ton of people.

@nasrally nasrally marked this pull request as draft February 2, 2024 02:43
@nasrally
Copy link
Contributor Author

nasrally commented Feb 2, 2024

Didn't really want to bother remembering how to rebase properly so just git reset --soft'ed and recreated the commits. Hope it's good enough

@nasrally nasrally marked this pull request as ready for review February 2, 2024 02:56
@nasrally
Copy link
Contributor Author

nasrally commented Feb 2, 2024

Why is it suddenly unable to find libusb?

@h7x4
Copy link
Member

h7x4 commented Feb 2, 2024

Might've been after you moved it to pkgs/by-name. libusb1 is the correct one.

@nasrally
Copy link
Contributor Author

nasrally commented Feb 2, 2024

I borked it, okay, will never make changes on the phone again, must've missed something important .-.

nixos/modules/programs/xppen.nix Outdated Show resolved Hide resolved
pkgs/by-name/xp/xppen/package.nix Outdated Show resolved Hide resolved
pkgs/by-name/xp/xppen/package.nix Outdated Show resolved Hide resolved
@nasrally
Copy link
Contributor Author

nasrally commented Feb 2, 2024

h7x4, thank you so much for helping!

@nasrally
Copy link
Contributor Author

nasrally commented Feb 5, 2024

I'd like to confirm, but you don't have an XP-Pen tablet, right?

Yep, unfortunately, I initially made this for my friend and he still has not tested any of it >:6

In that case, I would like to know which screen to advance to. (You will probably see a screen with text like connect device and a white background.)

Basically I think that's it, all I'd like to know right now is if the changes in /var/lib/pentablet persist (they should), all I need is a confirmation from you :)

@misumisumi
Copy link

OK.
I thought it would be best if we could write to PenTabletrc separately from config.xml, so I installed it on the VM's ubuntu and checked, but it didn't appear in strace, so I was just curious.
I'll check it on the KDE system tomorrow.

@nasrally
Copy link
Contributor Author

nasrally commented Feb 5, 2024

I thought it would be best if we could write to PenTabletrc separately

At this point I'm not even sure what this file is used for. If it is used instead of config.xml and its presence actually means pentablet stops rewriting config.xml then, well, it may still be worth investigating, writing a wrapper that would create (if not present) a $HOME/.config/PenTabletrc file is probably the better solution, but that would mean we'd still have to go back to buildFHSEnv which feels sub-optimal at this point (to me at least). Having a separate wrapper means it becomes more complicated to change the xppen(-unwrapped) package (because udev rules duh), the only decent way of doing that in case of buildFHSEnv would be writing an overlay, no decent .override that applies to both xppen and xppen-unwrapped for you. But if I copy udev rules to the wrapper store object (which I'm not even sure if you can do easily) that would be just redundancy idk don't like it either.

@misumisumi
Copy link

I checked the driver installed on the KDE Neon VM, but I still couldn't find the PenTabletrc string. (Need to keep in mind that the tablet is not connected)

I investigated the behavior in various communities, and it seems that at least in older versions, the specification was to write directly to files under /usr/. https://www.reddit.com/r/XPpen/comments/12xgoq0/linux_driversutility_the_most_insecure_piece_of/

Anyway, as you say, buildFHSEnv is a pain, so I think it's okay to push it here.

@misumisumi
Copy link

It will fail if uinput is not present, so please add the following to nixosModule

     hardware.uinput.enable = true;

nixos/modules/programs/xppen.nix Outdated Show resolved Hide resolved
nixos/modules/programs/xppen.nix Outdated Show resolved Hide resolved
nasrally and others added 2 commits February 10, 2024 16:33
Co-authored-by: MinerSebas <66798382+MinerSebas@users.noreply.github.com>
@nasrally
Copy link
Contributor Author

nasrally commented Feb 10, 2024

Is this a good-enough service? I'm not familiar with how people usually do it in nixpkgs, I've found a few examples with grep and followed them (nginx and nifi)
Seems to be working for me

@nasrally
Copy link
Contributor Author

However it seems like this service runs every time I nixos-rebuild my system with it even if nothing was changed :/ Is this normal? Do I need to add some nixos-specific conditions?

@MinerSebas
Copy link
Contributor

The missing piece should just be adding restartTriggers = [ cfg.package ] to the service.

nixos/modules/programs/xppen.nix Outdated Show resolved Hide resolved
nixos/modules/programs/xppen.nix Outdated Show resolved Hide resolved
nixos/modules/programs/xppen.nix Outdated Show resolved Hide resolved
Copy link
Contributor

@eclairevoyant eclairevoyant left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your work so far! Some feedback below.


services.udev.packages = [ cfg.package ];

systemd.services.xppen-create-config-dir = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This service seems like something that might be better achieved with systemd-tmpfiles

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately I don't think it can, those files are installed in /var because it's kind of a hack and are not temporary, those are user configuration files:///

Copy link
Contributor

@eclairevoyant eclairevoyant Feb 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

things created via systemd-tmpfiles are not necessarily temporary, despite the name.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or can tmpfiles be used to store files persistently? My problem is that I don't think I'd want those user-changed configs to be removed even is the module is disabled. If I could patch this app to read configs from, say, $XDG_CONFIG_HOME I would, but me no smart enough to patch binaries to this degree. /var is better than the default /usr but yes it is incredible that they even fathomed to make /usr/lib a user-writable configuration directory :)))
So yeah, don't think tmpfiles is good, these files are by no means temporary

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

things created via systemd-tmpfiles are not necessarily temporary, despite the name.

So what would the added benefit be then? Can it copy a set of given files instead of this little scripty thingy?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm just not familiar with systemd-tmpfiles that's why I'm asking:)

pkgs/by-name/xp/xppen/package.nix Show resolved Hide resolved
pkgs/by-name/xp/xppen/package.nix Outdated Show resolved Hide resolved
pkgs/by-name/xp/xppen/package.nix Outdated Show resolved Hide resolved
nasrally and others added 4 commits February 12, 2024 03:49
Co-authored-by: nuko <host@nuko.city>
Co-authored-by: nuko <host@nuko.city>
Co-authored-by: éclairevoyant <848000+eclairevoyant@users.noreply.github.com>
Co-authored-by: éclairevoyant <848000+eclairevoyant@users.noreply.github.com>
@h7x4 h7x4 changed the title Xppen pentablet xppen: init package with nixos module Feb 12, 2024
@damiankorcz
Copy link

damiankorcz commented Sep 23, 2024

Hey,
I have an XP-Pen Deco LW. This model works wired and wireless (Bluetooth - comes with a receiver) so I can test both scenarios. By default in KDE 6, it get detected and moves the cursor (wired or wireless). I would like to help get this PR updated and merged. I've tried to build it and it appears to build fine although when running the PenTablet executable I get the following:

[damian@nixos-desktop:~/Git/nixpkgs/result/bin]$ ./PenTablet
QFont::fromString: Invalid description 'Noto Sans,10,-1,5,400,0,0,0,0,0,0,0,0,0,0,1'
QLocale::English
QMetaObject::connectSlotsByName: No matching signal for on_horizontalSlider_tablet_light_valueChanged(int)
QObject::connect: Incompatible sender/receiver arguments
        QDesktopWidget::primaryScreenChanged() --> MainWindow::onDeskScreenChanged(int)
QLayout: Attempting to add QLayout "" to MainWindow "MainWindow", which already has a layout
Function  EnumDisplay nScreenCount: 4
Device.AllScreen "(0,0,4640,2880)"
Device.Screen 1 : "1(1440,1440,2560,1440)"
Device.Screen 2 : "2(0,320,1440,2560)"
Device.Screen 3 : "3(1440,0,2560,1440)"
Device.Screen 4 : "4(4000,2400,640,480)"
-------type: 1
hid_open_path Failed!
Cannot mix incompatible Qt library (5.15.14) with this library (5.15.12)
Aborted (core dumped)

Let me know what you want me to try further. Also, it appears the version is still 3.4.9 but they add a suffix with YYMMDD e.g. currently it's on XPPenLinux3.4.9-240607. So might need to amend how the versions are defined.

@nasrally
Copy link
Contributor Author

Hey @damiankorcz, I have completely forgotten about this PR. Unfortunately I don't have much time to fix and update it myself, but I think you can suggest changes and fixes, I'll add them. I can still push some effort into getting this PR merged :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants