Commit 0e598024 authored by Martino Fontana's avatar Martino Fontana
Browse files

bottles: wrap in FHS

parent f560c82d
Loading
Loading
Loading
Loading
+2 −30
Original line number Diff line number Diff line
@@ -14,7 +14,6 @@
, gtk4
, gtksourceview5
, libadwaita
, steam
, cabextract
, p7zip
, xdpyinfo
@@ -26,46 +25,20 @@
, mangohud
, vkbasalt-cli
, vmtouch
, wine
, bottlesExtraLibraries ? pkgs: [ ] # extra packages to add to steam.run multiPkgs
, bottlesExtraPkgs ? pkgs: [ ] # extra packages to add to steam.run targetPkgs
}:

let
  steam-run = (steam.override {
    # required by wine runner `caffe`
    extraLibraries = pkgs: with pkgs; [ libunwind libusb1 gnutls ]
      ++ bottlesExtraLibraries pkgs;
    extraPkgs = pkgs: [ ]
      ++ bottlesExtraPkgs pkgs;
  }).run;
in
python3Packages.buildPythonApplication rec {
  pname = "bottles";
  pname = "bottles-unwrapped";
  version = "2022.11.14";

  src = fetchFromGitHub {
    owner = "bottlesdevs";
    repo = pname;
    repo = "bottles";
    rev = version;
    sha256 = "sha256-bigrJtqx9iZURYojwxlGe7xSGWS13wSaGcrTTROP9J8=";
  };

  patches = [ ./vulkan_icd.patch ];

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

    substituteInPlace bottles/backend/wine/winecommand.py \
      --replace \
        "command = f\"{runner} {command}\"" \
        "command = f\"{''' if runner == 'wine' or runner == 'wine64' else '${steam-run}/bin/steam-run '}{runner} {command}\"" \
      --replace \
        "command = f\"{_picked['entry_point']} {command}\"" \
        "command = f\"${steam-run}/bin/steam-run {_picked['entry_point']} {command}\""
    '';

  nativeBuildInputs = [
    blueprint-compiler
    meson
@@ -109,7 +82,6 @@ python3Packages.buildPythonApplication rec {
    gamescope
    mangohud
    vmtouch
    wine

    # Undocumented (subprocess.Popen())
    lsb-release
+101 −0
Original line number Diff line number Diff line
{ lib
, buildFHSUserEnvBubblewrap
, symlinkJoin
, bottles-unwrapped
, extraPkgs ? pkgs: [ ]
, extraLibraries ? pkgs: [ ]
}:

let fhsEnv = {
  targetPkgs = pkgs: with pkgs; [
    bottles-unwrapped
    vkbasalt
  ] ++ extraPkgs pkgs;

  multiPkgs =
    let
      xorgDeps = pkgs: with pkgs.xorg; [
        libpthreadstubs
        libSM
        libX11
        libXaw
        libxcb
        libXcomposite
        libXcursor
        libXdmcp
        libXext
        libXi
        libXinerama
        libXmu
        libXrandr
        libXrender
        libXv
        libXxf86vm
      ];
    in
    pkgs: with pkgs; [
      # https://wiki.winehq.org/Building_Wine
      alsa-lib
      cups
      dbus
      fontconfig
      freetype
      glib
      gnutls
      libglvnd
      gsm
      gst_all_1.gstreamer
      gst_all_1.gst-plugins-base
      libgphoto2
      libjpeg_turbo
      libkrb5
      libpcap
      libpng
      libpulseaudio
      libtiff
      libunwind
      libusb1
      libv4l
      libxml2
      mpg123
      ocl-icd
      openldap
      samba4
      sane-backends
      SDL2
      udev
      vulkan-loader

      # https://www.gloriouseggroll.tv/how-to-get-out-of-wine-dependency-hell/
      alsa-plugins
      dosbox
      giflib
      gtk3
      libva
      libxslt
      ncurses
      openal

      # Steam runtime
      libgcrypt
      libgpg-error
      p11-kit
      zlib # Freetype
    ] ++ xorgDeps pkgs
    ++ extraLibraries pkgs;
};
in
symlinkJoin {
  name = "bottles";
  paths = [
    (buildFHSUserEnvBubblewrap (fhsEnv // { name = "bottles"; runScript = "bottles"; }))
    (buildFHSUserEnvBubblewrap (fhsEnv // { name = "bottles-cli"; runScript = "bottles-cli"; }))
  ];
  postBuild = ''
    mkdir -p $out/share
    ln -s ${bottles-unwrapped}/share/applications $out/share
    ln -s ${bottles-unwrapped}/share/icons $out/share
  '';

  inherit (bottles-unwrapped) meta;
}
+3 −3
Original line number Diff line number Diff line
@@ -27752,9 +27752,9 @@ with pkgs;
  bonzomatic = callPackage ../applications/editors/bonzomatic { };
  bottles = callPackage ../applications/misc/bottles {
    wine = null;
  };
  bottles = callPackage ../applications/misc/bottles/fhsenv.nix { };
  bottles-unwrapped = callPackage ../applications/misc/bottles { };
  brave = callPackage ../applications/networking/browsers/brave { };