nixpkgs/pkgs/tools/admin/nomachine-client/default.nix
Profpatsch 4a7f99d55d treewide: with stdenv.lib; in meta -> with lib;
Part of: https://github.com/NixOS/nixpkgs/issues/108938

meta = with stdenv.lib;

is a widely used pattern. We want to slowly remove
the `stdenv.lib` indirection and encourage people
to use `lib` directly. Thus let’s start with the meta
field.

This used a rewriting script to mostly automatically
replace all occurances of this pattern, and add the
`lib` argument to the package header if it doesn’t
exist yet.

The script in its current form is available at
https://cs.tvl.fyi/depot@2f807d7f141068d2d60676a89213eaa5353ca6e0/-/blob/users/Profpatsch/nixpkgs-rewriter/default.nix
2021-01-11 10:38:22 +01:00

97 lines
3.3 KiB
Nix

{ lib, stdenv, file, fetchurl, makeWrapper,
autoPatchelfHook, jsoncpp, libpulseaudio }:
let
versionMajor = "6.12";
versionMinor = "3";
versionBuild_x86_64 = "7";
versionBuild_i686 = "8";
in
stdenv.mkDerivation rec {
pname = "nomachine-client";
version = "${versionMajor}.${versionMinor}";
src =
if stdenv.hostPlatform.system == "x86_64-linux" then
fetchurl {
urls = [
"https://download.nomachine.com/download/${versionMajor}/Linux/nomachine_${version}_${versionBuild_x86_64}_x86_64.tar.gz"
"https://web.archive.org/web/https://download.nomachine.com/download/${versionMajor}/Linux/nomachine_${version}_${versionBuild_x86_64}_x86_64.tar.gz"
];
sha256 = "1dqsqwxbd77g6gc0hvjmmg4flm3vwwv5y98m8d9wxyybp37vkmgd";
}
else if stdenv.hostPlatform.system == "i686-linux" then
fetchurl {
urls = [
"https://download.nomachine.com/download/${versionMajor}/Linux/nomachine_${version}_${versionBuild_i686}_i686.tar.gz"
"https://web.archive.org/web/https://download.nomachine.com/download/${versionMajor}/Linux/nomachine_${version}_${versionBuild_i686}_i686.tar.gz"
];
sha256 = "1q14hxjy66s5cpq19rshscsm679csb6p16c5p2agh5zd64cr4am6";
}
else
throw "NoMachine client is not supported on ${stdenv.hostPlatform.system}";
postUnpack = ''
mv $(find . -type f -name nxclient.tar.gz) .
mv $(find . -type f -name nxplayer.tar.gz) .
rm -r NX/
tar xf nxclient.tar.gz
tar xf nxplayer.tar.gz
rm $(find . -maxdepth 1 -type f)
'';
nativeBuildInputs = [ file makeWrapper autoPatchelfHook ];
buildInputs = [ jsoncpp libpulseaudio ];
installPhase = ''
rm bin/nxplayer bin/nxclient
mkdir -p $out/NX
cp -r bin lib share $out/NX/
ln -s $out/NX/bin $out/bin
for i in share/icons/*; do
if [[ -d "$i" ]]; then
mkdir -p "$out/share/icons/hicolor/$(basename $i)/apps"
cp "$i"/* "$out/share/icons/hicolor/$(basename $i)/apps/"
fi
done
mkdir $out/share/applications
cp share/applnk/player/xdg/*.desktop $out/share/applications/
cp share/applnk/client/xdg-mime/*.desktop $out/share/applications/
mkdir -p $out/share/mime/packages
cp share/applnk/client/xdg-mime/*.xml $out/share/mime/packages/
for i in $out/share/applications/*.desktop; do
substituteInPlace "$i" --replace /usr/NX/bin $out/bin
done
'';
postFixup = ''
makeWrapper $out/bin/nxplayer.bin $out/bin/nxplayer --set NX_SYSTEM $out/NX
makeWrapper $out/bin/nxclient.bin $out/bin/nxclient --set NX_SYSTEM $out/NX
# libnxcau.so needs libpulse.so.0 for audio to work, but doesn't
# have a DT_NEEDED entry for it.
patchelf --add-needed libpulse.so.0 $out/NX/lib/libnxcau.so
'';
dontBuild = true;
dontStrip = true;
meta = with lib; {
description = "NoMachine remote desktop client (nxplayer)";
homepage = "https://www.nomachine.com/";
license = {
fullName = "NoMachine 6 End-User License Agreement";
url = "https://www.nomachine.com/licensing-6";
free = false;
};
maintainers = with maintainers; [ talyz ];
platforms = [ "x86_64-linux" "i686-linux" ];
};
}