nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at devShellTools-shell 95 lines 2.9 kB view raw
1{ 2 lib, 3 fetchurl, 4 stdenv, 5 slang, 6 popt, 7 python3, 8 gettext, 9}: 10 11let 12 pythonIncludePath = "${lib.getDev python3}/include/python"; 13in 14stdenv.mkDerivation rec { 15 pname = "newt"; 16 version = "0.52.24"; 17 18 src = fetchurl { 19 url = "https://releases.pagure.org/${pname}/${pname}-${version}.tar.gz"; 20 sha256 = "sha256-Xe1+Ih+F9kJSHEmxgmyN4ZhFqjcrr11jClF3S1RPvbs="; 21 }; 22 23 postPatch = '' 24 sed -i -e s,/usr/bin/install,install, -e s,-I/usr/include/slang,, Makefile.in po/Makefile 25 26 substituteInPlace configure \ 27 --replace "/usr/include/python" "${pythonIncludePath}" 28 substituteInPlace configure.ac \ 29 --replace "/usr/include/python" "${pythonIncludePath}" 30 31 substituteInPlace Makefile.in \ 32 --replace "ar rv" "${stdenv.cc.targetPrefix}ar rv" 33 ''; 34 35 strictDeps = true; 36 nativeBuildInputs = [ python3 ]; 37 buildInputs = [ 38 slang 39 popt 40 ] 41 ++ lib.optionals stdenv.hostPlatform.isDarwin [ 42 gettext # for darwin with clang 43 ]; 44 45 NIX_LDFLAGS = 46 "-lncurses" 47 + lib.optionalString stdenv.hostPlatform.isDarwin " -L${python3}/lib -lpython${python3.pythonVersion}"; 48 49 preConfigure = '' 50 # If CPP is set explicitly, configure and make will not agree about which 51 # programs to use at different stages. 52 unset CPP 53 ''; 54 55 makeFlags = lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [ 56 "CROSS_COMPILE=${stdenv.cc.targetPrefix}" 57 ]; 58 59 postFixup = lib.optionalString stdenv.hostPlatform.isDarwin '' 60 set -xe 61 install_name_tool -id $out/lib/libnewt.so.${version} $out/lib/libnewt.so.${version} 62 install_name_tool -change libnewt.so.${version} $out/lib/libnewt.so.${version} $out/bin/whiptail 63 install_name_tool -change libnewt.so.${version} $out/lib/libnewt.so.${version} \ 64 $out/lib/python*/site-packages/_snack* # glob for version & suffix 65 set +x 66 ''; 67 68 passthru.tests.pythonModule = (python3.withPackages (ps: [ ps.snack ])).overrideAttrs ( 69 { nativeBuildInputs, postBuild, ... }@_prevAttrs: 70 { 71 nativeBuildInputs = nativeBuildInputs ++ [ python3.pkgs.pythonImportsCheckHook ]; 72 pythonImportsCheck = [ "snack" ]; 73 /** 74 Call pythonImportsCheckPhase manually. This is necessary because: 75 - pythonImportsCheckHook adds the check to $preDistPhases 76 - python3.withPackages is built with a version of `buildEnv`, 77 ... which is implemented by `runCommand`, 78 ... which has a custom builder and does not run $preDistPhases 79 */ 80 postBuild = postBuild + '' 81 runPhase pythonImportsCheckPhase 82 ''; 83 } 84 ); 85 86 meta = { 87 description = "Library for color text mode, widget based user interfaces"; 88 mainProgram = "whiptail"; 89 homepage = "https://pagure.io/newt"; 90 changelog = "https://pagure.io/newt/blob/master/f/CHANGES"; 91 license = lib.licenses.lgpl2; 92 platforms = lib.platforms.unix; 93 maintainers = with lib.maintainers; [ bryango ]; 94 }; 95}