NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
18.27k stars 14.26k forks source link

[Packaging requests] CrossOver #209545

Open yswtrue opened 1 year ago

yswtrue commented 1 year ago

Project description

CrossOver. Keep your favorite Windows Apps running in MacOS, Linux, Chrome & Android tablets. Try Now Buy Now · Check App Compatibility.

Metadata

teidova commented 1 year ago

That would be great !

shymega commented 1 year ago

I continued the work on this from a closed PR in my fork. I did reach out to CodeWeavers on the BetterTesters forum, but didn't receive a response. I need to prod, because I can't perform my usual tests for CodeWeavers of CrossOver as it doesn't run well on NixOS.

zink-chimaera commented 1 year ago

I continued the work on this from a closed PR in my fork. I did reach out to CodeWeavers on the BetterTesters forum, but didn't receive a response. I need to prod, because I can't perform my usual tests for CodeWeavers of CrossOver as it doesn't run well on NixOS.

What are the limitations you are facing currently?

shymega commented 1 year ago

@zink-chimaera Limitations in which sense?

The derivation currently doesn't build correctly, I'm awaiting to hear back from CodeWeavers currently.

yswtrue commented 1 year ago

I can build and run the crossover, but I don't know how to add 32bit libs

shymega commented 1 year ago

@yswtrue Ah. I haven't yet gotten my derivation to build, and I wasn't going to make it into a PR until it did. Would you like to collaborate?

I was also going to add support for Darwin, too - but I think that'll be a separate PR.

yswtrue commented 1 year ago

This is the derivation, I think maybe I need to add the 32-bit library manually, lib.makeLibraryPath seems only get the 64-bit path.

{ lib
, stdenv
, fetchurl
, dpkg
, autoPatchelfHook
, makeWrapper
, pkgs
, steam-run
, wrapGAppsHook
, gobject-introspection
, glibc_multi
, pkgsi686Linux
}:
let
  libraries = with pkgs; [
    gst_all_1.gstreamer
    alsa-lib
    glibc
    freetype
    libpng
    zlib
    lcms
    libGL
    glui
    libpcap
    openssl
    gtkdialog
    gtk3
    perl
    xorg.libICE
    xorg.libSM
    xorg.libX11
    xorg.libXext
    xorg.libXi
    xorg.libXcursor
    xorg.libXrandr
    gdk-pixbuf-xlib
    cups
    dbus

    pkgsi686Linux.gst_all_1.gstreamer
    pkgsi686Linux.openssl
    pkgsi686Linux.alsa-lib
    pkgsi686Linux.glibc
    pkgsi686Linux.glib
    pkgsi686Linux.freetype
    pkgsi686Linux.libpng
    pkgsi686Linux.zlib
    pkgsi686Linux.lcms
    pkgsi686Linux.libGL
    pkgsi686Linux.glui
    pkgsi686Linux.libxml2
    pkgsi686Linux.mpg123

    (python3.withPackages (p: with p; [
      pygobject3 gst-python dbus-python pycairo
    ]))

    pango
    glib
    vte

    desktop-file-utils
    sane-backends
    ocl-icd
    libunwind
    libxcrypt-legacy
    libgphoto2
    gst_all_1.gstreamer
    gst_all_1.gst-plugins-base
    openal
    apulse
    fontconfig
    gnutls
    gsm
    libexif
    openldap
    pulseaudio
    xorg.libXcomposite
    xorg.libXinerama
    libxml2
    libxslt
    xorg.libXxf86vm
    xorg.libXxf86dga
    mpg123
    nss_latest
    sane-frontends
    sane-backends
    v4l-utils

  ] ;
  version = "22.1.1-1";

in

