From 1bcff4548fba22335c7ec44cfe27210489c3cb6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gutyina=20Gerg=C5=91?= Date: Sun, 27 Oct 2024 12:28:25 +0100 Subject: [PATCH] nixos/xppen: init Co-authored-by: yakrobat --- .../manual/release-notes/rl-2411.section.md | 2 + nixos/modules/module-list.nix | 1 + nixos/modules/programs/xppen.nix | 53 +++++++++++++++++++ 3 files changed, 56 insertions(+) create mode 100644 nixos/modules/programs/xppen.nix diff --git a/nixos/doc/manual/release-notes/rl-2411.section.md b/nixos/doc/manual/release-notes/rl-2411.section.md index df940e90ff943..b293129b03826 100644 --- a/nixos/doc/manual/release-notes/rl-2411.section.md +++ b/nixos/doc/manual/release-notes/rl-2411.section.md @@ -118,6 +118,8 @@ - [Immersed](https://immersed.com/), a closed-source coworking platform. Available as [programs.immersed](#opt-programs.immersed.enable). +- [XPPen](https://www.xp-pen.com/), the official closed-source driver for XP Pen tablets. Available as [programs.xppen](#opt-programs.xppen.enable). + - [HomeBox](https://github.com/sysadminsmedia/homebox): the inventory and organization system built for the Home User. Available as [services.homebox](#opt-services.homebox.enable). - [matrix-hookshot](https://matrix-org.github.io/matrix-hookshot), a Matrix bot for connecting to external services. Available as [services.matrix-hookshot](#opt-services.matrix-hookshot.enable). diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index d11d707a4f874..b73986d401b23 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -326,6 +326,7 @@ ./programs/xfconf.nix ./programs/xfs_quota.nix ./programs/xonsh.nix + ./programs/xppen.nix ./programs/xss-lock.nix ./programs/xwayland.nix ./programs/yabar.nix diff --git a/nixos/modules/programs/xppen.nix b/nixos/modules/programs/xppen.nix new file mode 100644 index 0000000000000..13c168fe4b28f --- /dev/null +++ b/nixos/modules/programs/xppen.nix @@ -0,0 +1,53 @@ +{ + config, + lib, + pkgs, + ... +}: + +let + cfg = config.programs.xppen; +in + +{ + options.programs.xppen = { + enable = lib.mkEnableOption "XPPen PenTablet application"; + package = lib.mkPackageOption pkgs "xppen_4" { + example = "pkgs.xppen_3"; + extraDescription = '' + Use xppen_4 for newer and xppen_3 for older tablets. + To check which version of the driver you need, go to + https://www.xp-pen.com/download/ then select your tablet + and look for the major version in the available files for Linux. + ''; + }; + }; + + config = lib.mkIf cfg.enable { + hardware.uinput.enable = true; + + environment.systemPackages = [ cfg.package ]; + + services.udev.packages = [ cfg.package ]; + + systemd.services.xppen-create-config-dir = { + restartTriggers = [ cfg.package ]; + wantedBy = [ "multi-user.target" ]; + serviceConfig = { + Type = "oneshot"; + TimeoutSec = 60; + ExecStart = pkgs.writeScript "xppen-create-config-dir" '' + #!${pkgs.bash}/bin/bash + install -m 777 -d "/var/lib/pentablet/conf/xppen" + readarray -d "" files < <(find ${cfg.package}/usr/lib/pentablet/conf -type f -print0) + for file in "''${files[@]}"; do + file_new="/var''${file#${cfg.package + "/usr"}}" + if [ ! -f $file_new ]; then + install -m 666 "''$file" "''$file_new" + fi + done + ''; + }; + }; + }; +}