From 0295652d91b30980e534251734b94d249643bec7 Mon Sep 17 00:00:00 2001 From: wxt <3264117476@qq.com> Date: Sat, 24 Aug 2024 22:25:52 +0800 Subject: [PATCH 1/2] todesk: init at 4.7.2.0 --- pkgs/by-name/to/todesk/package.nix | 144 +++++++++++++++++++++++++++++ 1 file changed, 144 insertions(+) create mode 100644 pkgs/by-name/to/todesk/package.nix diff --git a/pkgs/by-name/to/todesk/package.nix b/pkgs/by-name/to/todesk/package.nix new file mode 100644 index 000000000000..24f9ec992a41 --- /dev/null +++ b/pkgs/by-name/to/todesk/package.nix @@ -0,0 +1,144 @@ +{ + stdenv, + lib, + procps, + fetchurl, + dpkg, + writeShellScript, + buildFHSEnv, + nspr, + kmod, + systemdMinimal, + glib, + pulseaudio, + libXext, + libX11, + libXrandr, + glibc, + cairo, + libva, + libdrm, + coreutils, + libXi, + libGL, + bash, + libXcomposite, + libXdamage, + libXfixes, + libXtst, + nss, + libXxf86vm, + gtk3, + gdk-pixbuf, + pango, + libz, + libayatana-appindicator, +}: + +let + version = "4.7.2.0"; + todesk-unwrapped = stdenv.mkDerivation (finalAttrs: { + pname = "todesk-unwrapped"; + version = version; + src = fetchurl { + url = "https://newdl.todesk.com/linux/todesk-v${finalAttrs.version}-amd64.deb"; + hash = "sha256-v7VpXXFVaKI99RpzUWfAc6eE7NHGJeFrNeUTbVuX+yg="; + curlOptsList = [ + "--user-agent" + "Mozilla/5.0" + ]; + }; + nativeBuildInputs = [ dpkg ]; + + unpackPhase = '' + runHook preUnpack + dpkg -x $src ./todesk-src + runHook postUnpack + ''; + + installPhase = '' + runHook preInstall + mkdir -p "$out/lib" + cp -r todesk-src/* "$out" + cp "${libayatana-appindicator}/lib/libayatana-appindicator3.so.1" "$out/opt/todesk/bin/libappindicator3.so.1" + mv "$out/opt/todesk/bin" "$out/bin" + cp "$out/bin/libmfx.so.1" "$out/lib" + cp "$out/bin/libglut.so.3" "$out/lib" + mkdir "$out/opt/todesk/config" + mkdir "$out/opt/todesk/bin" + mkdir -p "$out/share/applications" + mkdir "$out/share/icons" + runHook postInstall + ''; + + }); + +in +buildFHSEnv { + inherit version; + name = "todesk"; + targetPkgs = pkgs: [ + todesk-unwrapped + pulseaudio + nspr + kmod + libXi + systemdMinimal + glib + libz + bash + coreutils + libX11 + libXext + libXrandr + glibc + libdrm + libGL + procps + cairo + libXcomposite + libXdamage + libXfixes + libXtst + nss + libXxf86vm + gtk3 + gdk-pixbuf + pango + libva + ]; + extraBwrapArgs = [ + "--bind /var/lib/todesk /opt/todesk/config" # create the folder before bind to avoid permission denided. + "--bind ${todesk-unwrapped}/bin /opt/todesk/bin" + "--bind /var/lib/todesk /etc/todesk" # service write uuid here. Such a pain! + ]; # soft link doesn't work so that we should bind ourselves + runScript = writeShellScript "ToDesk.sh" '' + export LIBVA_DRIVER_NAME=iHD + export LIBVA_DRIVERS_PATH=${todesk-unwrapped}/bin + if [ "''${1}" = 'service' ] + then + /opt/todesk/bin/ToDesk_Service + else + /opt/todesk/bin/ToDesk + fi + ''; # a small script to choose what to exec + extraInstallCommands = '' + mkdir -p "$out/share/applications" + mkdir -p "$out/share/icons" + cp ${todesk-unwrapped}/usr/share/applications/todesk.desktop $out/share/applications + cp -rf ${todesk-unwrapped}/usr/share/icons/* $out/share/icons + substituteInPlace "$out/share/applications/todesk.desktop" \ + --replace-fail '/opt/todesk/bin/ToDesk' "$out/bin/todesk desktop" + substituteInPlace "$out/share/applications/todesk.desktop" \ + --replace-fail '/opt/todesk/bin' "${todesk-unwrapped}/lib" + ''; + meta = { + description = "Remote Desktop Application"; + homepage = "https://www.todesk.com/linux.html"; + license = lib.licenses.unfree; + platforms = [ "x86_64-linux" ]; + sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ]; + maintainers = with lib.maintainers; [ bot-wxt1221 ]; + mainProgram = "todesk"; + }; +} From 1c77c14c21d415c5b461c345aa340e63efe96159 Mon Sep 17 00:00:00 2001 From: wxt <3264117476@qq.com> Date: Sat, 24 Aug 2024 22:26:00 +0800 Subject: [PATCH 2/2] nixos/todesk: init --- .../manual/release-notes/rl-2411.section.md | 2 + nixos/modules/module-list.nix | 1 + nixos/modules/services/monitoring/todesk.nix | 45 +++++++++++++++++++ 3 files changed, 48 insertions(+) create mode 100644 nixos/modules/services/monitoring/todesk.nix diff --git a/nixos/doc/manual/release-notes/rl-2411.section.md b/nixos/doc/manual/release-notes/rl-2411.section.md index 0fea2aa31494..5d0fdb6e3790 100644 --- a/nixos/doc/manual/release-notes/rl-2411.section.md +++ b/nixos/doc/manual/release-notes/rl-2411.section.md @@ -109,6 +109,8 @@ - [foot](https://codeberg.org/dnkl/foot), a fast, lightweight and minimalistic Wayland terminal emulator. Available as [programs.foot](#opt-programs.foot.enable). +- [ToDesk](https://www.todesk.com/linux.html), a remote desktop applicaton. Available as [services.todesk.enable](#opt-services.todesk.enable). + ## Backward Incompatibilities {#sec-release-24.11-incompatibilities} - `transmission` package has been aliased with a `trace` warning to `transmission_3`. Since [Transmission 4 has been released last year](https://github.com/transmission/transmission/releases/tag/4.0.0), and Transmission 3 will eventually go away, it was decided perform this warning alias to make people aware of the new version. The `services.transmission.package` defaults to `transmission_3` as well because the upgrade can cause data loss in certain specific usage patterns (examples: [#5153](https://github.com/transmission/transmission/issues/5153), [#6796](https://github.com/transmission/transmission/issues/6796)). Please make sure to back up to your data directory per your usage: diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index 88715af4dc0e..8540a70789cd 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -928,6 +928,7 @@ ./services/monitoring/teamviewer.nix ./services/monitoring/telegraf.nix ./services/monitoring/thanos.nix + ./services/monitoring/todesk.nix ./services/monitoring/tremor-rs.nix ./services/monitoring/tuptime.nix ./services/monitoring/unpoller.nix diff --git a/nixos/modules/services/monitoring/todesk.nix b/nixos/modules/services/monitoring/todesk.nix new file mode 100644 index 000000000000..807d924abfcf --- /dev/null +++ b/nixos/modules/services/monitoring/todesk.nix @@ -0,0 +1,45 @@ +{ + config, + lib, + pkgs, + ... +}: + +let + cfg = config.services.todesk; +in +{ + options = { + services.todesk.enable = lib.mkEnableOption "ToDesk daemon"; + services.todesk.package = lib.mkPackageOption pkgs "todesk" { }; + }; + + config = lib.mkIf cfg.enable { + + environment.systemPackages = [ cfg.package ]; + + systemd.services.todeskd = { + description = "ToDesk Daemon Service"; + + wantedBy = [ "multi-user.target" ]; + wants = [ + "network-online.target" + "display-manager.service" + "nss-lookup.target" + ]; + serviceConfig = { + Type = "simple"; + ExecStart = "${cfg.package}/bin/todesk service"; + ExecReload = "${pkgs.coreutils}/bin/kill -SIGINT $MAINPID"; + Restart = "on-failure"; + WorkingDirectory = "/var/lib/todesk"; + PrivateTmp = true; + StateDirectory = "todesk"; + StateDirectoryMode = "0777"; # Desktop application read and write /opt/todesk/config/config.ini. Such a pain! + ProtectSystem = "strict"; + ProtectHome = "read-only"; + RemoveIPC = "yes"; + }; + }; + }; +}