diff --git a/pkgs/by-name/md/mdfried/package.nix b/pkgs/by-name/md/mdfried/package.nix index 276656a43e77..a20fd5ca2e8d 100644 --- a/pkgs/by-name/md/mdfried/package.nix +++ b/pkgs/by-name/md/mdfried/package.nix @@ -1,10 +1,18 @@ { lib, + stdenv, rustPlatform, fetchFromGitHub, pkg-config, chafa, + fontconfig, glib, + gnumake, + gperf, + libiconv, + python3, + unzip, + writeShellScriptBin, nix-update-script, }: @@ -21,15 +29,39 @@ rustPlatform.buildRustPackage (finalAttrs: { cargoHash = "sha256-jnByeBBL13DavExG2pVN7vNRr+UXGkxRY0a4MkwzRe0="; + buildFeatures = [ "pdf" ]; + + # Prevent updateAutotoolsGnuConfigScripts from modifying mupdf's vendored + # autotools files — doing so invalidates cargo's fingerprint for mupdf-sys + # and causes a rebuild that fails on read-only cargoArtifacts files. + updateAutotoolsGnuConfigScriptsPhase = "true"; + nativeBuildInputs = [ pkg-config + rustPlatform.bindgenHook # for mupdf-sys bindgen + gperf # for mupdf vendored Makefile + python3 # for mupdf vendored Makefile + unzip # for mupdf vendored docx_template build + # mupdf-sys cp_r copies files from the read-only Nix store, preserving + # mode 444. make then fails to regenerate headers. Wrap make to chmod first. + (writeShellScriptBin "make" '' + chmod -R u+w . 2>/dev/null || true + exec ${lib.getExe gnumake} "$@" + '') ]; buildInputs = [ chafa - glib + fontconfig.dev # for font-kit (mupdf dep) + glib.dev # for glib-2.0.pc (mupdf needs glib.dev, chafa could do with just glib) + ] + ++ lib.optionals stdenv.hostPlatform.isDarwin [ + libiconv ]; + CFLAGS_aarch64_apple_darwin = lib.optionalString stdenv.hostPlatform.isDarwin "-UTARGET_OS_MAC"; + CXXFLAGS_aarch64_apple_darwin = lib.optionalString stdenv.hostPlatform.isDarwin "-UTARGET_OS_MAC"; + doCheck = true; passthru.updateScript = nix-update-script { };