Commit 7136764d authored by John Ericson's avatar John Ericson
Browse files

wine: Inline `staging.nix` and `util.nix`

Re `staging.nix`: It wasn't carrying its weight, and it interacted with
`base.nix` vs `default.nix` in bad ways.

Re `util.nix`: Once `staging.nix` is gone, `util.nix` is only used in
one file, and only one definition of it is used. Move that binding to
`base.nix`, and delete the rest.
parent b553e47e
Loading
Loading
Loading
Loading
+57 −9
Original line number Diff line number Diff line
@@ -24,14 +24,21 @@
  buildScript ? null,
  configureFlags ? [ ],
  mainProgram ? "wine",
  # Staging support
  useStaging ? false,
  autoconf,
  hexdump,
  perl,
  python3,
  gitMinimal,
}:

with import ./util.nix { inherit lib; };

let
  prevName = pname;
  prevConfigFlags = configureFlags;

  toBuildInputs = pkgArches: archPkgs: lib.concatLists (map archPkgs pkgArches);

  setupHookDarwin = makeSetupHook {
    name = "darwin-mingw-hook";
    substitutions = {
@@ -61,7 +68,15 @@ let
  badPlatforms = lib.optional (
    !supportFlags.mingwSupport || lib.any (flag: supportFlags.${flag}) darwinUnsupportedFlags
  ) "x86_64-darwin";

  # Staging patches (from src.staging when useStaging is true)
  stagingPatches = src.staging or null;
in
assert
  useStaging
  ->
    stagingPatches != null
    && lib.versions.majorMinor version == lib.versions.majorMinor stagingPatches.version;
stdenv.mkDerivation (
  finalAttrs:
  lib.optionalAttrs (buildScript != null) { builder = buildScript; }
@@ -89,7 +104,14 @@ stdenv.mkDerivation (

    nativeBuildInputs =
      with supportFlags;
      [
      lib.optionals useStaging [
        autoconf
        hexdump
        perl
        python3
        gitMinimal
      ]
      ++ [
        bison
        flex
        fontforge
@@ -101,9 +123,20 @@ stdenv.mkDerivation (
        mingwGccs ++ lib.optional stdenv.hostPlatform.isDarwin setupHookDarwin
      );

    buildInputs = toBuildInputs pkgArches (
    buildInputs =
      lib.optionals useStaging (
        toBuildInputs pkgArches (
          pkgs:
          [
            pkgs.perl
            pkgs.autoconf
            pkgs.gitMinimal
          ]
          ++ lib.optional stdenv.hostPlatform.isLinux pkgs.util-linux
        )
      )
      ++ toBuildInputs pkgArches (
        with supportFlags;
      (
        pkgs:
        [
          pkgs.freetype
@@ -191,11 +224,24 @@ stdenv.mkDerivation (
        ++ lib.optionals ffmpegSupport [
          pkgs.ffmpeg-headless
        ]
      )
      );

    inherit patches;

    prePatch =
      if !useStaging then
        null
      else
        ''
          patchShebangs tools
          cp -r ${stagingPatches}/patches ${stagingPatches}/staging .
          chmod +w patches
          patchShebangs ./patches/gitapply.sh
          python3 ./staging/patchinstall.py DESTDIR="$PWD" --all ${
            lib.concatMapStringsSep " " (ps: "-W ${ps}") stagingPatches.disabledPatchsets
          }
        '';

    configureFlags =
      prevConfigFlags
      ++ lib.optionals supportFlags.waylandSupport [ "--with-wayland" ]
@@ -291,7 +337,9 @@ stdenv.mkDerivation (
        fromSource
        binaryNativeCode # mono, gecko
      ];
      description = "Open Source implementation of the Windows API on top of X, OpenGL, and Unix";
      description =
        "Open Source implementation of the Windows API on top of X, OpenGL, and Unix"
        + lib.optionalString useStaging " (with staging patches)";
      inherit badPlatforms platforms;
      maintainers = with lib.maintainers; [
        avnik
+3 −4
Original line number Diff line number Diff line
@@ -100,10 +100,9 @@ let
    .${wineRelease} or null;
in
if baseRelease != null then
  callPackage ./staging.nix {
    wineUnstable = (wine-build wineBuild baseRelease).override {
  (wine-build wineBuild baseRelease).override {
    inherit wineRelease;
    };
    useStaging = true;
  }
else
  wine-build wineBuild wineRelease
+14 −0
Original line number Diff line number Diff line
@@ -9,6 +9,12 @@
  moltenvk,
  wineRelease ? "stable",
  supportFlags,
  # Staging native build deps
  autoconf,
  hexdump,
  perl,
  python3,
  gitMinimal,
}:

let
@@ -25,6 +31,14 @@ with src;
      patches
      moltenvk
      wineRelease
      # Forcing these `nativeBuildInputs` used in the `staging` to come
      # from ambient `pkgs`, rather than being provided by
      # `pkgsi686Linux.callPackage` for that platform.
      autoconf
      hexdump
      perl
      python3
      gitMinimal
      ;
    pkgArches = [ pkgsi686Linux ];
    geckos = [ gecko32 ];
+0 −53
Original line number Diff line number Diff line
{
  lib,
  stdenv,
  callPackage,
  autoconf,
  hexdump,
  perl,
  python3,
  wineUnstable,
  gitMinimal,
}:

with callPackage ./util.nix { };

let
  patch = wineUnstable.src.staging;
  build-inputs = pkgNames: extra: (mkBuildInputs wineUnstable.pkgArches pkgNames) ++ extra;
in
assert lib.versions.majorMinor wineUnstable.version == lib.versions.majorMinor patch.version;

wineUnstable.overrideAttrs (self: {
  buildInputs = build-inputs (
    [
      "perl"
      "autoconf"
      "gitMinimal"
    ]
    ++ lib.optional stdenv.hostPlatform.isLinux "util-linux"
  ) self.buildInputs;
  nativeBuildInputs = [
    autoconf
    hexdump
    perl
    python3
    gitMinimal
  ]
  ++ self.nativeBuildInputs;

  prePatch = self.prePatch or "" + ''
    patchShebangs tools
    cp -r ${patch}/patches ${patch}/staging .
    chmod +w patches
    patchShebangs ./patches/gitapply.sh
    python3 ./staging/patchinstall.py DESTDIR="$PWD" --all ${
      lib.concatMapStringsSep " " (ps: "-W ${ps}") patch.disabledPatchsets
    }
  '';
})
// {
  meta = wineUnstable.meta // {
    description = wineUnstable.meta.description + " (with staging patches)";
  };
}
+0 −6
Original line number Diff line number Diff line
{ lib }:
rec {
  toPackages = pkgNames: pkgs: map (pn: lib.getAttr pn pkgs) pkgNames;
  toBuildInputs = pkgArches: archPkgs: lib.concatLists (map archPkgs pkgArches);
  mkBuildInputs = pkgArches: pkgNames: toBuildInputs pkgArches (toPackages pkgNames);
}