Unverified Commit c29545ba authored by Gutyina Gergő's avatar Gutyina Gergő
Browse files

nixos/xppen: init



Co-authored-by: default avataryakrobat <yakrobat@protonmail.com>
parent 70469150
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -31,6 +31,8 @@

- [Homebridge](https://github.com/homebridge/homebridge), a lightweight Node.js server you can run on your home network that emulates the iOS HomeKit API. Available as [services.homebridge](#opt-services.homebridge.enable).

- [XPPen](https://www.xp-pen.com/), the official closed-source driver for XP Pen tablets. Available as [programs.xppen](#opt-programs.xppen.enable).

- [LACT](https://github.com/ilya-zlobintsev/LACT), a GPU monitoring and configuration tool, can now be enabled through [services.lact.enable](#opt-services.lact.enable).
  Note that for LACT to work properly on AMD GPU systems, you need to enable [hardware.amdgpu.overdrive.enable](#opt-hardware.amdgpu.overdrive.enable).

+1 −0
Original line number Diff line number Diff line
@@ -357,6 +357,7 @@
  ./programs/xfconf.nix
  ./programs/xfs_quota.nix
  ./programs/xonsh.nix
  ./programs/xppen.nix
  ./programs/xss-lock.nix
  ./programs/xwayland.nix
  ./programs/yazi.nix
+55 −0
Original line number Diff line number Diff line
{
  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.tmpfiles.rules = [
      "d /var/lib/pentablet/conf/xppen 0777 - - -"
    ];

    systemd.services.xppen-create-config-dir = {
      restartTriggers = [ cfg.package ];
      wantedBy = [ "multi-user.target" ];
      serviceConfig = {
        Type = "oneshot";
        TimeoutSec = 60;
        ExecStart = pkgs.writeShellScript "xppen-create-config-dir" ''
          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
        '';
      };
    };
  };
}