miktex: init at 25.2

qbisi 3b5793de 6b8cf07d

+307
+20
pkgs/by-name/mi/miktex/find-exectables-in-path.patch
···
··· 1 + diff --git a/Libraries/MiKTeX/Core/Session/filetypes.cpp b/Libraries/MiKTeX/Core/Session/filetypes.cpp 2 + index 82e55382f..84ac206e9 100644 3 + --- a/Libraries/MiKTeX/Core/Session/filetypes.cpp 4 + +++ b/Libraries/MiKTeX/Core/Session/filetypes.cpp 5 + @@ -198,6 +198,15 @@ void SessionImpl::RegisterFileType(FileType fileType) 6 + searchPath.push_back(myPrefixBinCanon.ToString()); 7 + } 8 + #endif 9 + + if (Utils::GetEnvironmentString("PATH", str)) 10 + + { 11 + + PathName binDir(str); 12 + + binDir.Canonicalize(); 13 + + if (std::find(searchPath.begin(), searchPath.end(), binDir.ToString()) == searchPath.end()) 14 + + { 15 + + searchPath.push_back(binDir.ToString()); 16 + + } 17 + + } 18 + break; 19 + } 20 + case FileType::OTF:
+247
pkgs/by-name/mi/miktex/package.nix
···
··· 1 + { 2 + lib, 3 + stdenv, 4 + fetchFromGitHub, 5 + fetchurl, 6 + runCommand, 7 + writeText, 8 + biber, 9 + 10 + # nativeBuildInputs 11 + bison, 12 + cmake, 13 + curl, 14 + flex, 15 + fop, 16 + libxslt, 17 + pkg-config, 18 + writableTmpDirAsHomeHook, 19 + 20 + # buildInputs 21 + apr, 22 + aprutil, 23 + boost, 24 + bzip2, 25 + cairo, 26 + expat, 27 + fontconfig, 28 + freetype, 29 + fribidi, 30 + gd, 31 + gmp, 32 + graphite2, 33 + harfbuzzFull, 34 + hunspell, 35 + libjpeg, 36 + log4cxx, 37 + xz, 38 + mpfr, 39 + mpfi, 40 + libmspack, 41 + libressl, 42 + pixman, 43 + libpng, 44 + popt, 45 + uriparser, 46 + zziplib, 47 + qt6Packages, 48 + }: 49 + let 50 + # This is needed for some bootstrap packages. 51 + webArchivePrefix = "https://web.archive.org/web/20250323131915if_"; 52 + miktexRemoteRepository = "https://ctan.org/tex-archive/systems/win32/miktex/tm/packages"; 53 + miktexLocalRepository = 54 + runCommand "miktex-local-repository" 55 + { 56 + src1 = fetchurl { 57 + url = "${webArchivePrefix}/${miktexRemoteRepository}/miktex-zzdb1-2.9.tar.lzma"; 58 + hash = "sha256-XYhbKlxhVSOlCcm0IOs2ddFgAt/CWXJoY6IuLSw74y4="; 59 + }; 60 + src2 = fetchurl { 61 + url = "${webArchivePrefix}/${miktexRemoteRepository}/miktex-zzdb3-2.9.tar.lzma"; 62 + hash = "sha256-5vLuGwjddqtJ5F/DtVKuRVRqgGNbkGFxRF41cXwseIs="; 63 + }; 64 + src3 = fetchurl { 65 + url = "${webArchivePrefix}/${miktexRemoteRepository}/miktex-config-2.9.tar.lzma"; 66 + hash = "sha256-fkh5KL+BU+gl8Sih8xBLi1DOx2vMuSflXlSTchjlGWQ="; 67 + }; 68 + src4 = fetchurl { 69 + url = "${webArchivePrefix}/${miktexRemoteRepository}/miktex-dvips.tar.lzma"; 70 + hash = "sha256-eJQdLhYetNlXAyyiGD/JRDA3fv0BbALwXtNfRxkLM7o="; 71 + }; 72 + src5 = fetchurl { 73 + url = "${webArchivePrefix}/${miktexRemoteRepository}/miktex-fontconfig.tar.lzma"; 74 + hash = "sha256-dxH/0iIL3SnjCSXLGAcNTb5cGJb5AQmV/JbH5CcPHdk="; 75 + }; 76 + src6 = fetchurl { 77 + url = "${webArchivePrefix}/${miktexRemoteRepository}/miktex-misc.tar.lzma"; 78 + hash = "sha256-ysNREvnKWseqqN59cwNzlV21UmccbjSGFyno8lv2H+M="; 79 + }; 80 + src7 = fetchurl { 81 + url = "${webArchivePrefix}/${miktexRemoteRepository}/tetex.tar.lzma"; 82 + hash = "sha256-DE1o66r2SFxxxuYeCRuFn6L1uBn26IFnje9b/qeVl6Q="; 83 + }; 84 + } 85 + '' 86 + mkdir $out 87 + cp $src1 $out/miktex-zzdb1-2.9.tar.lzma 88 + cp $src2 $out/miktex-zzdb3-2.9.tar.lzma 89 + cp $src3 $out/miktex-config-2.9.tar.lzma 90 + cp $src4 $out/miktex-dvips.tar.lzma 91 + cp $src5 $out/miktex-fontconfig.tar.lzma 92 + cp $src6 $out/miktex-misc.tar.lzma 93 + cp $src7 $out/tetex.tar.lzma 94 + ''; 95 + in 96 + stdenv.mkDerivation (finalAttrs: { 97 + pname = "miktex"; 98 + version = "25.2"; 99 + 100 + src = fetchFromGitHub { 101 + owner = "miktex"; 102 + repo = "miktex"; 103 + tag = finalAttrs.version; 104 + hash = "sha256-egN9+BRO/EAcbrn/jZac4Lb79H5N/LEjReMPGHVM/yM="; 105 + }; 106 + 107 + patches = [ 108 + ./startup-config-support-nix-store.patch 109 + # Miktex will search exectables in "GetMyPrefix(true)/bin". 110 + # The path evalutate to "/usr/bin" in FHS style linux distrubution, 111 + # compared to "/nix/store/.../bin" in NixOS. 112 + # As a result, miktex will fail to find e.g. 'pkexec','ksudo','gksu' 113 + # under /run/wrappers/bin in NixOS. 114 + # We fix this by adding the PATH environment variable to exectables' search path. 115 + ./find-exectables-in-path.patch 116 + ]; 117 + 118 + postPatch = 119 + '' 120 + # dont symlink fontconfig to /etc/fonts/conf.d 121 + substituteInPlace Programs/MiKTeX/miktex/topics/fontmaps/commands/FontMapManager.cpp \ 122 + --replace-fail 'this->ctx->session->IsAdminMode()' 'false' 123 + 124 + substituteInPlace \ 125 + Libraries/MiKTeX/App/app.cpp \ 126 + Programs/Editors/TeXworks/miktex/miktex-texworks.cpp \ 127 + Programs/MiKTeX/Console/Qt/main.cpp \ 128 + Programs/MiKTeX/PackageManager/mpm/mpm.cpp \ 129 + Programs/MiKTeX/Yap/MFC/StdAfx.h \ 130 + Programs/MiKTeX/initexmf/initexmf.cpp \ 131 + Programs/MiKTeX/miktex/miktex.cpp \ 132 + --replace-fail "log4cxx/rollingfileappender.h" "log4cxx/rolling/rollingfileappender.h" 133 + 134 + substitute cmake/modules/FindPOPPLER_QT5.cmake \ 135 + cmake/modules/FindPOPPLER_QT6.cmake \ 136 + --replace-fail "QT5" "QT6" \ 137 + --replace-fail "qt5" "qt6" 138 + 139 + substituteInPlace Programs/TeXAndFriends/omega/otps/source/outocp.c \ 140 + --replace-fail 'fprintf(stderr, s);' 'fprintf(stderr, "%s", s);' 141 + '' 142 + # This patch fixes mismatch char types (signed int and unsigned int) on aarch64-linux platform. 143 + # Should not be applied to other platforms otherwise the build will fail. 144 + + lib.optionalString (stdenv.hostPlatform.isAarch64 && stdenv.hostPlatform.isLinux) '' 145 + sed -i 's/--using-namespace=MiKTeX::TeXAndFriends/& --chars-are-unsigned/g' \ 146 + Programs/TeXAndFriends/Knuth/web/CMakeLists.txt 147 + ''; 148 + 149 + strictDeps = true; 150 + 151 + nativeBuildInputs = [ 152 + bison 153 + cmake 154 + curl 155 + flex 156 + fop 157 + libxslt 158 + pkg-config 159 + writableTmpDirAsHomeHook 160 + qt6Packages.wrapQtAppsHook 161 + qt6Packages.qttools 162 + qt6Packages.qt5compat 163 + ]; 164 + 165 + buildInputs = [ 166 + apr 167 + aprutil 168 + boost 169 + bzip2 170 + cairo 171 + expat 172 + fontconfig 173 + freetype 174 + fribidi 175 + gd 176 + gmp 177 + graphite2 178 + harfbuzzFull 179 + hunspell 180 + libjpeg 181 + log4cxx 182 + xz 183 + mpfr 184 + mpfi 185 + libmspack 186 + libressl 187 + pixman 188 + libpng 189 + popt 190 + uriparser 191 + zziplib 192 + qt6Packages.poppler 193 + ]; 194 + 195 + cmakeFlags = [ 196 + (lib.cmakeBool "WITH_BOOTSTRAPPING" true) 197 + (lib.cmakeBool "USE_SYSTEM_POPPLER" true) 198 + (lib.cmakeBool "USE_SYSTEM_POPPLER_QT" true) 199 + (lib.cmakeBool "MIKTEX_SELF_CONTAINED" false) 200 + # Miktex infers install prefix by stripping CMAKE_INSTALL_BINDIR from the called program. 201 + # It should not be set to absolute path in default cmakeFlags, otherwise an infinite loop will happen. 202 + (lib.cmakeFeature "CMAKE_INSTALL_BINDIR" "bin") 203 + (lib.cmakeFeature "CMAKE_INSTALL_LIBEXECDIR" "libexec") 204 + (lib.cmakeFeature "MIKTEX_SYSTEM_LINK_TARGET_DIR" "${placeholder "out"}/bin") 205 + (lib.cmakeFeature "MIKTEX_USER_LINK_TARGET_DIR" "${placeholder "out"}/bin") 206 + ]; 207 + 208 + env = { 209 + LANG = "C.UTF-8"; 210 + MIKTEX_REPOSITORY = "file://${miktexLocalRepository}/"; 211 + }; 212 + 213 + enableParallelBuilding = false; 214 + 215 + enableParallelChecking = false; 216 + 217 + doCheck = true; 218 + 219 + # Todo: figure out the exact binary to be Qt wrapped. 220 + dontWrapQtApps = true; 221 + 222 + postFixup = 223 + '' 224 + wrapQtApp $out/bin/miktex-console 225 + wrapQtApp $out/bin/miktex-texworks 226 + $out/bin/miktexsetup finish --verbose 227 + '' 228 + # Biber binary is missing on ctan.org for aarch64-linux platform. 229 + + lib.optionalString (stdenv.hostPlatform.isAarch64 && stdenv.hostPlatform.isLinux) '' 230 + ln -sf ${biber}/bin/biber $out/bin/biber 231 + ''; 232 + 233 + meta = { 234 + description = "A modern TeX distribution"; 235 + homepage = "https://miktex.org"; 236 + platforms = lib.platforms.linux; 237 + license = with lib.licenses; [ 238 + lppl13c 239 + gpl2Plus 240 + gpl3Plus 241 + publicDomain 242 + ]; 243 + maintainers = with lib.maintainers; [ 244 + qbisi 245 + ]; 246 + }; 247 + })
+40
pkgs/by-name/mi/miktex/startup-config-support-nix-store.patch
···
··· 1 + diff --git a/Libraries/MiKTeX/Core/Session/unx/unxStartupConfig.cpp b/Libraries/MiKTeX/Core/Session/unx/unxStartupConfig.cpp 2 + index 1728e7af9..727c36d8c 100644 3 + --- a/Libraries/MiKTeX/Core/Session/unx/unxStartupConfig.cpp 4 + +++ b/Libraries/MiKTeX/Core/Session/unx/unxStartupConfig.cpp 5 + @@ -90,6 +90,10 @@ InternalStartupConfig SessionImpl::DefaultConfig(MiKTeXConfiguration config, Ver 6 + { 7 + pos = n - 2; 8 + } 9 + + else if (n > 3 && splittedPrefix[1] == "nix" && splittedPrefix[2] == "store") 10 + + { 11 + + pos = 1; 12 + + } 13 + if (pos < n) 14 + { 15 + PathName destdir; 16 + @@ -98,10 +102,10 @@ InternalStartupConfig SessionImpl::DefaultConfig(MiKTeXConfiguration config, Ver 17 + destdir /= splittedPrefix[i]; 18 + } 19 + MIKTEX_ASSERT(MIKTEX_SYSTEM_VAR_LIB_DIR[0] == '/'); 20 + - ret.commonConfigRoot = destdir / (MIKTEX_SYSTEM_VAR_LIB_DIR + 1) / MIKTEX_PREFIX "texmf"; 21 + + ret.commonConfigRoot = destdir / (MIKTEX_SYSTEM_VAR_LIB_DIR + 1) / MIKTEX_PREFIX "texmf" / "config"; 22 + MIKTEX_ASSERT(MIKTEX_SYSTEM_VAR_CACHE_DIR[0] == '/'); 23 + ret.commonDataRoot = destdir / (MIKTEX_SYSTEM_VAR_CACHE_DIR + 1) / MIKTEX_PREFIX "texmf"; 24 + - ret.commonInstallRoot = destdir / "usr" / "local" / MIKTEX_INSTALL_DIR; 25 + + ret.commonInstallRoot = destdir / (MIKTEX_SYSTEM_VAR_LIB_DIR + 1) / MIKTEX_PREFIX "texmf" / "install"; 26 + } 27 + #endif 28 + if (ret.commonConfigRoot.Empty()) 29 + @@ -124,9 +128,9 @@ InternalStartupConfig SessionImpl::DefaultConfig(MiKTeXConfiguration config, Ver 30 + 31 + PathName myLoc = GetMyLocation(true); 32 + #if defined(MIKTEX_MACOS_BUNDLE) 33 + - ret.isSharedSetup = Utils::IsParentDirectoryOf(PathName("/usr"), myLoc) || Utils::IsParentDirectoryOf(PathName("/Applications"), myLoc) ? TriState::True : TriState::False; 34 + + ret.isSharedSetup = Utils::IsParentDirectoryOf(PathName("/nix/store"), myLoc) || Utils::IsParentDirectoryOf(PathName("/usr"), myLoc) || Utils::IsParentDirectoryOf(PathName("/Applications"), myLoc) ? TriState::True : TriState::False; 35 + #else 36 + - ret.isSharedSetup = Utils::IsParentDirectoryOf(PathName("/usr"), myLoc) || Utils::IsParentDirectoryOf(PathName("/opt"), myLoc) ? TriState::True : TriState::False; 37 + + ret.isSharedSetup = Utils::IsParentDirectoryOf(PathName("/nix/store"), myLoc) || Utils::IsParentDirectoryOf(PathName("/usr"), myLoc) || Utils::IsParentDirectoryOf(PathName("/opt"), myLoc) ? TriState::True : TriState::False; 38 + #endif 39 + 40 + return ret;