2024-06-30 08:12:46 +00:00
|
|
|
{
|
|
|
|
lib,
|
|
|
|
stdenv,
|
|
|
|
fetchurl,
|
|
|
|
fixDarwinDylibNames,
|
|
|
|
which,
|
|
|
|
dieHook,
|
|
|
|
enableShared ? !stdenv.hostPlatform.isStatic,
|
|
|
|
enableStatic ? stdenv.hostPlatform.isStatic,
|
2024-05-02 00:46:19 +00:00
|
|
|
# for passthru.tests
|
|
|
|
# , nix
|
|
|
|
}:
|
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "lowdown";
|
|
|
|
version = "1.1.0";
|
|
|
|
|
2024-06-30 08:12:46 +00:00
|
|
|
outputs = [
|
|
|
|
"out"
|
|
|
|
"lib"
|
|
|
|
"dev"
|
|
|
|
"man"
|
|
|
|
];
|
2024-05-02 00:46:19 +00:00
|
|
|
|
|
|
|
src = fetchurl {
|
|
|
|
url = "https://kristaps.bsd.lv/lowdown/snapshots/lowdown-${version}.tar.gz";
|
|
|
|
hash = "sha512-EpAWTz7Zy+2qqJGgzLrt0tK7WEZ+hHbdyqzAmMiaqc6uNXscR88git6/UbTjvB9Yanvetvw9huSuyhcORCEIug==";
|
|
|
|
};
|
|
|
|
|
2024-06-30 08:12:46 +00:00
|
|
|
nativeBuildInputs = [
|
|
|
|
which
|
|
|
|
dieHook
|
|
|
|
] ++ lib.optionals stdenv.isDarwin [ fixDarwinDylibNames ];
|
2024-05-02 00:46:19 +00:00
|
|
|
|
|
|
|
preConfigure = lib.optionalString (stdenv.isDarwin && stdenv.isAarch64) ''
|
|
|
|
echo 'HAVE_SANDBOX_INIT=0' > configure.local
|
|
|
|
'';
|
|
|
|
|
|
|
|
configurePhase = ''
|
|
|
|
runHook preConfigure
|
|
|
|
./configure PREFIX=''${!outputDev} \
|
|
|
|
BINDIR=''${!outputBin}/bin \
|
|
|
|
LIBDIR=''${!outputLib}/lib \
|
|
|
|
MANDIR=''${!outputMan}/share/man
|
|
|
|
runHook postConfigure
|
|
|
|
'';
|
|
|
|
|
|
|
|
makeFlags = [
|
|
|
|
"bins" # prevents shared object from being built unnecessarily
|
|
|
|
];
|
|
|
|
|
2024-06-30 08:12:46 +00:00
|
|
|
installTargets =
|
|
|
|
[ "install" ]
|
|
|
|
++ lib.optionals enableShared [ "install_shared" ]
|
|
|
|
++ lib.optionals enableStatic [ "install_static" ];
|
2024-05-02 00:46:19 +00:00
|
|
|
|
|
|
|
postInstall =
|
|
|
|
let
|
|
|
|
soVersion = "1";
|
|
|
|
in
|
|
|
|
|
|
|
|
# Check that soVersion is up to date even if we are not on darwin
|
|
|
|
lib.optionalString (enableShared && !stdenv.isDarwin) ''
|
|
|
|
test -f $lib/lib/liblowdown.so.${soVersion} || \
|
|
|
|
die "postInstall: expected $lib/lib/liblowdown.so.${soVersion} is missing"
|
|
|
|
''
|
|
|
|
# Fix lib extension so that fixDarwinDylibNames detects it, see
|
|
|
|
# <https://github.com/kristapsdz/lowdown/issues/87#issuecomment-1532243650>.
|
|
|
|
+ lib.optionalString (enableShared && stdenv.isDarwin) ''
|
|
|
|
darwinDylib="$lib/lib/liblowdown.${soVersion}.dylib"
|
|
|
|
mv "$lib/lib/liblowdown.so.${soVersion}" "$darwinDylib"
|
|
|
|
|
|
|
|
# Make sure we are re-creating a symbolic link here
|
|
|
|
test -L "$lib/lib/liblowdown.so" || \
|
|
|
|
die "postInstall: expected $lib/lib/liblowdown.so to be a symlink"
|
|
|
|
ln -s "$darwinDylib" "$lib/lib/liblowdown.dylib"
|
|
|
|
rm "$lib/lib/liblowdown.so"
|
|
|
|
'';
|
|
|
|
|
|
|
|
doInstallCheck = true;
|
|
|
|
installCheckPhase = ''
|
|
|
|
runHook preInstallCheck
|
|
|
|
echo '# TEST' > test.md
|
|
|
|
$out/bin/lowdown test.md
|
|
|
|
runHook postInstallCheck
|
|
|
|
'';
|
|
|
|
|
|
|
|
doCheck = true;
|
|
|
|
checkTarget = "regress";
|
|
|
|
|
|
|
|
# passthru.tests = {
|
|
|
|
# # most important consumer in nixpkgs
|
|
|
|
# inherit nix;
|
|
|
|
# };
|
|
|
|
|
|
|
|
meta = with lib; {
|
|
|
|
homepage = "https://kristaps.bsd.lv/lowdown/";
|
|
|
|
description = "Simple markdown translator";
|
|
|
|
license = licenses.isc;
|
|
|
|
maintainers = [ maintainers.sternenseemann ];
|
|
|
|
platforms = platforms.unix;
|
|
|
|
};
|
|
|
|
}
|