nixpkgs/pkgs/development/libraries/newt/default.nix
Artturin e0464e4788 treewide: replace stdenv.is with stdenv.hostPlatform.is
In preparation for the deprecation of `stdenv.isX`.

These shorthands are not conducive to cross-compilation because they
hide the platforms.

Darwin might get cross-compilation for which the continued usage of `stdenv.isDarwin` will get in the way

One example of why this is bad and especially affects compiler packages
https://www.github.com/NixOS/nixpkgs/pull/343059

There are too many files to go through manually but a treewide should
get users thinking when they see a `hostPlatform.isX` in a place where it
doesn't make sense.

```
fd --type f "\.nix" | xargs sd --fixed-strings "stdenv.is" "stdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "stdenv'.is" "stdenv'.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "clangStdenv.is" "clangStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "gccStdenv.is" "gccStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "stdenvNoCC.is" "stdenvNoCC.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "inherit (stdenv) is" "inherit (stdenv.hostPlatform) is"
fd --type f "\.nix" | xargs sd --fixed-strings "buildStdenv.is" "buildStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "effectiveStdenv.is" "effectiveStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "originalStdenv.is" "originalStdenv.hostPlatform.is"
```
2024-09-25 00:04:37 +03:00

62 lines
1.8 KiB
Nix

{ lib, fetchurl, stdenv, slang, popt, python }:
let
pythonIncludePath = "${lib.getDev python}/include/python";
in
stdenv.mkDerivation rec {
pname = "newt";
version = "0.52.24";
src = fetchurl {
url = "https://releases.pagure.org/${pname}/${pname}-${version}.tar.gz";
sha256 = "sha256-Xe1+Ih+F9kJSHEmxgmyN4ZhFqjcrr11jClF3S1RPvbs=";
};
postPatch = ''
sed -i -e s,/usr/bin/install,install, -e s,-I/usr/include/slang,, Makefile.in po/Makefile
substituteInPlace configure \
--replace "/usr/include/python" "${pythonIncludePath}"
substituteInPlace configure.ac \
--replace "/usr/include/python" "${pythonIncludePath}"
substituteInPlace Makefile.in \
--replace "ar rv" "${stdenv.cc.targetPrefix}ar rv"
'';
strictDeps = true;
nativeBuildInputs = [ python ];
buildInputs = [ slang popt ];
NIX_LDFLAGS = "-lncurses";
preConfigure = ''
# If CPP is set explicitly, configure and make will not agree about which
# programs to use at different stages.
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 ''
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
'';
meta = with lib; {
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 = [ ];
};
}