Skip to content

Commit e809d5d

Browse files
authored
newt, python3Packages.snack: fix darwin linking (NixOS#385725)
2 parents c7b02aa + cb1a729 commit e809d5d

File tree

3 files changed

+44
-19
lines changed

3 files changed

+44
-19
lines changed

pkgs/development/libraries/newt/default.nix renamed to pkgs/by-name/ne/newt/package.nix

Lines changed: 43 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@
44
stdenv,
55
slang,
66
popt,
7-
python,
7+
python3,
8+
gettext,
89
}:
910

1011
let
11-
pythonIncludePath = "${lib.getDev python}/include/python";
12+
pythonIncludePath = "${lib.getDev python3}/include/python";
1213
in
1314
stdenv.mkDerivation rec {
1415
pname = "newt";
@@ -32,40 +33,66 @@ stdenv.mkDerivation rec {
3233
'';
3334

3435
strictDeps = true;
35-
nativeBuildInputs = [ python ];
36-
buildInputs = [
37-
slang
38-
popt
39-
];
36+
nativeBuildInputs = [ python3 ];
37+
buildInputs =
38+
[
39+
slang
40+
popt
41+
]
42+
++ lib.optionals stdenv.hostPlatform.isDarwin [
43+
gettext # for darwin with clang
44+
];
4045

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

4350
preConfigure = ''
4451
# If CPP is set explicitly, configure and make will not agree about which
4552
# programs to use at different stages.
4653
unset CPP
4754
'';
4855

49-
configureFlags = lib.optionals stdenv.hostPlatform.isDarwin [
50-
"--disable-nls"
51-
];
52-
5356
makeFlags = lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [
5457
"CROSS_COMPILE=${stdenv.cc.targetPrefix}"
5558
];
5659

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

62-
meta = with lib; {
69+
passthru.tests.pythonModule = (python3.withPackages (ps: [ ps.snack ])).overrideAttrs (
70+
{ nativeBuildInputs, postBuild, ... }@_prevAttrs:
71+
{
72+
nativeBuildInputs = nativeBuildInputs ++ [ python3.pkgs.pythonImportsCheckHook ];
73+
pythonImportsCheck = [ "snack" ];
74+
/**
75+
Call pythonImportsCheckPhase manually. This is necessary because:
76+
- pythonImportsCheckHook adds the check to $preDistPhases
77+
- python3.withPackages is built with a version of `buildEnv`,
78+
... which is implemented by `runCommand`,
79+
... which has a custom builder and does not run $preDistPhases
80+
*/
81+
postBuild =
82+
postBuild
83+
+ ''
84+
runPhase pythonImportsCheckPhase
85+
'';
86+
}
87+
);
88+
89+
meta = {
6390
description = "Library for color text mode, widget based user interfaces";
6491
mainProgram = "whiptail";
6592
homepage = "https://pagure.io/newt";
6693
changelog = "https://pagure.io/newt/blob/master/f/CHANGES";
67-
license = licenses.lgpl2;
68-
platforms = platforms.unix;
69-
maintainers = [ ];
94+
license = lib.licenses.lgpl2;
95+
platforms = lib.platforms.unix;
96+
maintainers = with lib.maintainers; [ bryango ];
7097
};
7198
}

pkgs/top-level/all-packages.nix

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9721,8 +9721,6 @@ with pkgs;
97219721

97229722
nettle = import ../development/libraries/nettle { inherit callPackage fetchurl; };
97239723

9724-
newt = callPackage ../development/libraries/newt { python = python3; };
9725-
97269724
libnghttp2 = nghttp2.lib;
97279725

97289726
nghttp3 = callPackage ../development/libraries/nghttp3 { inherit (darwin.apple_sdk.frameworks) CoreServices; };

pkgs/top-level/python-packages.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15836,7 +15836,7 @@ self: super: with self; {
1583615836

1583715837
smtpdfix = callPackage ../development/python-modules/smtpdfix { };
1583815838

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

1584115841
snakebite = callPackage ../development/python-modules/snakebite { };
1584215842

0 commit comments

Comments
 (0)