Unverified Commit e809d5d9 authored by Aleksana's avatar Aleksana Committed by GitHub
Browse files

newt, python3Packages.snack: fix darwin linking (#385725)

parents c7b02aa1 cb1a729a
Loading
Loading
Loading
Loading
+43 −16
Original line number Diff line number Diff line
@@ -4,11 +4,12 @@
  stdenv,
  slang,
  popt,
  python,
  python3,
  gettext,
}:

let
  pythonIncludePath = "${lib.getDev python}/include/python";
  pythonIncludePath = "${lib.getDev python3}/include/python";
in
stdenv.mkDerivation rec {
  pname = "newt";
@@ -32,13 +33,19 @@ stdenv.mkDerivation rec {
  '';

  strictDeps = true;
  nativeBuildInputs = [ python ];
  buildInputs = [
  nativeBuildInputs = [ python3 ];
  buildInputs =
    [
      slang
      popt
    ]
    ++ lib.optionals stdenv.hostPlatform.isDarwin [
      gettext # for darwin with clang
    ];

  NIX_LDFLAGS = "-lncurses";
  NIX_LDFLAGS =
    "-lncurses"
    + lib.optionalString stdenv.hostPlatform.isDarwin " -L${python3}/lib -lpython${python3.pythonVersion}";

  preConfigure = ''
    # If CPP is set explicitly, configure and make will not agree about which
@@ -46,26 +53,46 @@ stdenv.mkDerivation rec {
    unset CPP
  '';

  configureFlags = lib.optionals stdenv.hostPlatform.isDarwin [
    "--disable-nls"
  ];

  makeFlags = lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [
    "CROSS_COMPILE=${stdenv.cc.targetPrefix}"
  ];

  postFixup = lib.optionalString stdenv.hostPlatform.isDarwin ''
    set -xe
    install_name_tool -id $out/lib/libnewt.so.${version} $out/lib/libnewt.so.${version}
    install_name_tool -change libnewt.so.${version} $out/lib/libnewt.so.${version} $out/bin/whiptail
    install_name_tool -change libnewt.so.${version} $out/lib/libnewt.so.${version} \
      $out/lib/python*/site-packages/_snack* # glob for version & suffix
    set +x
  '';

  passthru.tests.pythonModule = (python3.withPackages (ps: [ ps.snack ])).overrideAttrs (
    { nativeBuildInputs, postBuild, ... }@_prevAttrs:
    {
      nativeBuildInputs = nativeBuildInputs ++ [ python3.pkgs.pythonImportsCheckHook ];
      pythonImportsCheck = [ "snack" ];
      /**
        Call pythonImportsCheckPhase manually. This is necessary because:
        - pythonImportsCheckHook adds the check to $preDistPhases
        - python3.withPackages is built with a version of `buildEnv`,
          ... which is implemented by `runCommand`,
          ... which has a custom builder and does not run $preDistPhases
      */
      postBuild =
        postBuild
        + ''
          runPhase pythonImportsCheckPhase
        '';
    }
  );

  meta = with lib; {
  meta = {
    description = "Library for color text mode, widget based user interfaces";
    mainProgram = "whiptail";
    homepage = "https://pagure.io/newt";
    changelog = "https://pagure.io/newt/blob/master/f/CHANGES";
    license = licenses.lgpl2;
    platforms = platforms.unix;
    maintainers = [ ];
    license = lib.licenses.lgpl2;
    platforms = lib.platforms.unix;
    maintainers = with lib.maintainers; [ bryango ];
  };
}
+0 −2
Original line number Diff line number Diff line
@@ -9721,8 +9721,6 @@ with pkgs;
  nettle = import ../development/libraries/nettle { inherit callPackage fetchurl; };
  newt = callPackage ../development/libraries/newt { python = python3; };
  libnghttp2 = nghttp2.lib;
  nghttp3 = callPackage ../development/libraries/nghttp3 { inherit (darwin.apple_sdk.frameworks) CoreServices; };
+1 −1
Original line number Diff line number Diff line
@@ -15836,7 +15836,7 @@ self: super: with self; {
  smtpdfix = callPackage ../development/python-modules/smtpdfix { };
  snack = toPythonModule (pkgs.newt.override { inherit (self) python; });
  snack = toPythonModule (pkgs.newt.override { python3 = self.python; });
  snakebite = callPackage ../development/python-modules/snakebite { };