Unverified Commit d96826b3 authored by Matt Sturgeon's avatar Matt Sturgeon Committed by GitHub
Browse files

jetbrains: switch builder to use extendMkDerivation pattern (#478575)

parents da80bc24 a6276deb
Loading
Loading
Loading
Loading
+47 −46
Original line number Diff line number Diff line
# Darwin-specific base builder.
# TODO:
#   This actually just ignores a lot of options passed to it... (e.g. buildInputs)
#   - not entirely sure how this hasn't caused big problems yet.

{
  lib,
  stdenvNoCC,
  undmg,

  excludeDrvArgNames,
  ...
}:

lib.extendMkDerivation {
  inherit excludeDrvArgNames;

  constructDrv = stdenvNoCC.mkDerivation;

  extendDrvArgs =
    finalAttrs:
    {
  meta,
  pname,
      product,
  productShort,
  src,
  version,
  passthru,
      productShort ? product,

  plugins ? [ ],
      nativeBuildInputs ? [ ],
      meta ? { },
      ...
    }:

    let
      loname = lib.toLower productShort;
    in
stdenvNoCC.mkDerivation {
  inherit
    pname
    src
    version
    plugins
    passthru
    ;
  meta = meta // {
    mainProgram = loname;
  };
    {
      desktopName = product;

      dontFixup = true;

      installPhase = ''
        runHook preInstall
        APP_DIR="$out/Applications/${product}.app"
@@ -52,6 +46,13 @@ stdenvNoCC.mkDerivation {
        chmod +x "$out/bin/${loname}"
        runHook postInstall
      '';
  nativeBuildInputs = [ undmg ];

      nativeBuildInputs = nativeBuildInputs ++ [ undmg ];

      sourceRoot = ".";

      meta = meta // {
        mainProgram = loname;
      };
    };
}
+45 −63
Original line number Diff line number Diff line
@@ -6,67 +6,48 @@
  callPackage,

  jdk,
  fontconfig,
  libGL,
  libX11,

  vmopts ? null,
  forceWayland ? false,
}:
let
  baseBuilder = if stdenv.hostPlatform.isDarwin then ./darwin.nix else ./linux.nix;
  mkJetBrainsProductCore = callPackage baseBuilder { inherit vmopts; };
in
# Makes a JetBrains IDE
lib.extendMkDerivation {
  constructDrv = callPackage baseBuilder {
    inherit vmopts jdk forceWayland;
    # Args to not pass to mkDerivation in the base builders. Since both get the same args
    # passed in, both have the same list of args to ignore, even if they don't both use
    # all of them.
    excludeDrvArgNames = [
      "product"
      "productShort"
      "buildNumber"
      "wmClass"
      "libdbm"
      "fsnotifier"
      "extraLdPath"
      "extraWrapperArgs"
    ];
  };

  extendDrvArgs =
    # NOTE: See linux.nix and darwin.nix for additional specific arguments
    finalAttrs:
    {
  pname,
  src,
  version,
      buildNumber,
  wmClass,
      product,
  productShort ? product,
  meta,

      libdbm,
      fsnotifier,

  extraWrapperArgs ? [ ],
  extraLdPath ? [ ],
  buildInputs ? [ ],
      meta ? { },
      passthru ? { },
      ...
    }:
mkJetBrainsProductCore {
  inherit
    pname
    extraLdPath
    jdk
    src
    version
    buildNumber
    wmClass
    product
    productShort
    libdbm
    fsnotifier
    ;

  buildInputs =
    buildInputs
    ++ [ stdenv.cc.cc ]
    ++ lib.optionals stdenv.hostPlatform.isLinux [
      fontconfig
      libGL
      libX11
    ];

  extraWrapperArgs =
    extraWrapperArgs
    ++ lib.optionals (stdenv.hostPlatform.isLinux && forceWayland) [
      ''--add-flags "\''${WAYLAND_DISPLAY:+-Dawt.toolkit.name=WLToolkit}"''
    ];

  passthru = lib.recursiveUpdate passthru {
    {
      passthru = passthru // {
        inherit
          buildNumber
          product
@@ -77,11 +58,12 @@ mkJetBrainsProductCore {
        updateScript = ../updater/main.py;

        tests = {
      plugins = callPackage ../plugins/tests.nix { ideName = pname; };
          plugins = callPackage ../plugins/tests.nix { ide = finalAttrs.finalPackage; };
        };
      };

      meta = meta // {
        teams = [ lib.teams.jetbrains ];
      };
    };
}
+167 −151
Original line number Diff line number Diff line
@@ -18,20 +18,29 @@
  e2fsprogs,
  python3,
  autoPatchelfHook,
  vmopts ? null,
  glibcLocales,
  fontconfig,
  libGL,
  libX11,

  jdk,
  vmopts ? null,
  forceWayland ? null,
  excludeDrvArgNames,
}:

