From 67117cc6f7def604afa10224f174926299a02257 Mon Sep 17 00:00:00 2001 From: Bryan Lai Date: Thu, 27 Feb 2025 23:39:29 +0800 Subject: [PATCH 1/5] newt: move to by-name --- .../newt/default.nix => by-name/ne/newt/package.nix} | 6 +++--- pkgs/top-level/all-packages.nix | 2 -- pkgs/top-level/python-packages.nix | 2 +- 3 files changed, 4 insertions(+), 6 deletions(-) rename pkgs/{development/libraries/newt/default.nix => by-name/ne/newt/package.nix} (94%) diff --git a/pkgs/development/libraries/newt/default.nix b/pkgs/by-name/ne/newt/package.nix similarity index 94% rename from pkgs/development/libraries/newt/default.nix rename to pkgs/by-name/ne/newt/package.nix index 4e6f408acc33..401cb03e075d 100644 --- a/pkgs/development/libraries/newt/default.nix +++ b/pkgs/by-name/ne/newt/package.nix @@ -4,11 +4,11 @@ stdenv, slang, popt, - python, + python3, }: let - pythonIncludePath = "${lib.getDev python}/include/python"; + pythonIncludePath = "${lib.getDev python3}/include/python"; in stdenv.mkDerivation rec { pname = "newt"; @@ -32,7 +32,7 @@ stdenv.mkDerivation rec { ''; strictDeps = true; - nativeBuildInputs = [ python ]; + nativeBuildInputs = [ python3 ]; buildInputs = [ slang popt diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index e40fe12a25a6..bcb9f2470f64 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -9740,8 +9740,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 d42500f8352e..c7ea49b48ca0 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -16542,7 +16542,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 { }; From 0d0f72f601768bd0dbaafde55bba22dccc0abb11 Mon Sep 17 00:00:00 2001 From: Bryan Lai Date: Fri, 28 Feb 2025 11:30:17 +0800 Subject: [PATCH 2/5] newt: clean up & build w/ gettext for darwin See: https://github.com/Homebrew/homebrew-core/blob/e6f19bd09a4e2c339bdfff78163b60e042b33cc2/Formula/n/newt.rb#L28 Also, add myself to maintainers. --- pkgs/by-name/ne/newt/package.nix | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/pkgs/by-name/ne/newt/package.nix b/pkgs/by-name/ne/newt/package.nix index 401cb03e075d..b62cdf502b07 100644 --- a/pkgs/by-name/ne/newt/package.nix +++ b/pkgs/by-name/ne/newt/package.nix @@ -5,6 +5,7 @@ slang, popt, python3, + gettext, }: let @@ -33,10 +34,14 @@ stdenv.mkDerivation rec { strictDeps = true; nativeBuildInputs = [ python3 ]; - buildInputs = [ - slang - popt - ]; + buildInputs = + [ + slang + popt + ] + ++ lib.optionals stdenv.hostPlatform.isDarwin [ + gettext # for darwin with clang + ]; NIX_LDFLAGS = "-lncurses"; @@ -46,10 +51,6 @@ 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}" ]; @@ -59,13 +60,13 @@ stdenv.mkDerivation rec { install_name_tool -change libnewt.so.${version} $out/lib/libnewt.so.${version} $out/bin/whiptail ''; - meta = with lib; { + 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 ]; }; } From 80860b906af62d7b9b12ba29b0e4f337ddf200be Mon Sep 17 00:00:00 2001 From: Bryan Lai Date: Fri, 28 Feb 2025 12:01:46 +0800 Subject: [PATCH 3/5] newt, python3Packages.snack: fix darwin linking --- pkgs/by-name/ne/newt/package.nix | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkgs/by-name/ne/newt/package.nix b/pkgs/by-name/ne/newt/package.nix index b62cdf502b07..d70c31e27f8c 100644 --- a/pkgs/by-name/ne/newt/package.nix +++ b/pkgs/by-name/ne/newt/package.nix @@ -43,7 +43,9 @@ stdenv.mkDerivation rec { 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 From 0e7ffca8e7c27289fef62989b192bf31dc8e43e5 Mon Sep 17 00:00:00 2001 From: Bryan Lai Date: Fri, 28 Feb 2025 14:23:59 +0800 Subject: [PATCH 4/5] newt, python3Packages.snack: add passthru.tests --- pkgs/by-name/ne/newt/package.nix | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/pkgs/by-name/ne/newt/package.nix b/pkgs/by-name/ne/newt/package.nix index d70c31e27f8c..4d7fd3fa2a1d 100644 --- a/pkgs/by-name/ne/newt/package.nix +++ b/pkgs/by-name/ne/newt/package.nix @@ -62,6 +62,26 @@ stdenv.mkDerivation rec { install_name_tool -change libnewt.so.${version} $out/lib/libnewt.so.${version} $out/bin/whiptail ''; + 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"; From cb1a729adc6c36af95d60ccdbf37a5beef5aa6a2 Mon Sep 17 00:00:00 2001 From: Bryan Lai Date: Fri, 28 Feb 2025 16:06:51 +0800 Subject: [PATCH 5/5] newt, python3Packages.snack: fix dylib name --- pkgs/by-name/ne/newt/package.nix | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkgs/by-name/ne/newt/package.nix b/pkgs/by-name/ne/newt/package.nix index 4d7fd3fa2a1d..94459d70d674 100644 --- a/pkgs/by-name/ne/newt/package.nix +++ b/pkgs/by-name/ne/newt/package.nix @@ -58,8 +58,12 @@ stdenv.mkDerivation rec { ]; 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 ''; passthru.tests.pythonModule = (python3.withPackages (ps: [ ps.snack ])).overrideAttrs (