Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Packaging request: MikTeX #167847

Closed
linsui opened this issue Apr 8, 2022 · 1 comment
Closed

Packaging request: MikTeX #167847

linsui opened this issue Apr 8, 2022 · 1 comment
Labels
0.kind: packaging request Request for a new package to be added 6.topic: TeX Issues regarding texlive and TeX in general

Comments

@linsui
Copy link
Contributor

linsui commented Apr 8, 2022

Project description
MiKTeX is a modern C/C++ implementation of TeX & Friends for Windows, macOS and Linux.

I partly build it. But the binaries doesn't work for me.

{ lib
, stdenv
, fetchFromGitHub
, wrapQtAppsHook
, bison
, cmake
, flex
, fop
, git
, gnused
, libxslt
, pkg-config
, qttools
, apr
, aprutil
, boost
, bzip2
, cairo
, expat
, fontconfig
, freetype
, fribidi
, gd
, gmp
, graphite2
, harfbuzzFull
, hunspell
, icu
, libjpeg
, log4cxx
, lzma
, mpfr
, libmspack
, libressl
, pixman
, libpng
, poppler
, popt
, potrace
, qtdeclarative
, qtscript
, uriparser
, zziplib
, libsForQt5
}:

stdenv.mkDerivation rec {
  pname = "miktex";
  version = "22.3";

  src = fetchFromGitHub {
    owner = pname;
    repo = pname;
    rev = version;
    sha256 = "sha256-IvXlFEM7fp0EYSmQmt1KKAAMQM4bTZL0vPfdFpXJKhQ=";
  };

  postPatch = ''
    substituteInPlace Programs/TeXAndFriends/omega/otps/source/outocp.c \
      --replace 'fprintf(stderr, s);' 'fprintf(stderr, "%s", s);'
  '';

  nativeBuildInputs = [
    wrapQtAppsHook
    bison
    cmake
    flex
    fop
    git
    gnused
    libxslt
    pkg-config
    qttools
  ];

  buildInputs = [
    apr
    aprutil
    boost
    bzip2
    cairo
    expat
    fontconfig
    freetype
    fribidi
    gd
    gmp
    graphite2
    harfbuzzFull
    hunspell
    icu
    libjpeg
    log4cxx
    lzma
    mpfr
    libmspack
    libressl
    pixman
    libpng
    poppler
    popt
    potrace
    qtdeclarative
    qtscript
    uriparser
    zziplib
    libsForQt5.poppler
  ];

  cmakeFlags = [
    "-DWITH_BOOTSTRAPPING=FALSE"
    "-DUSE_SYSTEM_POPPLER=TRUE"
    "-DUSE_SYSTEM_POPPLER_QT5=TRUE"
    "-DWITH_MAN_PAGES=FALSE"
  ];

  preBuild = ''
    export HOME=$TMPDIR
    export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$(pwd)/sandbox/miktex/bin/linux-x86_64
  '';

  meta = with lib; {
    description = "A modern TeX distribution";
    homepage = "https://miktex.org";
    platforms = platforms.unix;
    license = licenses.bsd3;
  };
}

I had to disable the man pages however it builds fine with pure nix-shell.

@linsui linsui added the 0.kind: packaging request Request for a new package to be added label Apr 8, 2022
@veprbl veprbl added the 6.topic: TeX Issues regarding texlive and TeX in general label Apr 8, 2022
@qbisi
Copy link
Contributor

qbisi commented Mar 19, 2025

update 2025.03.19

{
  lib,
  stdenv,
  fetchFromGitHub,
  bison,
  cmake,
  flex,
  fop,
  libxslt,
  pkg-config,
  boost,

  # buildInputs
  apr,
  aprutil,
  bzip2,
  cairo,
  expat,
  fontconfig,
  freetype,
  fribidi,
  gd,
  gmp,
  graphite2,
  harfbuzzFull,
  hunspell,
  libjpeg,
  log4cxx,
  xz,
  mpfr,
  mpfi,
  libmspack,
  libressl,
  pixman,
  libpng,
  poppler,
  popt,
  uriparser,
  zziplib,
  kdePackages,
}:

stdenv.mkDerivation (finalAttrs: {
  pname = "miktex";
  version = "25.2";

  src = fetchFromGitHub {
    owner = "miktex";
    repo = "miktex";
    tag = finalAttrs.version;
    hash = "sha256-egN9+BRO/EAcbrn/jZac4Lb79H5N/LEjReMPGHVM/yM=";
  };

  patches = lib.optionals (stdenv.hostPlatform.isAarch64 && stdenv.hostPlatform.isLinux) [
    ./unsigned-char.patch
  ];

  postPatch = ''
    find . -type f \( -name "*.h" -o -name "*.c" \) -exec \
      sed -i 's|log4cxx/rollingfileappender.h|log4cxx/rolling/rollingfileappender.h|g' {} +

    substitute cmake/modules/FindPOPPLER_QT5.cmake \
      cmake/modules/FindPOPPLER_QT6.cmake \
      --replace-fail "QT5" "QT6" \
      --replace-fail "qt5" "qt6"

    substituteInPlace Programs/TeXAndFriends/omega/otps/source/outocp.c \
      --replace 'fprintf(stderr, s);' 'fprintf(stderr, "%s", s);'
  '';

  nativeBuildInputs = [
    bison
    cmake
    flex
    fop
    libxslt
    pkg-config
    kdePackages.wrapQtAppsHook
    kdePackages.qttools
    kdePackages.qt5compat
    boost
  ];

  buildInputs = [
    apr
    aprutil
    bzip2
    cairo
    expat
    fontconfig
    freetype
    fribidi
    gd
    gmp
    graphite2
    harfbuzzFull
    hunspell
    libjpeg
    log4cxx
    xz
    mpfr
    mpfi
    libmspack
    libressl
    pixman
    libpng
    popt
    uriparser
    zziplib
    kdePackages.poppler
  ];

  cmakeFlags = [
    (lib.cmakeFeature "MIKTEX_RELEASE_STATE" "0")
    (lib.cmakeBool "WITH_BOOTSTRAPPING" false)
    (lib.cmakeBool "USE_SYSTEM_POPPLER" true)
    (lib.cmakeBool "USE_SYSTEM_POPPLER_QT" true)
  ];

  preBuild =
    let
      system = "${stdenv.hostPlatform.parsed.kernel.name}-${stdenv.hostPlatform.parsed.cpu.name}";
    in
    ''
      export HOME=$(mktemp -d)
      export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$(pwd)/sandbox/miktex/bin/${system}
    '';

  # doCheck = true;

  # dontWrapQtApps = true;

  meta = with lib; {
    description = "A modern TeX distribution";
    homepage = "https://miktex.org";
    platforms = platforms.lunix;
    license = licenses.gpl2Plus;
  };
})

This recipe can build miktex on x86_64-linux and aarch64-linux platform.
However the generated main program miktex-console miktexsetup stuck at some point and does not showup a UI.

@qbisi qbisi closed this as completed Mar 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: packaging request Request for a new package to be added 6.topic: TeX Issues regarding texlive and TeX in general
Projects
None yet
Development

No branches or pull requests

3 participants