stdenv.mkDerivation rec {
  pname = "crossover";
  inherit version;

  src = fetchurl {
    url = "https://media.codeweavers.com/pub/crossover/cxlinux/demo/crossover_${version}.deb";
    sha256 = "sha256-0HRqCVJcqgbp3gXkuAEwl7EKS8lGv2+Gc5FhixRARxs=";
  };

  nativeBuildInputs = [
    glibc_multi
    autoPatchelfHook
    wrapGAppsHook
    gobject-introspection
    makeWrapper
    dpkg
  ];
  autoPatchelfIgnoreMissingDeps = [
    "libpcap.so.0.8"
    "libcapi20.so.3"
  ];
  buildInputs = libraries;

  unpackCmd = "dpkg -x $src source";

  preFixup = ''
    makeWrapperArgs+=("''${gappsWrapperArgs[@]}")
  '';

  installPhase = ''
    mkdir -p $out/opt
    mv opt/* $out/opt/

    mv usr $out/usr
    makeWrapper $out/opt/cxoffice/bin/crossover $out/bin/crossover \
      --prefix PATH : "${lib.makeBinPath libraries}" \
      --prefix LD_LIBRARY_PATH : "${lib.makeLibraryPath libraries}" \
      --prefix XDG_DATA_DIRS : "$out/share/gsettings-schemas/${pname}" \
      --prefix XDG_DATA_DIRS : "${pkgs.gsettings-desktop-schemas}/share/gsettings-schemas/${pkgs.gsettings-desktop-schemas.name}" \
      --prefix XDG_DATA_DIRS : "${pkgs.gtk3}/share/gsettings-schemas/${pkgs.gtk3.name}"

    runHook preFixup
    runHook postInstall
  '';

  meta = with lib; {
    description = "Run your Windows® app on MacOS, Linux, or ChromeOS";
    maintainers = with maintainers; [ yswtrue ];
    license = licenses.gpl3Only;
    sourceProvenance = with sourceTypes; [ binaryNativeCode ];
    platforms = [ "x86_64-linux" ];
  };
}
yswtrue commented 1 year ago

This one can use normally now, but I can't register software license, because steam-run can't use sudo

{ lib
, stdenv
, fetchurl
, dpkg
, autoPatchelfHook
, makeWrapper
, pkgs
, steam
, wrapGAppsHook
, gobject-introspection
, glibc_multi
, gsettings-desktop-schemas
}:
let
  gds = gsettings-desktop-schemas;
  steam-run = (steam.override {
    extraPkgs = p: with p; [
    ];
    extraLibraries = p: with p; [
      gnutls
      openldap
      gmp
      openssl
      gst_all_1.gstreamer
      gst_all_1.gst-plugins-good
      gst_all_1.gst-plugins-ugly
      gst_all_1.gst-plugins-base
      libunwind
      sane-backends
      libgphoto2
      openal
      apulse

      libpcap
      sane-backends
      ocl-icd
      libxcrypt-legacy
    ];
  }).run;

  version = "22.1.1-1";

in

stdenv.mkDerivation rec {
  pname = "crossover";
  inherit version;

  buildInputs = [
    steam-run
    pkgs.gtkdialog
    pkgs.gtk3
    pkgs.vte
    (pkgs.python3.withPackages (p: with p; [
      pygobject3
      gst-python
      dbus-python
      pycairo
    ]))
  ];

  src = fetchurl {
    url = "https://media.codeweavers.com/pub/crossover/cxlinux/demo/crossover_${version}.deb";
    sha256 = "sha256-0HRqCVJcqgbp3gXkuAEwl7EKS8lGv2+Gc5FhixRARxs=";
  };

  nativeBuildInputs = [
    glibc_multi
    # autoPatchelfHook
    wrapGAppsHook
    gobject-introspection
    makeWrapper
    dpkg
  ];
  autoPatchelfIgnoreMissingDeps = [
    "libpcap.so.0.8"
    "libcapi20.so.3"
  ];

  unpackCmd = "dpkg -x $src source";

  preFixup = ''
    makeWrapperArgs+=("''${gappsWrapperArgs[@]}")
  '';

  installPhase = ''
    mkdir -p $out/opt
    mv opt/* $out/opt/

    mv usr $out/usr

    makeWrapper ${steam-run}/bin/steam-run $out/bin/crossover \
      --add-flags $out/opt/cxoffice/bin/crossover \
      --set-default GSETTINGS_SCHEMA_DIR "${gds}/share/gsettings-schemas/${gds.pname}-${gds.version}/glib-2.0/schemas"

    runHook preFixup
    runHook postInstall
  '';

  meta = with lib; {
    description = "Run your Windows® app on MacOS, Linux, or ChromeOS";
    maintainers = with maintainers; [ yswtrue ];
    license = licenses.gpl3Only;
    sourceProvenance = with sourceTypes; [ binaryNativeCode ];
    platforms = [ "x86_64-linux" ];
  };
}
shymega commented 1 year ago

I think it might be best to collaborate on a PR. I don't think this issue was intended for code-pasting.

Looking at your derivation, it seems fairly 'hacky' - with no offence meant, of course. I wouldn't be using steam-run for this.

Or perhaps we could collaborate on a Discourse post?

RegisHubelia commented 1 year ago

+1

zDEFz commented 1 year ago

+1

zDEFz commented 1 year ago

I have contacted CodeWeavers and reached somebody, but they weren't sure what they need todo from their end. I asked again, this time with the issue that we cannot register the software because steam-run cannot run as sudo...

Other than that, the procedure to create the package from the derivation can be done for testing as follows:

mkdir crossover
cd crossover
nano default.nix
{ pkgs ? import <nixpkgs> {} }:

pkgs.callPackage ./crossover.nix {}

nano crossover.nix add the content of https://github.com/NixOS/nixpkgs/issues/209545#issuecomment-1650166979

export NIXPKGS_ALLOW_UNFREE=1
nix-build
zDEFz commented 1 year ago

Got reply from support. Amazing people.

---snip--- Yes, you can manually download your license files from our website here https://www.codeweavers.com/account/edit?inp=lic and unzip that and place the 2 files in either /opt/cxoffice/etc or ~/cxoffice/etc depending on how Crossover was installed. I assume the directory structure is a bit different on NixOS but hopefully that points you in the right direction. ---snip---

deftdawg commented 1 year ago

@zDEFz 's procedure as a shellscript at the bottom :wink:

License didn't work though... when I try to open the About screen, crossover fails to find <nixstore-package-dir>/opt/cxoffice/license.txt (license.txt is inside the generated license zip file) and <nixstore-package-dir>/opt/cxoffice/doc/license.txt.gz - neither of those locations is writable

Traceback (most recent call last):
  File "/nix/store/jqg51ln7y8bdsdaan43nv1s4zhwrywrv-crossover-22.1.1-1/opt/cxoffice/lib/python/crossoverui.py", line 1111, in on_about_activate
    with open(os.path.join(cxutils.CX_ROOT, 'license.txt'), 'r', encoding='utf8') as f:
FileNotFoundError: [Errno 2] No such file or directory: '/nix/store/jqg51ln7y8bdsdaan43nv1s4zhwrywrv-crossover-22.1.1-1/opt/cxoffice/license.txt'

Seems like crossover.nix will need to symlink /opt/cxoffice/etc to ~/.cxoffice (created by crossover) or something else writable and we put the license in there.


~/build-crossover.sh

#!/usr/bin/env bash

mkdir ~/crossover
cd ~/crossover || exit
cat <<EOF > default.nix
{ pkgs ? import <nixpkgs> {} }:

pkgs.callPackage ./crossover.nix {}
EOF

# copied from https://github.com/NixOS/nixpkgs/issues/209545#issuecomment-1650166979
# then escaped to stop bad substitution -> all $ replaced with \$
cat <<EOF > crossover.nix
{ lib
, stdenv
, fetchurl
, dpkg
, autoPatchelfHook
, makeWrapper
, pkgs
, steam
, wrapGAppsHook
, gobject-introspection
, glibc_multi
, gsettings-desktop-schemas
}:
let
  gds = gsettings-desktop-schemas;
  steam-run = (steam.override {
    extraPkgs = p: with p; [
    ];
    extraLibraries = p: with p; [
      gnutls
      openldap
      gmp
      openssl
      gst_all_1.gstreamer
      gst_all_1.gst-plugins-good
      gst_all_1.gst-plugins-ugly
      gst_all_1.gst-plugins-base
      libunwind
      sane-backends
      libgphoto2
      openal
      apulse

      libpcap
      sane-backends
      ocl-icd
      libxcrypt-legacy
    ];
  }).run;

  version = "22.1.1-1";

in

stdenv.mkDerivation rec {
  pname = "crossover";
  inherit version;

  buildInputs = [
    steam-run
    pkgs.gtkdialog
    pkgs.gtk3
    pkgs.vte
    (pkgs.python3.withPackages (p: with p; [
      pygobject3
      gst-python
      dbus-python
      pycairo
    ]))
  ];

  src = fetchurl {
    url = "https://media.codeweavers.com/pub/crossover/cxlinux/demo/crossover_\${version}.deb";
    sha256 = "sha256-0HRqCVJcqgbp3gXkuAEwl7EKS8lGv2+Gc5FhixRARxs=";
  };

  nativeBuildInputs = [
    glibc_multi
    # autoPatchelfHook
    wrapGAppsHook
    gobject-introspection
    makeWrapper
    dpkg
  ];
  autoPatchelfIgnoreMissingDeps = [
    "libpcap.so.0.8"
    "libcapi20.so.3"
  ];

  unpackCmd = "dpkg -x \$src source";

  preFixup = ''
    makeWrapperArgs+=("''\${gappsWrapperArgs[@]}")
  '';

  installPhase = ''
    mkdir -p \$out/opt
    mv opt/* \$out/opt/

    mv usr \$out/usr

    makeWrapper \${steam-run}/bin/steam-run \$out/bin/crossover \
      --add-flags \$out/opt/cxoffice/bin/crossover \
      --set-default GSETTINGS_SCHEMA_DIR "\${gds}/share/gsettings-schemas/\${gds.pname}-\${gds.version}/glib-2.0/schemas"

    runHook preFixup
    runHook postInstall
  '';

  meta = with lib; {
    description = "Run your Windows® app on MacOS, Linux, or ChromeOS";
    maintainers = with maintainers; [ yswtrue ];
    license = licenses.gpl3Only;
    sourceProvenance = with sourceTypes; [ binaryNativeCode ];
    platforms = [ "x86_64-linux" ];
  };
}
EOF

export NIXPKGS_ALLOW_UNFREE=1
nix-build

./result/bin/crossover # Run it
deftdawg commented 1 year ago

I had a go at trying to get the package to find <nix-dir>/opt/cxoffice/license.txt at /etc/cxoffice/license.txt and while it looks good running ls -l result/opt/cxoffice and running cat result/opt/cxoffice/license.txt,

~/crossover/result/opt/cxoffice/lib/python/crossoverui.py:1111 still fails to find the license.txt file...

Here is the updated script including the postInstall step that makes the link to /etc/cxoffice:

#!/usr/bin/env bash

if [ ! -e /etc/cxoffice/license.txt ]; then
    sudo unzip -d /etc/cxoffice ~/Downloads/crossover-linux-license.zip || exit
fi 

mkdir ~/crossover
cd ~/crossover || exit
cat <<EOF > default.nix
{ pkgs ? import <nixpkgs> {} }:

pkgs.callPackage ./crossover.nix {}
EOF

# copied from https://github.com/NixOS/nixpkgs/issues/209545#issuecomment-1650166979, then all $ replaced with \$
cat <<EOF > crossover.nix
{ lib
, stdenv
, fetchurl
, dpkg
, autoPatchelfHook
, makeWrapper
, pkgs
, steam
, wrapGAppsHook
, gobject-introspection
, glibc_multi
, gsettings-desktop-schemas
}:
let
  gds = gsettings-desktop-schemas;
  steam-run = (steam.override {
    extraPkgs = p: with p; [
    ];
    extraLibraries = p: with p; [
      gnutls
      openldap
      gmp
      openssl
      gst_all_1.gstreamer
      gst_all_1.gst-plugins-good
      gst_all_1.gst-plugins-ugly
      gst_all_1.gst-plugins-base
      libunwind
      sane-backends
      libgphoto2
      openal
      apulse

      libpcap
      sane-backends
      ocl-icd
      libxcrypt-legacy
    ];
  }).run;

  version = "22.1.1-1";

in

stdenv.mkDerivation rec {
  pname = "crossover";
  inherit version;

  buildInputs = [
    steam-run
    pkgs.gtkdialog
    pkgs.gtk3
    pkgs.vte
    (pkgs.python3.withPackages (p: with p; [
      pygobject3
      gst-python
      dbus-python
      pycairo
    ]))
  ];

  src = fetchurl {
    url = "https://media.codeweavers.com/pub/crossover/cxlinux/demo/crossover_\${version}.deb";
    sha256 = "sha256-0HRqCVJcqgbp3gXkuAEwl7EKS8lGv2+Gc5FhixRARxs=";
  };

  nativeBuildInputs = [
    glibc_multi
    # autoPatchelfHook
    wrapGAppsHook
    gobject-introspection
    makeWrapper
    dpkg
  ];
  autoPatchelfIgnoreMissingDeps = [
    "libpcap.so.0.8"
    "libcapi20.so.3"
  ];

  unpackCmd = "dpkg -x \$src source";

  preFixup = ''
    makeWrapperArgs+=("''\${gappsWrapperArgs[@]}")
  '';

  installPhase = ''
    mkdir -p \$out/opt
    mv opt/* \$out/opt/

    mv usr \$out/usr

    makeWrapper \${steam-run}/bin/steam-run \$out/bin/crossover \
      --add-flags \$out/opt/cxoffice/bin/crossover \
      --set-default GSETTINGS_SCHEMA_DIR "\${gds}/share/gsettings-schemas/\${gds.pname}-\${gds.version}/glib-2.0/schemas"

    runHook preFixup
    runHook postInstall
  '';

  # Added post Install to replace out/opt/cxoffice with a symlink to /etc/cxoffice on the host
  postInstall = ''
    rmdir \$out/opt/cxoffice/etc
    ln -s /etc/cxoffice/license.txt \$out/opt/cxoffice
    ln -s /etc/cxoffice \$out/opt/cxoffice/etc
  '';

  meta = with lib; {
    description = "Run your Windows® app on MacOS, Linux, or ChromeOS";
    maintainers = with maintainers; [ yswtrue ];
    license = licenses.gpl3Only;
    sourceProvenance = with sourceTypes; [ binaryNativeCode ];
    platforms = [ "x86_64-linux" ];
  };
}
EOF

NIXPKGS_ALLOW_UNFREE=1 nix-build
./result/bin/crossover # Run it
deftdawg commented 1 year ago

Once we get past the license issue, we still have a number of libraries that Crossover reports as missing in Help->System Information that may break certain things:

  1. Missing 32-bit libcapi20.so.3 library
  2. Missing 32-bit libgssapi_krb5.so.2 library
  3. Missing 32-bit libkrb5.so.3 library
  4. Missing 32-bit libodbc.so.2 library
  5. Missing 32-bit libOSMesa.so.8 library
  6. Missing 32-bit libpcap.so.0.8 library
  7. Missing 32-bit libv4l2.so.0 library
  8. Missing 64-bit libcapi20.so.3 library
  9. Missing 64-bit libgssapi_krb5.so.2 library
  10. Missing 64-bit libkrb5.so.3 library
  11. Missing 64-bit libodbc.so.2 library
  12. Missing 64-bit libOSMesa.so.8 library
  13. Missing 64-bit libpcap.so.0.8 library
  14. Missing 64-bit libv4l2.so.0 library
  15. The gst-libav 32-bit GStreamer plugins appear to be missing avdec_eac3
  16. The gst-libav 64-bit GStreamer plugins appear to be missing avdec_eac3
  17. The gst-plugins-bad 32-bit GStreamer plugins appear to be missing h264parse
  18. The gst-plugins-bad 64-bit GStreamer plugins appear to be missing h264parse
Steinhagen commented 1 year ago

I think that the libraries issues can be solved the same way it's done for Lutris.

shymega commented 1 year ago

Agreed. I am in contact with CodeWeavers, and they have said they're looking at Flatpak support, as well as removing 32-bit libs - but this is long-term.

ashuramaruzxc commented 9 months ago

Agreed. I am in contact with CodeWeavers, and they have said they're looking at Flatpak support, as well as removing 32-bit libs - but this is long-term.

any new information regarding the flatpak or at least nix support?

shymega commented 7 months ago

Agreed. I am in contact with CodeWeavers, and they have said they're looking at Flatpak support, as well as removing 32-bit libs - but this is long-term.

any new information regarding the flatpak or at least nix support?

No ref Flatpak. They're looking into Flatpak support. But Nix support is up to the community, and I think it'd be best to simplify the derivation by waiting for CW to remove the 32-bit deps.

mwalid207 commented 4 months ago

Plus one for this!

shymega commented 4 months ago

No updates yet. I'm going to reach out to CodeWeavers this weekend.

Please, show your support by reacting with :+1: on the top-level post. Otherwise we all get pinged.

liberodark commented 1 month ago

Any news about this add ?

shymega commented 1 month ago

Gonna quote what I said, above your comment:

No updates yet. I'm going to reach out to CodeWeavers this weekend. Please, show your support by reacting with :+1: on the top-level post. Otherwise we all get pinged.

The last sentence being key. I'm waiting to hear back from Codeweavers, but until then, it's not my place to disclose.

liberodark commented 1 month ago

What do you think about something like :

    # Copy license.zip
    mkdir -p $out/opt/cxoffice/etc/
    cp ${pkgs.copyFile { src = ~/license.zip; }} $out/opt/cxoffice/etc/license.zip

    # Extract license.zip
    if [ ! -e /opt/cxoffice/etc/license.txt ]; then
      echo "Extracting license..."
      unzip -d /opt/cxoffice/etc/ $out/opt/cxoffice/etc/license.zip || exit
    fi 

Also have do this :

#!/usr/bin/env bash

mkdir -p ~/crossover
cd ~/crossover || exit

cat <<EOF > default.nix
{ pkgs ? import <nixpkgs> {} }:

pkgs.callPackage ./crossover.nix {}
EOF

cat <<EOF > crossover.nix
{ lib
, stdenv
, fetchurl
, dpkg
, autoPatchelfHook
, makeWrapper
, pkgs
, steam
, wrapGAppsHook
, gobject-introspection
, glibc_multi
, gsettings-desktop-schemas
}:
let
  gds = gsettings-desktop-schemas;
  steam-run = (steam.override {
    extraPkgs = p: with p; [
    ];
    extraLibraries = p: with p; [
      gnutls
      openldap
      gmp
      openssl
      gst_all_1.gstreamer
      gst_all_1.gst-plugins-good
      gst_all_1.gst-plugins-ugly
      gst_all_1.gst-plugins-base
      libunwind
      sane-backends
      libgphoto2
      openal
      apulse
      libpcap
      sane-backends
      ocl-icd
      libxcrypt-legacy
    ];
  }).run;

  version = "22.0.1-1";

in

stdenv.mkDerivation rec {
  pname = "crossover";
  inherit version;

  buildInputs = [
    steam-run
    pkgs.gtkdialog
    pkgs.gtk3
    pkgs.vte
    (pkgs.python3.withPackages (p: with p; [
      pygobject3
      gst-python
      dbus-python
      pycairo
    ]))
  ];

  src = fetchurl {
    url = "https://media.codeweavers.com/pub/crossover/cxlinux/demo/crossover_\${version}.deb";
    sha256 = "sha256-0wpM/4LCfjeZLgt0ECGdRuL3YPE0gQ/2otzUkJ9B/dY=";
  };

  nativeBuildInputs = [
    glibc_multi
    wrapGAppsHook
    gobject-introspection
    makeWrapper
    dpkg
    pkgs.unzip
  ];

  autoPatchelfIgnoreMissingDeps = [
    "libpcap.so.0.8"
    "libcapi20.so.3"
  ];

  unpackCmd = "dpkg -x \$src source";

  preFixup = ''
    makeWrapperArgs+=("''\${gappsWrapperArgs[@]}")
  '';

  installPhase = ''
    mkdir -p \$out/opt
    mv opt/* \$out/opt/
    mv usr \$out/usr

    makeWrapper \${steam-run}/bin/steam-run \$out/bin/crossover \
      --add-flags \$out/opt/cxoffice/bin/crossover \
      --set-default GSETTINGS_SCHEMA_DIR "\${gds}/share/gsettings-schemas/\${gds.pname}-\${gds.version}/glib-2.0/schemas"

    runHook preFixup
    runHook postInstall
  '';

  meta = with lib; {
    description = "Run your Windows® app on MacOS, Linux, or ChromeOS";
    maintainers = with maintainers; [ yswtrue ];
    license = licenses.gpl3Only;
    platforms = [ "x86_64-linux" ];
  };
}
EOF

if [ -z "${NIXPKGS_ALLOW_UNFREE+x}" ]; then
  export NIXPKGS_ALLOW_UNFREE=1
  echo "NIXPKGS_ALLOW_UNFREE was not set, now it's set to 1"
else
  echo "NIXPKGS_ALLOW_UNFREE is already set to $NIXPKGS_ALLOW_UNFREE"
fi

if [ -d ./result ]; then
  ./result/bin/crossover
else
  nix-build || exit
  ./result/bin/crossover
fi
shymega commented 1 month ago

That looks not so clearly split. Why have you put the derivation in a heredoc?

shymega commented 1 month ago

So, I wouldn't rely on steam-run, personally.

With regards to the license, I think we should avoid storing the license in the Nix store. It would also present problems with Hydra - I think.

Let me get back to Codeweavers, and ask how they would proceed with license storage, and the lib32 licenses. A major blocker is that Crossover, oob, uses the host system's package manager to install dependencies. Nix being Nix, we can't work that way.

liberodark commented 2 weeks ago

Ok have rework a script for work without steam-run

crossover.nix

{
  lib,
  stdenv,
  fetchurl,
  dpkg,
  autoPatchelfHook,
  makeWrapper,
  pkgs,
  wrapGAppsHook,
  gobject-introspection,
  glibc_multi,
  gsettings-desktop-schemas,
}:

let
  gds = gsettings-desktop-schemas;
  # Create LSB Release File
  lsbRelease = pkgs.writeText "lsb-release" ''
    DISTRIB_ID=nixos
    DISTRIB_RELEASE=${pkgs.lib.version}
    DISTRIB_CODENAME=nixos
    DISTRIB_DESCRIPTION="NixOS"
  '';

  # Remove Python Ads
  pythonSetup = pkgs.writeText "crossover-python-setup.py" ''
    import warnings
    import locale
    import os

    # Skip Ads
    warnings.filterwarnings("ignore", category=DeprecationWarning, module="fileupdate")
    warnings.filterwarnings("ignore", category=DeprecationWarning, module="distversion")
    warnings.filterwarnings("ignore", category=DeprecationWarning, module="multiprocessing.popen_fork")

    # Local
    try:
        locale.setlocale(locale.LC_ALL, "")
    except:
        locale.setlocale(locale.LC_ALL, "C")
  '';

  # Script for install crossover
  setupScript = pkgs.writeScript "setup-crossover.sh" ''
        #!${pkgs.bash}/bin/bash
        set -e

        mkdir -p "$HOME/.cxoffice"
        mkdir -p "$HOME/.local/share/cxoffice"
        mkdir -p "$HOME/.local/share/applications/cxoffice"
        mkdir -p "$HOME/.local/share/icons"
        mkdir -p "$HOME/.cache/cxoffice"

        if [ ! -f "$HOME/.local/share/cxoffice/crossover.conf" ]; then
          echo "Create crossover.conf..."
          cat > "$HOME/.local/share/cxoffice/crossover.conf" << EOF
    [CrossOver]
    autoinstall=true
    check_for_updates=false
    EOF
        fi

        chmod -R u+rw "$HOME/.cxoffice"
        chmod -R u+rw "$HOME/.local/share/cxoffice"
        chmod -R u+rw "$HOME/.local/share/applications/cxoffice"
        chmod -R u+rw "$HOME/.cache/cxoffice"

  '';
in
stdenv.mkDerivation rec {
  pname = "crossover";
  version = "22.0.1-1";

  src = fetchurl {
    url = "https://media.codeweavers.com/pub/crossover/cxlinux/demo/crossover_${version}.deb";
    sha256 = "sha256-0wpM/4LCfjeZLgt0ECGdRuL3YPE0gQ/2otzUkJ9B/dY=";
  };

  nativeBuildInputs = [
    dpkg
    autoPatchelfHook
    wrapGAppsHook
    gobject-introspection
    makeWrapper
    pkgs.unzip
  ];

  buildInputs = [
    # graphics
    pkgs.gtk3
    pkgs.gtkdialog
    pkgs.vte
    pkgs.libnotify
    pkgs.shared-mime-info

    # System
    glibc_multi
    pkgs.glibc.dev
    pkgs.libxcrypt-legacy

    # Audio
    pkgs.alsa-lib
    pkgs.alsa-plugins
    pkgs.pulseaudio
    pkgs.openal

    # Multimedia
    pkgs.gst_all_1.gstreamer
    pkgs.gst_all_1.gst-plugins-base
    pkgs.gst_all_1.gst-plugins-good
    pkgs.gst_all_1.gst-plugins-ugly

    # Network
    pkgs.gnutls
    pkgs.libgpg-error
    pkgs.openldap
    pkgs.openssl
    pkgs.openssl.dev
    pkgs.libpcap
    pkgs.cacert

    # Image
    pkgs.libgphoto2
    pkgs.sane-backends
    pkgs.cups

    # Other
    pkgs.gmp
    pkgs.libunwind
    pkgs.ocl-icd
    pkgs.vulkan-loader
    pkgs.sqlite
    pkgs.desktop-file-utils

    # Python
    (pkgs.python3.withPackages (
      p: with p; [
        pygobject3
        gst-python
        dbus-python
        pycairo
        requests
        urllib3
      ]
    ))
  ];

  runtimeDependencies = [
    pkgs.vulkan-loader
    pkgs.cups.lib
    pkgs.openssl
  ];

  unpackCmd = "dpkg -x $src source";

  autoPatchelfIgnoreMissingDeps = [
    "libcapi20.so.3"
    "libpcap.so.0.8"
  ];

  preFixup = ''
    gappsWrapperArgs+=(
      --prefix LD_LIBRARY_PATH : ${lib.makeLibraryPath buildInputs}
      --prefix GST_PLUGIN_PATH : "$GST_PLUGIN_SYSTEM_PATH_1_0"
      --prefix VK_LAYER_PATH : ${pkgs.vulkan-validation-layers}/share/vulkan/explicit_layer.d
      --set OPENSSL_CONF "${pkgs.openssl.out}/etc/ssl/openssl.cnf"
      --set SSL_CERT_FILE "${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt"
      --prefix PATH : ${
        lib.makeBinPath [
          pkgs.openssl
          pkgs.desktop-file-utils
        ]
      }
      --set PYTHONWARNINGS "ignore"
      --set PYTHONSTARTUP "${pythonSetup}"
      --set GSETTINGS_SCHEMA_DIR "${gds}/share/gsettings-schemas/${gds.pname}-${gds.version}/glib-2.0/schemas"
      --set CXOFFICE_HOME "$HOME/.cxoffice"
      --set XDG_DATA_HOME "$HOME/.local/share"
      --set XDG_CACHE_HOME "$HOME/.cache"
    )
  '';

  installPhase = ''
    runHook preInstall

    mkdir -p $out/{bin,opt,usr,etc,libexec}
    cp -r opt/* $out/opt/
    cp -r usr/* $out/usr/

    cp ${lsbRelease} $out/etc/lsb-release

    install -Dm755 ${setupScript} $out/libexec/setup-crossover.sh

    makeWrapper $out/opt/cxoffice/bin/crossover $out/bin/crossover \
      --run "$out/libexec/setup-crossover.sh" \
      --set LSB_RELEASE "$out/etc/lsb-release" \
      "''${gappsWrapperArgs[@]}"

    chmod +x $out/opt/cxoffice/bin/*

    runHook postInstall
  '';

  meta = with lib; {
    description = "Run your Windows® apps on Linux";
    homepage = "https://www.codeweavers.com/crossover";
    license = licenses.unfree;
    maintainers = with maintainers; [ ];
    platforms = [ "x86_64-linux" ];
  };
}

That just a poc but is build & run. PS : Update have just format the code.

Steinhagen commented 2 weeks ago

Should there be a draft PR created for this?

liberodark commented 2 weeks ago

I think someone more knowledgeable than me should look at this PoC. I'm just giving a possible way of crossover without steam-run But I have another idea in mind for the licensing issue.

Steinhagen commented 2 weeks ago

I was about to ask about it. Maybe creating a module should be created for it? Still, that should be something that would be compatible with sops-nix so that the license is not committed to the store. That being said, the recipe looks really good! Nice work mate!

shymega commented 1 week ago

Hi,

Just going to do a review here.

On 08.11.2024 12:35, liberodark wrote:

Ok have rework a script for work without steam-run

crossover.nix


{ lib
, stdenv
, fetchurl
, dpkg
, autoPatchelfHook
, makeWrapper
, pkgs
, wrapGAppsHook
, gobject-introspection
, glibc_multi
, gsettings-desktop-schemas
}:

let
 gds = gsettings-desktop-schemas;
 # Create LSB Release File
 lsbRelease = pkgs.writeText &quot;lsb-release&quot; &#39;&#39;
   DISTRIB_ID=nixos
   DISTRIB_RELEASE=${pkgs.lib.version}
   DISTRIB_CODENAME=nixos
   DISTRIB_DESCRIPTION=&quot;NixOS&quot;
 &#39;&#39;;

Not too keen on this. If this is only necessary for the sandbox, then I can see why, but if it's being saved in $out, then I would be against it.

Remove Python Ads

pythonSetup = pkgs.writeText "crossover-python-setup.py" '' import warnings import locale import os

Skip Ads

warnings.filterwarnings("ignore", category=DeprecationWarning, module="fileupdate") warnings.filterwarnings("ignore", category=DeprecationWarning, module="distversion") warnings.filterwarnings("ignore", category=DeprecationWarning, module="multiprocessing.popen_fork")

Local

try: locale.setlocale(locale.LC_ALL, "") except: locale.setlocale(locale.LC_ALL, "C") '';

What is the purpose of this?

Script for install crossover

setupScript = pkgs.writeScript "setup-crossover.sh" ''

!${pkgs.bash}/bin/bash

set -e

mkdir -p "$HOME/.cxoffice" mkdir -p "$HOME/.local/share/cxoffice" mkdir -p "$HOME/.local/share/applications/cxoffice" mkdir -p "$HOME/.local/share/icons" mkdir -p "$HOME/.cache/cxoffice"

if [ ! -f "$HOME/.local/share/cxoffice/crossover.conf" ]; then echo "Création de crossover.conf..." cat > "$HOME/.local/share/cxoffice/crossover.conf" << EOF [CrossOver] autoinstall=true check_for_updates=false EOF fi

chmod -R u+rw "$HOME/.cxoffice" chmod -R u+rw "$HOME/.local/share/cxoffice" chmod -R u+rw "$HOME/.local/share/applications/cxoffice" chmod -R u+rw "$HOME/.cache/cxoffice"

'';

This shouldn't be touching $HOME - sandbox or not. I would prefer for something like a nixosModule/homeModule to handle this.

in stdenv.mkDerivation rec { pname = "crossover"; version = "22.0.1-1";

src = fetchurl { url = "https://media.codeweavers.com/pub/crossover/cxlinux/demo/crossover_${version}.deb&quot;; sha256 = "sha256-0wpM/4LCfjeZLgt0ECGdRuL3YPE0gQ/2otzUkJ9B/dY="; };

nativeBuildInputs = [ dpkg autoPatchelfHook wrapGAppsHook gobject-introspection makeWrapper pkgs.unzip ];

buildInputs = [

graphics

pkgs.gtk3 pkgs.gtkdialog pkgs.vte pkgs.libnotify pkgs.shared-mime-info

System

glibc_multi pkgs.glibc.dev pkgs.libxcrypt-legacy

Audio

pkgs.alsa-lib pkgs.alsa-plugins pkgs.pulseaudio pkgs.openal

Multimedia

pkgs.gst_all_1.gstreamer pkgs.gst_all_1.gst-plugins-base pkgs.gst_all_1.gst-plugins-good pkgs.gst_all_1.gst-plugins-ugly

Network

pkgs.gnutls pkgs.libgpg-error pkgs.openldap pkgs.openssl pkgs.openssl.dev pkgs.libpcap pkgs.cacert

Image

pkgs.libgphoto2 pkgs.sane-backends pkgs.cups

Other

pkgs.gmp pkgs.libunwind pkgs.ocl-icd pkgs.vulkan-loader pkgs.sqlite pkgs.desktop-file-utils

Python

(pkgs.python3.withPackages (p: with p; [ pygobject3 gst-python dbus-python pycairo requests urllib3 ])) ];

You could use buildInputs = with pkgs; [], or specify the packages at the top of the derivation. It's a lot of repetitive code to prepend pkgs.. KISS.

runtimeDependencies = [ pkgs.vulkan-loader pkgs.cups.lib pkgs.openssl ];

Same goes for this.

unpackCmd = "dpkg -x $src source";

autoPatchelfIgnoreMissingDeps = [ "libcapi20.so.3" "libpcap.so.0.8" ];

Are we certain this doesn't affect Crossover?

preFixup = '' gappsWrapperArgs+=( --prefix LD_LIBRARY_PATH : ${lib.makeLibraryPath buildInputs} --prefix GST_PLUGIN_PATH : "$GST_PLUGIN_SYSTEM_PATH_1_0" --prefix VK_LAYER_PATH : ${pkgs.vulkan-validation-layers}/share/vulkan/explicit_layer.d --set OPENSSL_CONF "${pkgs.openssl.out}/etc/ssl/openssl.cnf" --set SSL_CERT_FILE "${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt" --prefix PATH : ${lib.makeBinPath [ pkgs.openssl pkgs.desktop-file-utils ]} --set PYTHONWARNINGS "ignore" --set PYTHONSTARTUP "${pythonSetup}" --set GSETTINGS_SCHEMA_DIR "${gds}/share/gsettings-schemas/${gds.pname}-${gds.version}/glib-2.0/schemas" --set CXOFFICE_HOME "$HOME/.cxoffice" --set XDG_DATA_HOME "$HOME/.local/share" --set XDG_CACHEHOME "$HOME/.cache" Setting XDG* should not happen inside the sandbox, or any user-specific variable. This should be handled by a module. ) '';

installPhase = '' runHook preInstall

mkdir -p $out/{bin,opt,usr,etc,libexec} cp -r opt/ $out/opt/ cp -r usr/ $out/usr/

cp ${lsbRelease} $out/etc/lsb-release

This shouldn't be necessary.

install -Dm755 ${setupScript} $out/libexec/setup-crossover.sh

makeWrapper $out/opt/cxoffice/bin/crossover $out/bin/crossover \ --run "$out/libexec/setup-crossover.sh" \ --set LSB_RELEASE "$out/etc/lsb-release" \ "''${gappsWrapperArgs[@]}"

chmod +x $out/opt/cxoffice/bin/*

runHook postInstall '';

meta = with lib; { description = "Run your Windows® apps on Linux"; homepage = "https://www.codeweavers.com/crossover&quot;; license = licenses.unfree; maintainers = with maintainers; [ ]; platforms = [ "x86_64-linux" ]; }; }

That's all I can think of for now. It would be easier if it were a PR - I'm not certain my MUA has formatted this correctly.

If you want, I could make a PR based on this, and add you to my fork?

Best wishes,

Dom Rodriguez

shymega commented 1 week ago

On 08.11.2024 12:58, liberodark wrote:

I think someone more knowledgeable than me should look at this topic. I'm just giving a possible way of crossover without steam-run But I have another idea in mind for the licensing issue.

I've sent a review - but in email format, quoting the code block.

Best wishes,

Dom Rodriguez

liberodark commented 1 day ago

Hi, for crossover I managed to do better via a FHS and I was even able to install and launch wine applications without steam-run. But I need time to think if I make a PR it is because I am sure that it could bring something currently in all my tests I could not activate the license.

PS : A review would be better in PR. But honestly I don't have a solution for the license part yet. I don't like the idea of ​​using flatpak so I would like to find a solution. But I don't have it yet I think some people could help us on this point and have much better idea or approach than me.

Best Regards

shymega commented 1 day ago

@liberodark You haven't posted the derivation here, so I can't see what you've done.

liberodark commented 18 hours ago

Hi, @shymega Sorry my English is not very good. I think we misunderstood each other. What I'm saying is that it would be interesting to have feedback from people who would have a better approach to propose than mine. And then to do a PR then Review.

Best Regards