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

newt, python3Packages.snack: fix darwin linking #385725

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -32,40 +33,66 @@ stdenv.mkDerivation rec {
'';

strictDeps = true;
nativeBuildInputs = [ python ];
buildInputs = [
slang
popt
];
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
# programs to use at different stages.
unset CPP
'';

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

makeFlags = lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [
Copy link
Member Author

@bryango bryango Feb 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

--disable-nls can be removed now as the required gettext is added for darwin.

"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
'';

meta = with lib; {
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 = {
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 ];
};
}
2 changes: 0 additions & 2 deletions pkgs/top-level/all-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9970,8 +9970,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; };
Expand Down
2 changes: 1 addition & 1 deletion pkgs/top-level/python-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -15266,7 +15266,7 @@ self: super: with self; {
smtpdfix = callPackage ../development/python-modules/smtpdfix { };

snack = toPythonModule (pkgs.newt.override {
inherit (self) python;
python3 = self.python;
});

snakemake = toPythonModule (pkgs.snakemake.override {
Expand Down