I need some help making a Nix package for the Remote Desktop Manager (RDM) app

The application is written in dotnet and currently only has deb and rpm packages available. Using the deb package, I wrote the following code. When I build and run it, it throws an error and crashes. Upon examining the logs, I get the following error. When I visit the URL mentioned in the error, it suggests setting the DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=“1” environment variable. As you can see in the code, I have already set the environment variable, but I am still getting the same error.

“ERROR System.Globalization.CultureNotFoundException: Only the invariant culture is supported in globalization-invariant mode. See Globalization config settings - .NET | Microsoft Learn for more information. (Parameter ‘name’)
en-US is an invalid culture identifier.”

{ lib,
  stdenv, 
  fetchurl, 
  dpkg,
  webkitgtk,
  cacert,
  libsecret,
  vte,
  libxcrypt,
  libsoup_3,
  webkitgtk_4_1,
  lttng-ust_2_12,
  libxcrypt-legacy,
  icu,
  gtk3,
  dotnet-sdk_8,
  
  
  makeWrapper,
  autoPatchelfHook

  }:


stdenv.mkDerivation rec {
  pname = "rdm";
  version = "2024.1.1.3";

  src = fetchurl {
    url = "https://cdn.devolutions.net/download/Linux/RDM/${version}/RemoteDesktopManager_${version}_amd64.deb";
    sha256 = "C70B33945618D000825994A9261C1473DA05525717CB06AACE3220F17197C780";
  };

  dontConfigure = true;
  dontBuild = true;

  nativeBuildInputs = [ dpkg makeWrapper autoPatchelfHook];

  buildInputs = [ dpkg
                  cacert
                  libsecret
                  vte
                  libxcrypt
                  libsoup_3
                  webkitgtk
                  webkitgtk_4_1
                  lttng-ust_2_12
                  libxcrypt-legacy
                  icu.dev
                  icu
                  gtk3
                  gtk3.out
                  dotnet-sdk_8
                  
                  ];

  unpackPhase = ''
    dpkg-deb -x $src $out
  '';

  installPhase = ''
    runHook preInstall

    export DOTNET_SYSTEM_GLOBALIZATION_INVARIANT="1"

    mkdir -p $out/usr/bin

    echo "export DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=1" > $out/bin/remotedesktopmanager
    echo "exec $out/usr/lib/devolutions/RemoteDesktopManager/RemoteDesktopManager \$@" >> $out/bin/remotedesktopmanager
    
    ln -s $out/bin/remotedesktopmanager $out/bin/rdm
    ln -s $out/bin/remotedesktopmanager $out/usr/bin/remotedesktopmanager

    wrapProgram $out/bin/remotedesktopmanager --prefix LD_LIBRARY_PATH : ${gtk3}/lib:${gtk3.out}/lib 
    
    runHook postInstall
  '';

  shellHook = ''
    export DOTNET_SYSTEM_GLOBALIZATION_INVARIANT="1"
  '';


  meta = {
    description = "Devolutions Remote Desktop Manager";
    homepage = "https://devolutions.net/remote-desktop-manager/";

  };
}


1 Like

The shellHook isn’t used by stdenv.mkDerivation, & so won’t have any effect.

The code sets the variable in the installPhase, but this doesn’t impact what the environment variable is at runtime.

First try setting the variable in your shell to check if that helps.

If so, wrapProgram takes --set VAR VAL.

Thank you @rgoulter I understand my faults. I changed the code. It worked after change the config file directly. I’m stuck on the error below.

Exception

