diff --git a/nixos/doc/manual/release-notes/rl-2411.section.md b/nixos/doc/manual/release-notes/rl-2411.section.md index aae9fdd9547e..ca795a6af656 100644 --- a/nixos/doc/manual/release-notes/rl-2411.section.md +++ b/nixos/doc/manual/release-notes/rl-2411.section.md @@ -124,6 +124,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 eda3c7703c4c..b06521dcb9b3 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -929,6 +929,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"; + }; + }; + }; +} 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"; + }; +}