{ description = "Remote Controll Drivers."; inputs = { nixpkgs.url = "github:NixOS/nixpkgs"; # Specify the nixpkgs input }; outputs = { self, nixpkgs }: let # Import the nixpkgs packages to access utilities like wget and tar. pkgs = import nixpkgs { system = "x86_64-linux"; }; # Define the download and extraction process. downloadAndExtract = pkgs.stdenv.mkDerivation { pname = "pentablet"; version = "3.2.1.210426"; # Set up the fetchURL to download the tarball. src = pkgs.fetchurl { url = "https://www.xp-pen.com/download/file.html?id=2901&pid=977&ext=gz"; sha256 = "1wyl96lpw8wvzfq3q5q0njp2ca8j5h89psi8j0lmrhymxhp94ml7"; # Replace with the actual hash }; extraBuildCommands = '' # mkdir -p $out/etc/xdg/autostart # mkdir -p $out/lib/udev/rules.d # mkdir -p $out/usr/lib/pentablet/{conf/xppen,doc,lib,platforms} # mkdir -p $out/usr/share/{applications,icons/hicolor/256x256/apps} # mkdir -p $PWD/tmp # # Extract and install to FHS directories under $out # tar -xzf XPPenLinux3.4.9-240607.tar.gz -C $PWD/tmp # cp $PWD/tmp/App/etc/xdg/autostart/xppentablet.desktop $out/etc/xdg/autostart/ # cp $PWD/tmp/App/lib/udev/rules.d/10-xp-pen.rules $out/lib/udev/rules.d/ # cp -r $PWD/tmp/App/usr/lib/pentablet/conf/xppen/* $out/usr/lib/pentablet/conf/xppen/ # cp -r $PWD/tmp/App/usr/lib/pentablet/doc/* $out/usr/lib/pentablet/doc/ # cp -r $PWD/tmp/App/usr/lib/pentablet/lib/* $out/usr/lib/pentablet/lib/ # cp $PWD/tmp/App/usr/lib/pentablet/platforms/libqxcb.so $out/usr/lib/pentablet/platforms/ # cp $PWD/tmp/App/usr/lib/pentablet/PenTablet $out/usr/lib/pentablet/ # cp $PWD/tmp/App/usr/lib/pentablet/PenTablet.sh $out/usr/lib/pentablet/ # cp $PWD/tmp/App/usr/lib/pentablet/resource.rcc $out/usr/lib/pentablet/ # cp $PWD/tmp/App/usr/share/applications/xppentablet.desktop $out/usr/share/applications/ # cp $PWD/tmp/App/usr/share/icons/hicolor/256x256/apps/xppentablet.png $out/usr/share/icons/hicolor/256x256/apps/ # # Set appropriate permissions based on the script # chmod 0555 $out/usr/lib/pentablet/PenTablet # chmod 0555 $out/usr/lib/pentablet/PenTablet.sh # chmod 0777 $out/usr/lib/pentablet/conf/xppen # chmod 0666 $out/usr/lib/pentablet/conf/xppen/config.xml # chmod 0666 $out/usr/lib/pentablet/conf/xppen/language.ini # chmod 0666 $out/usr/lib/pentablet/conf/xppen/name_config.ini # chmod 0666 $out/usr/lib/pentablet/resource.rcc # # Ensure autostart and application icons have the correct permissions # chmod 0444 $out/usr/share/applications/xppentablet.desktop # chmod 0555 $out/usr/share/icons/hicolor/256x256/apps/xppentablet.png # # Create the lockfile # touch $out/tmp/qtsingleapp-Pentab-9c9b-lockfile # chmod 0666 $out/tmp/qtsingleapp-Pentab-9c9b-lockfile set -e mkdir -p $out/etc/xdg/autostart mkdir -p $out/lib/udev/rules.d mkdir -p $out/usr/lib/pentablet/{conf/xppen,doc,lib,platforms} mkdir -p $out/usr/share/{applications,icons/hicolor/256x256/apps} mkdir -p $PWD/tmp tar -xzf ${src} -C $PWD/tmp ls -R $PWD/tmp install -Dm644 $PWD/tmp/App/etc/xdg/autostart/xppentablet.desktop $out/etc/xdg/autostart/xppentablet.desktop install -Dm644 $PWD/tmp/App/lib/udev/rules.d/10-xp-pen.rules $out/lib/udev/rules.d/10-xp-pen.rules install -Dm644 -t $out/usr/lib/pentablet/conf/xppen/ $PWD/tmp/App/usr/lib/pentablet/conf/xppen/* install -Dm644 -t $out/usr/lib/pentablet/doc/ $PWD/tmp/App/usr/lib/pentablet/doc/* install -Dm755 $PWD/tmp/App/usr/lib/pentablet/platforms/libqxcb.so $out/usr/lib/pentablet/platforms/libqxcb.so install -Dm555 $PWD/tmp/App/usr/lib/pentablet/PenTablet $out/usr/lib/pentablet/PenTablet install -Dm555 $PWD/tmp/App/usr/lib/pentablet/PenTablet.sh $out/usr/lib/pentablet/PenTablet.sh install -Dm644 $PWD/tmp/App/usr/lib/pentablet/resource.rcc $out/usr/lib/pentablet/resource.rcc install -Dm644 $PWD/tmp/App/usr/share/applications/xppentablet.desktop $out/usr/share/applications/xppentablet.desktop install -Dm644 $PWD/tmp/App/usr/share/icons/hicolor/256x256/apps/xppentablet.png $out/usr/share/icons/hicolor/256x256/apps/xppentablet.png touch $out/tmp/qtsingleapp-Pentab-9c9b-lockfile chmod 0666 $out/tmp/qtsingleapp-Pentab-9c9b-lockfile # Cleanup rm -rf $PWD/tmp ''; # Use bind mounts to mirror the required paths bindPaths = [ { hostPath = "$out/etc/xdg"; containerPath = "/etc/xdg"; } { hostPath = "$out/lib/udev"; containerPath = "/lib/udev"; } { hostPath = "$out/usr/lib/pentablet"; containerPath = "/usr/lib/pentablet"; } { hostPath = "$out/usr/share"; containerPath = "/usr/share"; } { hostPath = "$out/tmp"; containerPath = "/tmp"; } ]; runScript = '' export LD_LIBRARY_PATH=/usr/lib/pentablet/lib export QT_PLUGIN_PATH=/usr/lib/pentablet export XPPEN_CONFIG_DIR=/usr/lib/pentablet/conf/xppen # Launch the application /usr/lib/pentablet/PenTablet.sh ''; }; in { # Expose the downloadAndExtract process as a package in the flake's outputs. packages.x86_64-linux.default = downloadAndExtract; defaultPackage.x86_64-linux = downloadAndExtract; }; }