Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Using bottles on nonFHS systems (e.g. NixOS) #72

Closed
ghost opened this issue Jan 3, 2021 · 12 comments
Closed

[BUG] Using bottles on nonFHS systems (e.g. NixOS) #72

ghost opened this issue Jan 3, 2021 · 12 comments

Comments

@ghost
Copy link

ghost commented Jan 3, 2021

Describe the bug
I wanna maintain a bottles package for NixOS. Therefore I have written a (not yet polished) nix derivation (see under "Additional context"). The packaging itself is correct and bottles execute without any further error.

If you try to create a bottle, bottles respectively the lutris/proton/… runner throws an error (see NixOS/nixpkgs#108256). The problem here is that the runners are downloaded from the github releases without further patching, what is unproblematic for the most Linux systems, but not for NixOS.

NixOS has a store concept, what means the most files aren't at the place you would expect it to be. The extracted runners are now trying to use the loader /lib64/ld-linux-x86-64.so.2 and don't find the LD binary. Actually the binary is somewhere like /nix/store/1yvpgm763b3hvg8q4gzpzmflr5674x4j-glibc-2.32-10/lib64/ld-linux-x86-64.so.2.

Normally you circumvent this situation with something like patchelf or using autopatchelf, but this is only applies to packaging. As the binaries are extracted at runtime, patching them would be required also at runtime, either from bottles itself or maually from the user (through patchelf e.g.). Both solutions are not that perfect, I think.

A better solution could be packaging the different runners in seperate namespace, so they could be installed through the different tools (declarative, through nix-env, etc.), e.g. nixos.bottlesRunner.lutris-6.0-rc1-x86_64; this would allow patching them.

But therefore it would be needed that bottles looks for pre-installed runners. I don't know if it's better to load them directly from the nix-store or copy them to $XDG_DATA_HOME/bottles/runners before using them.

Please let me know what you think about that topic. 👍

Installation

  • Method: Meson build
  • Version: 270a0ba

To Reproduce
Steps to reproduce the behavior:

  1. Compile the given nix derivation.
  2. Execute bottles.
  3. Create a new bottle.
  4. See error

Expected behavior
The runner binaries execute without any further error.

Desktop (please complete the following information):

  • OS: NixOS
  • Version: 20.09 (Nightingale)

Additional context

Nix file:

{ stdenv
, fetchurl
, python3Packages
, meson
, ninja
, pkgconfig
, itstool
, gettext
, gtk3
, python3
, glib
, gdk-pixbuf
, gobject-introspection
, gnome3
, gtksourceview4
, json-glib
, gspell
, gsettings-desktop-schemas
, desktop-file-utils
, wine
, libnotify
, wrapGAppsHook
}:

python3Packages.buildPythonApplication rec {
  pname = "bottles";
  version = "2.0.9.1";

  src = fetchurl {
    url = "https://github.com/bottlesdevs/${pname}/archive/${version}.tar.gz";
    sha256 = "0f3aqd2jyg81xsb71zx3ljzhk41jgn9pnw7mf9k80p213k4z0p40";
  };

  nativeBuildInputs = [
    meson
    ninja
    itstool
    gettext
    wrapGAppsHook
    gobject-introspection
  ];
  
  buildInputs = [
    glib
    gtk3
    json-glib
    gspell
    gobject-introspection
    gsettings-desktop-schemas
    desktop-file-utils
    gdk-pixbuf
    libnotify
    wine
  ];
  
  propagatedBuildInputs = with python3Packages; [
    pycairo
    pygobject3
    lxml
    dbus-python
    gst-python
    liblarch
  ];

  format = "other";
  strictDeps = false; # broken with gobject-introspection setup hook https://github.com/NixOS/nixpkgs/issues/56943
  doCheck = false; # why?
  dontWrapGApps = true; # prevent double wrapping
  
  preConfigure = ''
    substituteInPlace build-aux/meson/postinstall.py \
      --replace "'update-desktop-database'" \
                "'${desktop-file-utils}/bin/update-desktop-database'"
  '';
  
  preFixup = ''
    makeWrapperArgs+=("''${gappsWrapperArgs[@]}")
  '';

  postPatch = ''
    chmod +x build-aux/meson/postinstall.py
    patchShebangs build-aux/meson/postinstall.py
  '';

  passthru = {
    updateScript = gnome3.updateScript {
      packageName = pname;
    };
  };

  meta = with stdenv.lib; {
    description = "Easily manage wine prefix in a new way! (Run Windows software and games on Linux)";
    homepage = "https://github.com/bottlesdevs/Bottles";
    license = licenses.gpl3Only;
    maintainers = with maintainers; [ bloomvdomino ];
    platforms = platforms.linux;
  };
}

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

@mirkobrombin
Copy link
Member

Hi thanks for being interested in bringing Bottles to NixOS.
I have never used or explored this distribution before but I hope I can help you.

Packing runners externally could be a solution but the Bottles functions that searches and installs updates should be disabled (it would also change the nature of the program itself).

It might be a good starting point to understand how Lutris (who also manages several runners) was ported to NixOS.
NixOS/nixpkgs#61742

@mirkobrombin
Copy link
Member

Also I see this portion of code which I think is declaring where the ld library is located:

...
    makeWrapperArgs = [
      "--prefix LD_LIBRARY_PATH : ${fullPath}:$out/lib"
      "--set GI_TYPELIB_PATH $GI_TYPELIB_PATH"
      "--prefix XDG_DATA_DIRS : $out/share"
      "--suffix XDG_DATA_DIRS : $XDG_ICON_DIRS:$GSETTINGS_SCHEMAS_PATH"
    ];
...

File: https://github.com/NixOS/nixpkgs/pull/61742/files#diff-d27e2469cae06cbf9f4d86d1dabd797af9a738af2ff79f93672eb88563601a21R134

@ghost
Copy link
Author

ghost commented Jan 3, 2021

Thanks for elaborating a little bit.

Yeah, I already assumed it would be the best way to do it like this. The lutris game runner uses buildFHSUserEnv, which creates a sandbox-like environment which is mostly FHS-conform. It tends to be a bit tricky when it comes to maintenance, e.g. graphic drivers, but I think I could work around it. (That was the reason why I didn't do that first!)

I'll rewrite the derivation soon, than we'll see if it works flawlessly!

@mirkobrombin
Copy link
Member

Thanks for elaborating a little bit.

Yeah, I already assumed it would be the best way to do it like this. The lutris game runner uses buildFHSUserEnv, which creates a sandbox-like environment which is mostly FHS-conform. It tends to be a bit tricky when it comes to maintenance, e.g. graphic drivers, but I think I could work around it. (That was the reason why I didn't do that first!)

I'll rewrite the derivation soon, than we'll see if it works flawlessly!

Great, keep us updated!

@ghost
Copy link
Author

ghost commented Jan 14, 2021

Actually I'm busy with exams preparation, but I'll keep working on it from time to time!

@mirkobrombin
Copy link
Member

Actually I'm busy with exams preparation, but I'll keep working on it from time to time!

No problem, thanks for your contribution.

@ghost
Copy link
Author

ghost commented Feb 16, 2021

I'm finished so far. I've used steam-run-native as environment for packaging, which provides an FHS-conform environment (tailored to Proton and wine).

bottles throws Cannot find executable for [name-of-program.lnk] for some applications (e.g. Mp3tag). Other, like EditPad Lite or NotePad++, are working, therefore I think the fault is on the other side. (Maybe we can evaluate the error in a further issue).

Any comments about the nix expression? Otherwise I'll submit it in the next days (after a little bit polishing)! 😄

Nix file:

{ lib
, stdenv
, fetchFromGitHub
, python3Packages
, meson
, ninja
, pkg-config
, appstream-glib
, itstool
, gettext
, gtk3
, python3
, glib
, gdk-pixbuf
, gobject-introspection
, json-glib
, gspell
, steam-run-native
, gsettings-desktop-schemas
, desktop-file-utils
, wine
, libnotify
, wrapGAppsHook
}:

python3Packages.buildPythonApplication rec {
  pname = "bottles";
  version = "2.1.0.6";

  src = fetchFromGitHub {
    owner = "bottlesdevs";
    repo = pname;
    rev = "dc116cdd1e9facc741ad9538a22113be8b678694";
    sha256 = "1xwqnsa4j7l2bbrxkb3z4w2yzv4qgkk3cmisk2iz8m8bm6i0p9qb";
  };

  nativeBuildInputs = [
    meson
    ninja
    itstool
    gettext
    pkg-config
    wrapGAppsHook
    gobject-introspection
  ];
  
  buildInputs = [
    appstream-glib
    glib
    gtk3
    json-glib
    gspell
    gobject-introspection
    gsettings-desktop-schemas
    desktop-file-utils
    gdk-pixbuf
    libnotify
    wine
  ];
  
  propagatedBuildInputs = with python3Packages; [
    pycairo
    pygobject3
    lxml
    dbus-python
    gst-python
    liblarch
  ] ++ [ steam-run-native ];

  format = "other";
  strictDeps = false; # broken with gobject-introspection setup hook https://github.com/NixOS/nixpkgs/issues/56943
  doCheck = false; # why?
  dontWrapGApps = true; # prevent double wrapping
  
  preConfigure = ''
    substituteInPlace build-aux/meson/postinstall.py \
      --replace "'update-desktop-database'" \
                "'${desktop-file-utils}/bin/update-desktop-database'"
    substituteInPlace src/runner.py \
      --replace " {runner}" \
                " ${steam-run-native}/bin/steam-run {runner}"
    substituteInPlace src/runner.py \
      --replace " {dxvk_setup}" \
                " ${steam-run-native}/bin/steam-run {dxvk_setup}"
  '';
  
  preFixup = ''
    makeWrapperArgs+=("''${gappsWrapperArgs[@]}")
  '';

  postPatch = ''
    chmod +x build-aux/meson/postinstall.py
    patchShebangs build-aux/meson/postinstall.py
  '';

  meta = with lib; {
    description = "Easily manage wine prefix in a new way! (Run Windows software and games on Linux)";
    homepage = "https://github.com/bottlesdevs/Bottles";
    license = licenses.gpl3Only;
    maintainers = with maintainers; [ bloomvdomino ];
    platforms = platforms.linux;
  };
}

@mirkobrombin
Copy link
Member

I'm finished so far. I've used steam-run-native as environment for packaging, which provides an FHS-conform environment (tailored to Proton and wine).

bottles throws Cannot find executable for [name-of-program.lnk] for some applications (e.g. Mp3tag). Other, like EditPad Lite or NotePad++, are working, therefore I think the fault is on the other side. (Maybe we can evaluate the error in a further issue).

Any comments about the nix expression? Otherwise I'll submit it in the next days (after a little bit polishing)!

Nix file:

{ lib
, stdenv
, fetchFromGitHub
, python3Packages
, meson
, ninja
, pkg-config
, appstream-glib
, itstool
, gettext
, gtk3
, python3
, glib
, gdk-pixbuf
, gobject-introspection
, json-glib
, gspell
, steam-run-native
, gsettings-desktop-schemas
, desktop-file-utils
, wine
, libnotify
, wrapGAppsHook
}:

python3Packages.buildPythonApplication rec {
  pname = "bottles";
  version = "2.1.0.6";

  src = fetchFromGitHub {
    owner = "bottlesdevs";
    repo = pname;
    rev = "dc116cdd1e9facc741ad9538a22113be8b678694";
    sha256 = "1xwqnsa4j7l2bbrxkb3z4w2yzv4qgkk3cmisk2iz8m8bm6i0p9qb";
  };

  nativeBuildInputs = [
    meson
    ninja
    itstool
    gettext
    pkg-config
    wrapGAppsHook
    gobject-introspection
  ];
  
  buildInputs = [
    appstream-glib
    glib
    gtk3
    json-glib
    gspell
    gobject-introspection
    gsettings-desktop-schemas
    desktop-file-utils
    gdk-pixbuf
    libnotify
    wine
  ];
  
  propagatedBuildInputs = with python3Packages; [
    pycairo
    pygobject3
    lxml
    dbus-python
    gst-python
    liblarch
  ] ++ [ steam-run-native ];

  format = "other";
  strictDeps = false; # broken with gobject-introspection setup hook https://github.com/NixOS/nixpkgs/issues/56943
  doCheck = false; # why?
  dontWrapGApps = true; # prevent double wrapping
  
  preConfigure = ''
    substituteInPlace build-aux/meson/postinstall.py \
      --replace "'update-desktop-database'" \
                "'${desktop-file-utils}/bin/update-desktop-database'"
    substituteInPlace src/runner.py \
      --replace " {runner}" \
                " ${steam-run-native}/bin/steam-run {runner}"
    substituteInPlace src/runner.py \
      --replace " {dxvk_setup}" \
                " ${steam-run-native}/bin/steam-run {dxvk_setup}"
  '';
  
  preFixup = ''
    makeWrapperArgs+=("''${gappsWrapperArgs[@]}")
  '';

  postPatch = ''
    chmod +x build-aux/meson/postinstall.py
    patchShebangs build-aux/meson/postinstall.py
  '';

  meta = with lib; {
    description = "Easily manage wine prefix in a new way! (Run Windows software and games on Linux)";
    homepage = "https://github.com/bottlesdevs/Bottles";
    license = licenses.gpl3Only;
    maintainers = with maintainers; [ bloomvdomino ];
    platforms = platforms.linux;
  };
}

Hope all is well with the exams! Thank you so much for your work and if you can open a new issue for the other issue so we can track it.

While work has begun on a new version of bottles and some things have changed, I don't know if the problem also occurs with v3. We'll see.

@ghost
Copy link
Author

ghost commented Mar 7, 2021

PR was merged: NixOS/nixpkgs#113825.

I'll package v3/v4 at the point it's feature/GUI-complete at the same level as v2. 😀

I think we can close this for now…

@ghost ghost closed this as completed Mar 7, 2021
@mirkobrombin
Copy link
Member

The v3 is currently the most stable release btw. Thanks for your support btw!

@ghost
Copy link
Author

ghost commented Mar 7, 2021

I know :) But there are some graphical glitches in v3 under NixOS. Even with the default Adwaita theme. Especially under the main view for each bottle.

I don't know if that's an NixOS only error (as I only have NixOS devices) or not. Maybe I'll debug that in a VM and open an issue if the glitches persist.

Therefore I thought v3 wasn't stable yet ;) Mea culpa…

@mirkobrombin
Copy link
Member

I know :) But there are some graphical glitches in v3 under NixOS. Even with the default Adwaita theme. Especially under the main view for each bottle.

I don't know if that's an NixOS only error (as I only have NixOS devices) or not. Maybe I'll debug that in a VM and open an issue if the glitches persist.

Therefore I thought v3 wasn't stable yet ;) Mea culpa…

Ah ok I didn't even think about it because I've never tried NixOS :D

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants