diff --git a/pkgs/development/libraries/newt/default.nix b/pkgs/by-name/ne/newt/package.nix similarity index 50% rename from pkgs/development/libraries/newt/default.nix rename to pkgs/by-name/ne/newt/package.nix index 4e6f408acc33..94459d70d674 100644 --- a/pkgs/development/libraries/newt/default.nix +++ b/pkgs/by-name/ne/newt/package.nix @@ -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 = [ - 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 @@ -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 ''; - 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 ]; }; } diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 77f5c28ecb2d..4092c8774107 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -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; }; diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index 7aaf06856b21..7eb1f2728748 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -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 { };