3
0
Fork 0
forked from mirrors/nixpkgs

Merge pull request #108131 from thiagokokada/opentabletdriver-misc-improvements

opentabletdriver: misc improvements to package/module
This commit is contained in:
Kevin Cox 2021-01-05 08:20:39 -05:00 committed by GitHub
commit e10ef1faec
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 37 additions and 16 deletions

View file

@ -24,6 +24,15 @@ in
''; '';
}; };
package = mkOption {
type = types.package;
default = pkgs.opentabletdriver;
defaultText = "pkgs.opentabletdriver";
description = ''
OpenTabletDriver derivation to use.
'';
};
daemon = { daemon = {
enable = mkOption { enable = mkOption {
default = true; default = true;
@ -37,9 +46,9 @@ in
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
environment.systemPackages = with pkgs; [ opentabletdriver ]; environment.systemPackages = [ cfg.package ];
services.udev.packages = with pkgs; [ opentabletdriver ]; services.udev.packages = [ cfg.package ];
boot.blacklistedKernelModules = cfg.blacklistedKernelModules; boot.blacklistedKernelModules = cfg.blacklistedKernelModules;
@ -50,7 +59,7 @@ in
serviceConfig = { serviceConfig = {
Type = "simple"; Type = "simple";
ExecStart = "${opentabletdriver}/bin/otd-daemon -c ${opentabletdriver}/lib/OpenTabletDriver/Configurations"; ExecStart = "${cfg.package}/bin/otd-daemon -c ${cfg.package}/lib/OpenTabletDriver/Configurations";
Restart = "on-failure"; Restart = "on-failure";
}; };
}; };

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;