1 { lib, stdenv, fetchurl, fixDarwinDylibNames, which, dieHook
2 , enableShared ? !stdenv.hostPlatform.isStatic
3 , enableStatic ? stdenv.hostPlatform.isStatic
4 , enableDarwinSandbox ? true
9 stdenv.mkDerivation rec {
10 pname = "lowdown${lib.optionalString (stdenv.hostPlatform.isDarwin && !enableDarwinSandbox) "-unsandboxed"}";
13 outputs = [ "out" "lib" "dev" "man" ];
16 url = "https://kristaps.bsd.lv/lowdown/snapshots/lowdown-${version}.tar.gz";
17 hash = "sha512-D50eoU95ref2Q6jfRCktgiL8j7143Kuv3RxUWbzBZl9aWjyh0nKnjgl709dMM/YQwCl9PDnmYHhYH6J3ULsnXg==";
20 nativeBuildInputs = [ which dieHook ]
21 ++ lib.optionals stdenv.hostPlatform.isDarwin [ fixDarwinDylibNames ];
23 # The Darwin sandbox calls fail inside Nix builds, presumably due to
24 # being nested inside another sandbox.
25 preConfigure = lib.optionalString (stdenv.hostPlatform.isDarwin && !enableDarwinSandbox) ''
26 echo 'HAVE_SANDBOX_INIT=0' > configure.local
31 ./configure PREFIX=''${!outputDev} \
32 BINDIR=''${!outputBin}/bin \
33 LIBDIR=''${!outputLib}/lib \
34 MANDIR=''${!outputMan}/share/man
38 # Fix rpath change on darwin to avoid failure like:
39 # error: install_name_tool: changing install names or
40 # rpaths can't be redone for: liblowdown.1.dylib (for architecture
41 # arm64) because larger
42 # https://github.com/NixOS/nixpkgs/pull/344532#issuecomment-238475791
43 env.NIX_CFLAGS_LINK = lib.optionalString stdenv.hostPlatform.isDarwin "-headerpad_max_install_names";
46 "bins" # prevents shared object from being built unnecessarily
51 ] ++ lib.optionals enableShared [
53 ] ++ lib.optionals enableStatic [
62 # Check that soVersion is up to date even if we are not on darwin
63 lib.optionalString (enableShared && !stdenv.hostPlatform.isDarwin) ''
64 test -f $lib/lib/liblowdown.so.${soVersion} || \
65 die "postInstall: expected $lib/lib/liblowdown.so.${soVersion} is missing"
67 # Fix lib extension so that fixDarwinDylibNames detects it, see
68 # <https://github.com/kristapsdz/lowdown/issues/87#issuecomment-1532243650>.
69 + lib.optionalString (enableShared && stdenv.hostPlatform.isDarwin) ''
70 darwinDylib="$lib/lib/liblowdown.${soVersion}.dylib"
71 mv "$lib/lib/liblowdown.so.${soVersion}" "$darwinDylib"
73 # Make sure we are re-creating a symbolic link here
74 test -L "$lib/lib/liblowdown.so" || \
75 die "postInstall: expected $lib/lib/liblowdown.so to be a symlink"
76 ln -s "$darwinDylib" "$lib/lib/liblowdown.dylib"
77 rm "$lib/lib/liblowdown.so"
80 doInstallCheck = true;
82 installCheckPhase = lib.optionalString (!stdenv.hostPlatform.isDarwin || !enableDarwinSandbox) ''
83 runHook preInstallCheck
85 echo '# TEST' > test.md
86 $out/bin/lowdown test.md
88 runHook postInstallCheck
92 checkTarget = "regress";
95 # most important consumer in nixpkgs
100 homepage = "https://kristaps.bsd.lv/lowdown/";
101 description = "Simple markdown translator";
102 license = licenses.isc;
103 maintainers = [ maintainers.sternenseemann ];
104 platforms = platforms.unix;