ERROR SILENT GLib.GException: Unrecognized image file format
   at Gdk.PixbufLoader.Close()
   at Gdk.PixbufLoader.InitFromBuffer(Byte[] buffer)
   at Devolutions.RemoteDesktopManager.ImageHelper.CreateImageFromSVGContent(String content, Int32 size)
   at Devolutions.RemoteDesktopManager.Managers.ImageManager.SvgConverterService.Convert(String svgText, String name, Int32 size)
   at Devolutions.RemoteDesktopManager.Managers.ImageResources.GetSvgImage(String svgName, ImagePaletteType palette, Int32 originalSize, ImageEffect effect, Nullable`1 deviceDPI)
   at Client.Helpers.BuilderHelper.GetSvg(String name, String size, String color)
   at Client.Helpers.BuilderHelper.TranslateImage(Image image)

Nix Code

{ lib,
  stdenv, 
  fetchurl, 
  dpkg,
  webkitgtk,
  cacert,
  libsecret,
  vte,
  libxcrypt,
  libsoup_3,
  webkitgtk_4_1,
  lttng-ust_2_12,
  libxcrypt-legacy,
  icu,
  gtk3,
  gdk-pixbuf,
  librsvg,
  shared-mime-info,
  dotnet-sdk_8,
  
  
  makeWrapper,
  autoPatchelfHook

  }:


stdenv.mkDerivation rec {
  pname = "rdm";
  version = "2024.1.1.3";

  src = fetchurl {
    url = "https://cdn.devolutions.net/download/Linux/RDM/${version}/RemoteDesktopManager_${version}_amd64.deb";
    sha256 = "C70B33945618D000825994A9261C1473DA05525717CB06AACE3220F17197C780";
  };

  dontConfigure = true;
  dontBuild = true;

  nativeBuildInputs = [ dpkg makeWrapper autoPatchelfHook];

  buildInputs = [ dpkg
                  cacert
                  libsecret
                  vte
                  libxcrypt
                  libsoup_3
                  webkitgtk
                  webkitgtk_4_1
                  lttng-ust_2_12
                  libxcrypt-legacy
                  icu.dev
                  icu
                  gtk3
                  gtk3.out
                  gdk-pixbuf
                  librsvg
                  shared-mime-info
                  dotnet-sdk_8
                  
                  ];

  unpackPhase = ''
    dpkg-deb -x $src $out
  '';





  installPhase = ''
    runHook preInstall
    mkdir -p $out/usr/bin

    ln -s $out/bin/remotedesktopmanager $out/bin/rdm
    ln -s $out/bin/remotedesktopmanager $out/usr/bin/remotedesktopmanager
    
    runHook postInstall
  '';


preFixup = ''
gappsWrapperArgs+=(
    # Thumbnailers
    --prefix XDG_DATA_DIRS : "${gdk-pixbuf}/share"
    --prefix XDG_DATA_DIRS : "${librsvg}/share"
    --prefix XDG_DATA_DIRS : "${shared-mime-info}/share"
  )
  '';

preInstall = ''
  echo "exec $out/usr/lib/devolutions/RemoteDesktopManager/RemoteDesktopManager \$@" > $out/bin/remotedesktopmanager

  wrapProgram $out/bin/remotedesktopmanager --prefix LD_LIBRARY_PATH : ${gtk3}/lib:${gtk3.out}/lib 
  wrapProgram $out/bin/remotedesktopmanager --prefix LD_LIBRARY_PATH : ${icu}/lib:${icu.dev}/lib


  tee  $out/usr/lib/devolutions/RemoteDesktopManager/RemoteDesktopManager.runtimeconfig.json << END
    { 
        "runtimeOptions": {
        "tfm": "net8.0",
        "includedFrameworks": [
          {
            "name": "Microsoft.NETCore.App",
            "version": "8.0.4"
          }
        ],
          "configProperties": {
              "System.Reflection.Metadata.MetadataUpdater.IsSupported": false,
              "System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": false,
              "System.Globalization.Invariant": false
        }
      }
    }

'';

postInstall = ''
    
'';


  meta = {
    description = "Devolutions Remote Desktop Manager";
    homepage = "https://devolutions.net/remote-desktop-manager/";

  };
}

I don’t know anything about the dotnet part, but as the derivation is using gdk-pixbuf you may be affected by build: Disable fringe loaders by default (!163) · Merge requests · GNOME / gdk-pixbuf · GitLab, which will be fixed in nixpkgs by gdk-pixbuf: enable other loaders, disable ani loader by qubitnano · Pull Request #308976 · NixOS/nixpkgs · GitHub (currently in staging, will hit master soon).

Thank you @SFrijters. I will check your recommendation and I’m gonna give feedback…