opentabletdriver: misc improvements

- Use install instead of cp when possible
- Add missing hooks
- Use desktopItem instead of packaging desktop file manually
This commit is contained in:
Thiago Kenji Okada 2021-01-01 11:29:24 -03:00
parent 0b0760b5e0
commit 0a14936466

View File

@ -2,7 +2,6 @@
, lib , lib
, fetchFromGitHub , fetchFromGitHub
, fetchurl , fetchurl
, makeWrapper
, linkFarmFromDrvs , linkFarmFromDrvs
, dotnet-netcore , dotnet-netcore
, dotnet-sdk , dotnet-sdk
@ -15,7 +14,9 @@
, libevdev , libevdev
, libnotify , libnotify
, udev , udev
, copyDesktopItems
, makeDesktopItem , makeDesktopItem
, makeWrapper
, wrapGAppsHook , wrapGAppsHook
}: }:
@ -39,6 +40,7 @@ stdenv.mkDerivation rec {
dotnet-sdk dotnet-sdk
dotnetPackages.Nuget dotnetPackages.Nuget
dpkg dpkg
copyDesktopItems
makeWrapper makeWrapper
wrapGAppsHook wrapGAppsHook
]; ];
@ -62,6 +64,8 @@ stdenv.mkDerivation rec {
]; ];
configurePhase = '' configurePhase = ''
runHook preConfigure
export HOME=$(mktemp -d) export HOME=$(mktemp -d)
export DOTNET_CLI_TELEMETRY_OPTOUT=1 export DOTNET_CLI_TELEMETRY_OPTOUT=1
export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1 export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
@ -76,20 +80,25 @@ stdenv.mkDerivation rec {
for project in OpenTabletDriver.{Console,Daemon,UX.Gtk}; do for project in OpenTabletDriver.{Console,Daemon,UX.Gtk}; do
dotnet restore --source "$PWD/nixos" $project dotnet restore --source "$PWD/nixos" $project
done done
runHook postConfigure
''; '';
buildPhase = '' buildPhase = ''
runHook preBuild
for project in OpenTabletDriver.{Console,Daemon,UX.Gtk}; do for project in OpenTabletDriver.{Console,Daemon,UX.Gtk}; do
dotnet build $project \ dotnet build $project \
--no-restore \ --no-restore \
--configuration Release \ --configuration Release \
--framework net5 --framework net5
done done
runHook postBuild
''; '';
installPhase = '' installPhase = ''
mkdir -p $out/lib/OpenTabletDriver/ runHook preInstall
cp -r ./OpenTabletDriver/Configurations/ $out/lib/OpenTabletDriver/
for project in OpenTabletDriver.{Console,Daemon,UX.Gtk}; do for project in OpenTabletDriver.{Console,Daemon,UX.Gtk}; do
dotnet publish $project \ dotnet publish $project \
@ -119,11 +128,19 @@ stdenv.mkDerivation rec {
--set DOTNET_ROOT "${dotnet-netcore}" \ --set DOTNET_ROOT "${dotnet-netcore}" \
--suffix LD_LIBRARY_PATH : "${lib.makeLibraryPath runtimeDeps}" --suffix LD_LIBRARY_PATH : "${lib.makeLibraryPath runtimeDeps}"
mkdir -p $out/share/{applications,pixmaps} mkdir -p $out/lib/OpenTabletDriver
cp -rv ./OpenTabletDriver/Configurations $out/lib/OpenTabletDriver
install -Dm644 $src/OpenTabletDriver.UX/Assets/otd.png -t $out/share/pixmaps
cp -r $src/OpenTabletDriver.UX/Assets/* $out/share/pixmaps # TODO: Ideally this should be build from OpenTabletDriver/OpenTabletDriver-udev instead
dpkg-deb --fsys-tarfile ${debPkg} | tar xf - ./usr/lib/udev/rules.d/30-opentabletdriver.rules
install -Dm644 ./usr/lib/udev/rules.d/30-opentabletdriver.rules -t $out/lib/udev/rules.d
cp -r ${makeDesktopItem { runHook postInstall
'';
desktopItems = [
(makeDesktopItem {
desktopName = "OpenTabletDriver"; desktopName = "OpenTabletDriver";
name = "OpenTabletDriver"; name = "OpenTabletDriver";
exec = "otd-gui"; exec = "otd-gui";
@ -131,13 +148,8 @@ stdenv.mkDerivation rec {
comment = meta.description; comment = meta.description;
type = "Application"; type = "Application";
categories = "Utility;"; categories = "Utility;";
}}/share/applications/* $out/share/applications })
];
# TODO: Ideally this should be build from OpenTabletDriver/OpenTabletDriver-udev instead
dpkg-deb --fsys-tarfile ${debPkg} | tar xf - ./usr/lib/udev/rules.d/30-opentabletdriver.rules
mkdir -p $out/lib/udev/rules.d
cp ./usr/lib/udev/rules.d/* $out/lib/udev/rules.d
'';
dontWrapGApps = true; dontWrapGApps = true;
dontStrip = true; dontStrip = true;