lib.extendMkDerivation {
  inherit excludeDrvArgNames;

  constructDrv = stdenv.mkDerivation;

  extendDrvArgs =
    finalAttrs:
    {
      pname,
      product,
  productShort,
  version,
  src,
      productShort ? product,
      wmClass,
  jdk,
  meta,
  passthru,

      libdbm,
      fsnotifier,
@@ -39,35 +48,28 @@
      extraLdPath ? [ ],
      extraWrapperArgs ? [ ],
      buildInputs ? [ ],
      nativeBuildInputs ? [ ],
      meta ? { },
      postPatch ? "",
      ...
}@args:
    }:

    let
      loName = lib.toLower productShort;
      hiName = lib.toUpper productShort;
      vmoptsName = loName + lib.optionalString stdenv.hostPlatform.is64bit "64" + ".vmoptions";
in

with stdenv;
lib.makeOverridable mkDerivation (
  rec {
    inherit
      pname
      version
      src
      buildInputs
      passthru
      ;
    meta = args.meta // {
      mainProgram = pname;
    };
      finalExtraWrapperArgs =
        extraWrapperArgs
        ++ lib.optionals forceWayland [
          ''--add-flags "\''${WAYLAND_DISPLAY:+-Dawt.toolkit.name=WLToolkit}"''
        ];

      desktopItem = makeDesktopItem {
      name = pname;
      exec = pname;
      comment = lib.trim (lib.replaceString "\n" " " meta.longDescription);
        name = finalAttrs.pname;
        exec = finalAttrs.meta.mainProgram;
        comment = lib.trim (lib.replaceString "\n" " " finalAttrs.meta.longDescription);
        desktopName = product;
      genericName = meta.description;
        genericName = finalAttrs.meta.description;
        categories = [ "Development" ];
        icon = pname;
        startupWMClass = wmClass;
@@ -75,8 +77,18 @@ lib.makeOverridable mkDerivation (

      vmoptsIDE = if hiName == "WEBSTORM" then "WEBIDE" else hiName;
      vmoptsFile = lib.optionalString (vmopts != null) (writeText vmoptsName vmopts);
    in
    {
      inherit desktopItem vmoptsIDE vmoptsFile;

    nativeBuildInputs = [
      buildInputs = buildInputs ++ [
        stdenv.cc.cc
        fontconfig
        libGL
        libX11
      ];

      nativeBuildInputs = nativeBuildInputs ++ [
        makeWrapper
        patchelf
        unzip
@@ -110,7 +122,8 @@ lib.makeOverridable mkDerivation (
            udev
          ]
        } >> $vmopts_file
    '';
      ''
      + postPatch;

      installPhase = ''
        runHook preInstall
@@ -149,7 +162,7 @@ lib.makeOverridable mkDerivation (
            }" \
            --suffix PATH : "${lib.makeBinPath [ python3 ]}" \
            --prefix LD_LIBRARY_PATH : "${lib.makeLibraryPath extraLdPath}" \
          ${lib.concatStringsSep " " extraWrapperArgs} \
            ${lib.concatStringsSep " " finalExtraWrapperArgs} \
            --set-default JDK_HOME "$jdk" \
            --set-default ANDROID_JAVA_HOME "$jdk" \
            --set-default JAVA_HOME "$jdk" \
@@ -173,8 +186,11 @@ lib.makeOverridable mkDerivation (

        runHook postInstall
      '';

      preferLocalBuild = !(finalAttrs.meta.license.free or true);

      meta = meta // {
        mainProgram = pname;
      };
    };
}
  // lib.optionalAttrs (!(meta.license.free or true)) {
    preferLocalBuild = true;
  }
)
+3 −1
Original line number Diff line number Diff line
@@ -47,7 +47,9 @@ mkJetBrainsProduct {

  src = fetchurl (urls.${system} or (throw "Unsupported system: ${system}"));

  buildInputs = [
  # NOTE: This `lib.optionals` is only here because the old Darwin builder ignored `buildInputs`.
  #       DataSpell may need these, even on Darwin!
  buildInputs = lib.optionals stdenv.hostPlatform.isLinux [
    libgcc
    (runCommand "libR" { } ''
      mkdir -p $out/lib
+3 −3
Original line number Diff line number Diff line
@@ -6,12 +6,12 @@
  fetchzip,
  fetchurl,
  # If not set, all IDEs are tested.
  ideName ? null,
  ide ? null,
}:

let
  ides =
    if ideName == null then
    if ide == null then
      with jetbrains;
      [
        clion
@@ -31,7 +31,7 @@ let
        webstorm
      ]
    else
      [ (jetbrains.${ideName}) ];
      [ ide ];
in
{
  # Check to see if the process for adding plugins is breaking anything, instead of the plugins themselves
Loading