44 stdenv ,
55 slang ,
66 popt ,
7- python ,
7+ python3 ,
8+ gettext ,
89} :
910
1011let
11- pythonIncludePath = "${ lib . getDev python } /include/python" ;
12+ pythonIncludePath = "${ lib . getDev python3 } /include/python" ;
1213in
1314stdenv . 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}
0 commit comments