nixpkgs/pkgs/tools/X11/opentabletdriver/default.nix

173 lines
4.5 KiB
Nix
Raw Normal View History

2020-12-26 15:59:38 +00:00
{ stdenv
, lib
, fetchFromGitHub
, fetchurl
, linkFarmFromDrvs
, dotnet-netcore
, dotnet-sdk
, dotnetPackages
, dpkg
, gtk3
, libX11
, libXrandr
, libappindicator
, libevdev
, libnotify
, udev
, copyDesktopItems
2020-12-26 15:59:38 +00:00
, makeDesktopItem
, makeWrapper
2021-01-08 16:48:00 +00:00
, nixosTests
2020-12-26 15:59:38 +00:00
, wrapGAppsHook
}:
stdenv.mkDerivation rec {
pname = "OpenTabletDriver";
2021-02-04 00:38:24 +00:00
version = "0.5.1";
2020-12-26 15:59:38 +00:00
src = fetchFromGitHub {
owner = "InfinityGhost";
repo = "OpenTabletDriver";
rev = "v${version}";
2021-02-04 00:38:24 +00:00
sha256 = "1if2mkj193yzf5si9pwaynrm6wkhqy7ihk4k1lklzcryk5675w36";
2020-12-26 15:59:38 +00:00
};
debPkg = fetchurl {
url = "https://github.com/InfinityGhost/OpenTabletDriver/releases/download/v${version}/OpenTabletDriver.deb";
2021-02-04 00:38:24 +00:00
sha256 = "16a1rr0yxra1dhwysbbfgsxpigh2jhjlsl7r28dgp8qcxncck7wg";
2020-12-26 15:59:38 +00:00
};
nativeBuildInputs = [
dotnet-sdk
dotnetPackages.Nuget
dpkg
copyDesktopItems
2020-12-26 15:59:38 +00:00
makeWrapper
wrapGAppsHook
];
nugetDeps = linkFarmFromDrvs "${pname}-nuget-deps" (import ./deps.nix {
fetchNuGet = { name, version, sha256 }: fetchurl {
name = "nuget-${name}-${version}.nupkg";
url = "https://www.nuget.org/api/v2/package/${name}/${version}";
inherit sha256;
};
});
runtimeDeps = [
gtk3
libX11
libXrandr
libappindicator
libevdev
libnotify
udev
];
configurePhase = ''
runHook preConfigure
2020-12-26 15:59:38 +00:00
export HOME=$(mktemp -d)
export DOTNET_CLI_TELEMETRY_OPTOUT=1
export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
nuget sources Add -Name nixos -Source "$PWD/nixos"
nuget init "$nugetDeps" "$PWD/nixos"
# FIXME: https://github.com/NuGet/Home/issues/4413
mkdir -p $HOME/.nuget/NuGet
cp $HOME/.config/NuGet/NuGet.Config $HOME/.nuget/NuGet
for project in OpenTabletDriver.{Console,Daemon,UX.Gtk}; do
dotnet restore --source "$PWD/nixos" $project
done
runHook postConfigure
2020-12-26 15:59:38 +00:00
'';
buildPhase = ''
runHook preBuild
2020-12-26 15:59:38 +00:00
for project in OpenTabletDriver.{Console,Daemon,UX.Gtk}; do
dotnet build $project \
--no-restore \
--configuration Release \
--framework net5
done
runHook postBuild
2020-12-26 15:59:38 +00:00
'';
installPhase = ''
runHook preInstall
2020-12-26 15:59:38 +00:00
for project in OpenTabletDriver.{Console,Daemon,UX.Gtk}; do
dotnet publish $project \
--no-build \
--no-self-contained \
--configuration Release \
--framework net5 \
--output $out/lib
done
# Give a more "*nix" name to the binaries
makeWrapper $out/lib/OpenTabletDriver.Console $out/bin/otd \
"''${gappsWrapperArgs[@]}" \
--prefix XDG_DATA_DIRS : "${gtk3}/share/gsettings-schemas/${gtk3.name}/" \
--set DOTNET_ROOT "${dotnet-netcore}" \
--suffix LD_LIBRARY_PATH : "${lib.makeLibraryPath runtimeDeps}"
makeWrapper $out/lib/OpenTabletDriver.Daemon $out/bin/otd-daemon \
"''${gappsWrapperArgs[@]}" \
--prefix XDG_DATA_DIRS : "${gtk3}/share/gsettings-schemas/${gtk3.name}/" \
--set DOTNET_ROOT "${dotnet-netcore}" \
--suffix LD_LIBRARY_PATH : "${lib.makeLibraryPath runtimeDeps}"
makeWrapper $out/lib/OpenTabletDriver.UX.Gtk $out/bin/otd-gui \
"''${gappsWrapperArgs[@]}" \
--prefix XDG_DATA_DIRS : "${gtk3}/share/gsettings-schemas/${gtk3.name}/" \
--set DOTNET_ROOT "${dotnet-netcore}" \
--suffix LD_LIBRARY_PATH : "${lib.makeLibraryPath runtimeDeps}"
mkdir -p $out/lib/OpenTabletDriver
cp -rv ./OpenTabletDriver/Configurations $out/lib/OpenTabletDriver
install -Dm644 $src/OpenTabletDriver.UX/Assets/otd.png -t $out/share/pixmaps
2020-12-26 15:59:38 +00:00
# TODO: Ideally this should be build from OpenTabletDriver/OpenTabletDriver-udev instead
2021-01-19 14:33:01 +00:00
dpkg-deb --fsys-tarfile ${debPkg} | tar xf - ./usr/lib/udev/rules.d/99-opentabletdriver.rules
install -Dm644 ./usr/lib/udev/rules.d/99-opentabletdriver.rules -t $out/lib/udev/rules.d
2020-12-26 15:59:38 +00:00
runHook postInstall
'';
desktopItems = [
(makeDesktopItem {
2020-12-26 15:59:38 +00:00
desktopName = "OpenTabletDriver";
name = "OpenTabletDriver";
exec = "otd-gui";
icon = "otd";
comment = meta.description;
type = "Application";
categories = "Utility;";
})
];
2020-12-26 15:59:38 +00:00
dontWrapGApps = true;
dontStrip = true;
passthru = {
updateScript = ./update.sh;
tests = {
otd-runs = nixosTests.opentabletdriver;
};
2021-01-08 16:48:00 +00:00
};
2020-12-26 15:59:38 +00:00
meta = with lib; {
description = "Open source, cross-platform, user-mode tablet driver";
homepage = "https://github.com/InfinityGhost/OpenTabletDriver";
license = licenses.lgpl3Plus;
maintainers = with maintainers; [ thiagokokada ];
platforms = platforms.linux;
};
}