nixpkgs/pkgs/by-name/po/poke/package.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

92 lines
2.3 KiB
Nix

{ lib
, stdenv
, fetchurl
, help2man
, pkg-config
, texinfo
, boehmgc
, readline
, nbdSupport ? !stdenv.hostPlatform.isDarwin, libnbd
, textStylingSupport ? true, gettext
, dejagnu
# update script only
, writeScript
}:
let
isCross = stdenv.hostPlatform != stdenv.buildPlatform;
in
stdenv.mkDerivation (finalAttrs: {
pname = "poke";
version = "4.2";
src = fetchurl {
url = "mirror://gnu/poke/poke-${finalAttrs.version}.tar.gz";
hash = "sha256-iq825h42elMUDqQOJVnp7FEud5xCvuNOesJLNLoRm94=";
};
outputs = [ "out" "dev" "info" "lib" ]
# help2man can't cross compile because it runs `poke --help` to
# generate the man page
++ lib.optional (!isCross) "man";
postPatch = ''
patchShebangs .
'';
strictDeps = true;
nativeBuildInputs = [
pkg-config
texinfo
] ++ lib.optionals (!isCross) [
help2man
];
buildInputs = [ boehmgc readline ]
++ lib.optional nbdSupport libnbd
++ lib.optional textStylingSupport gettext
++ lib.optional finalAttrs.finalPackage.doCheck dejagnu;
configureFlags = [
# libpoke depends on $datadir/poke, so we specify the datadir in
# $lib, and later move anything else it doesn't depend on to $out
"--datadir=${placeholder "lib"}/share"
];
enableParallelBuilding = true;
doCheck = true;
nativeCheckInputs = [ dejagnu ];
postInstall = ''
moveToOutput share/emacs "$out"
moveToOutput share/vim "$out"
'';
passthru = {
updateScript = writeScript "update-poke" ''
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p curl pcre common-updater-scripts
set -eu -o pipefail
# Expect the text in format of '<a href="...">poke 2.0</a>'
new_version="$(curl -s https://www.jemarch.net/poke |
pcregrep -o1 '>poke ([0-9.]+)</a>')"
update-source-version poke "$new_version"
'';
};
meta = {
description = "Interactive, extensible editor for binary data";
homepage = "http://www.jemarch.net/poke";
changelog = "https://git.savannah.gnu.org/cgit/poke.git/plain/ChangeLog?h=releases/poke-${finalAttrs.version}";
license = lib.licenses.gpl3Plus;
maintainers = with lib.maintainers; [ AndersonTorres kira-bruneau ];
platforms = lib.platforms.unix;
broken = stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64;
};
})