diff --git a/pkgs/applications/editors/vim/macvim-xcode26.patch b/pkgs/applications/editors/vim/macvim-xcode26.patch new file mode 100644 index 000000000000..4850475b3df0 --- /dev/null +++ b/pkgs/applications/editors/vim/macvim-xcode26.patch @@ -0,0 +1,13 @@ +diff --git a/src/MacVim/MacVim.xcodeproj/project.pbxproj b/src/MacVim/MacVim.xcodeproj/project.pbxproj +index 7481870..6355242 100644 +--- a/src/MacVim/MacVim.xcodeproj/project.pbxproj ++++ b/src/MacVim/MacVim.xcodeproj/project.pbxproj +@@ -1191,7 +1191,7 @@ + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/zsh; +- shellScript = "# Copy the runtime files to the app bundle, under Resources/vim/runtime folder.\n# We cannot do a direct copy of the runtime folder as it contains misc test\n# scripts and also man pages and we should use the Vim's defined rules to\n# install them properly.\n\n# Note that this will also install man pages, under a \"man\" folder. This is\n# useful if the user really wants to point their man page to MacVim's verison\n# instead of builtin Vim, using MANPATH=/Applications/MacVim.app/Contents/man).\n\n# prefix: Reset to empty as it's set to /Applications for fallback rt-folder\n# VIMNAME: Use the default \"vim\" to make sure man pages use that instead of \"Vim\"\n# VIMRTDIR: Make sure to use \"runtime\" as by default it uses a \"vim90\" style folder which is mostly a relic.\n\ncd \"${SRCROOT}\"/..\nmake \\\n DESTDIR=\"${TARGET_BUILD_DIR}\" \\\n prefix= \\\n VIMNAME=vim \\\n VIMRTDIR=/runtime \\\n macvim-install-runtime\n\n# Also add man pages for \"mvim\"\nfor curdir in \"$BUILT_PRODUCTS_DIR/$CONTENTS_FOLDER_PATH\"/man/**/man1; do\n (cd $curdir; ln -f -s gvim.1 mvim.1)\ndone\n"; ++ shellScript = "# Copy the runtime files to the app bundle, under Resources/vim/runtime folder.\n# We cannot do a direct copy of the runtime folder as it contains misc test\n# scripts and also man pages and we should use the Vim's defined rules to\n# install them properly.\n\n# Note that this will also install man pages, under a \"man\" folder. This is\n# useful if the user really wants to point their man page to MacVim's verison\n# instead of builtin Vim, using MANPATH=/Applications/MacVim.app/Contents/man).\n\n# prefix: Reset to empty as it's set to /Applications for fallback rt-folder\n# VIMNAME: Use the default \"vim\" to make sure man pages use that instead of \"Vim\"\n# VIMRTDIR: Make sure to use \"runtime\" as by default it uses a \"vim90\" style folder which is mostly a relic.\n\nset -e\n\ncd \"${SRCROOT}\"/..\nfor x in ${(k)parameters}; do if [[ $x = *_DEPLOYMENT_TARGET ]]; then [[ $x = MACOSX_DEPLOYMENT_TARGET ]] || unset $x; fi; done\nmake --jobs=1 \\\n DESTDIR=\"${TARGET_BUILD_DIR}\" \\\n prefix= \\\n VIMNAME=vim \\\n VIMRTDIR=/runtime \\\n macvim-install-runtime\n\n# Also add man pages for \"mvim\"\nfor curdir in \"$BUILT_PRODUCTS_DIR/$CONTENTS_FOLDER_PATH\"/man/**/man1; do\n (cd $curdir; ln -f -s gvim.1 mvim.1)\ndone\n"; + showEnvVarsInLog = 0; + }; + 90C052E1251E889500E2D81E /* Copy vimtutor */ = { diff --git a/pkgs/applications/editors/vim/macvim.nix b/pkgs/applications/editors/vim/macvim.nix index 943fd5b3b29e..19266316fd84 100644 --- a/pkgs/applications/editors/vim/macvim.nix +++ b/pkgs/applications/editors/vim/macvim.nix @@ -2,7 +2,7 @@ lib, stdenv, fetchFromGitHub, - runCommand, + apple-sdk_14, ncurses, gettext, pkg-config, @@ -11,52 +11,45 @@ tcl, perl, luajit, - darwin, - libiconv, python3, - enablePython ? false, - rcodesign, + # Setting withXcodePath makes it use that instead of the system-default Xcode. + # This can be set to one of the `darwin.xcode_*` packages as well. + # If set, this should be a path to Xcode.app, e.g. `"/Applications/Xcode.app"`. + withXcodePath ? null, }: -let - inherit (lib) optional optionals optionalString; -in - # Try to match MacVim's documented script interface compatibility let # Ruby 3.4 ruby = ruby_3_4; - - # Building requires a few system tools to be in PATH. - # Some of these we could patch into the relevant source files (such as xcodebuild and - # qlmanage) but some are used by Xcode itself and we have no choice but to put them in PATH. - # Symlinking them in this way is better than just putting all of /usr/bin in there. - buildSymlinks = runCommand "macvim-build-symlinks" { } '' - mkdir -p $out/bin - ln -s /usr/bin/xcrun /usr/bin/xcodebuild /usr/bin/tiffutil /usr/bin/qlmanage $out/bin - ''; in stdenv.mkDerivation (finalAttrs: { pname = "macvim"; - version = "181"; + version = "182"; src = fetchFromGitHub { owner = "macvim-dev"; repo = "macvim"; - rev = "release-${finalAttrs.version}"; - hash = "sha256-Wdq+eXSaGs+y+75ZbxoNAcyopRkWRHHRm05T0SHBrow="; + tag = + let + releaseType = if lib.hasInfix "." finalAttrs.version then "prerelease" else "release"; + in + "${releaseType}-${finalAttrs.version}"; + hash = "sha256-JEb71wZcvFsz94vb3+gC83BhlEccjlPrpr9RCXDUEIo="; }; enableParallelBuilding = true; nativeBuildInputs = [ pkg-config - buildSymlinks - ] - ++ optional stdenv.isAarch64 rcodesign; + ]; buildInputs = [ + # MacVim references up to MAC_OS_VERSION_14_0 in its source + # Update this SDK if it adds APIs that use newer versions + # (check both MAC_OS_VERSION_* and MAC_OS_X_VERSION_*) + apple-sdk_14 gettext ncurses cscope @@ -64,10 +57,51 @@ stdenv.mkDerivation (finalAttrs: { ruby tcl perl - ] - ++ optional enablePython python3; + python3 + ]; - patches = [ ./macvim.patch ]; + patches = [ + ./macvim.patch + # Xcode 26.0 sets *_DEPLOYMENT_TARGET env vars for all platforms in shell script build phases. + # This breaks invocations of clang in those phases, as they target the wrong platform. + # Note: The shell script build phase in question uses /bin/zsh. + # This also adds --jobs=1 to the shell script build phase invocation of `make` as running in + # parallel is causing the gvim.1 manpage to go missing. + ./macvim-xcode26.patch + ]; + + # Fix clang version detection in configure script, it's getting tripped up + # because the InstalledDir matches the same pattern + postPatch = '' + substituteInPlace src/auto/configure \ + --replace-fail /usr/bin/grep grep \ + --replace-fail '$CC --version 2>/dev/null |' '$CC --version 2>/dev/null | head -1 |' + '' + # Remove $(VIMTARGET) from the installrtbase rule deps. MacVim already comments out the usage of + # this executable in this rule, and for some reason Xcode is deleting it after copying it into + # MacVim.app/Contents/MacOS/, so this is getting rebuilt unnecessarily and causing issues. + + '' + substituteInPlace src/Makefile \ + --replace-fail \ + 'installrtbase: $(HELPSOURCE)/vim.1 $(DEST_VIM) $(VIMTARGET) $(DEST_RT)' \ + 'installrtbase: $(HELPSOURCE)/vim.1 $(DEST_VIM) $(DEST_RT)' + '' + # Patch in the xcode path we want + + '' + xcodebuildPath=${ + if withXcodePath == null then + "$(DEVELOPER_DIR= /usr/bin/xcrun -find xcodebuild)" + else + lib.escapeShellArg "${withXcodePath}/Contents/Developer/usr/bin/xcodebuild" + } + substituteInPlace src/Makefile \ + --replace-fail xcodebuild "$xcodebuildPath" + '' + # QuickLookStephen calls `qlmanage -r` in a shell script phase + + '' + substituteInPlace src/MacVim/qlstephen/QuickLookStephen.xcodeproj/project.pbxproj \ + --replace-fail qlmanage /usr/bin/qlmanage + ''; configureFlags = [ "--enable-cscope" @@ -76,23 +110,15 @@ stdenv.mkDerivation (finalAttrs: { "--enable-gui=macvim" "--enable-multibyte" "--enable-nls" - "--enable-luainterp=dynamic" - ] - ++ optionals enablePython [ - "--enable-python3interp=dynamic" - ] - ++ [ - "--enable-perlinterp=dynamic" - "--enable-rubyinterp=dynamic" + "--enable-luainterp=yes" + "--enable-python3interp=yes" + "--enable-perlinterp=yes" + "--enable-rubyinterp=yes" "--enable-tclinterp=yes" "--without-local-dir" "--with-luajit" "--with-lua-prefix=${luajit}" - ] - ++ optionals enablePython [ "--with-python3-command=${python3}/bin/python3" - ] - ++ [ "--with-ruby-command=${ruby}/bin/ruby" "--with-tclsh=${tcl}/bin/tclsh" "--with-tlib=ncurses" @@ -100,90 +126,34 @@ stdenv.mkDerivation (finalAttrs: { "--disable-sparkle" ]; - # Remove references to Sparkle.framework from the project. - # It's unused (we disabled it with --disable-sparkle) and this avoids - # copying the unnecessary several-megabyte framework into the result. - postPatch = '' - echo "Patching file src/MacVim/MacVim.xcodeproj/project.pbxproj" - sed -e '/Sparkle\.framework/d' -i src/MacVim/MacVim.xcodeproj/project.pbxproj + preConfigure = '' + configureFlagsArray+=( + --with-developer-dir="$DEVELOPER_DIR" + CFLAGS="-Wno-error=implicit-function-declaration" + ) '' - # Xcode 26.0 sets *_DEPLOYMENT_TARGET env vars for all platforms in shell script build phases. - # This breaks invocations of clang in those phases, as they target the wrong platform. - # Note: The shell script build phase in question uses /bin/zsh. + # Having `$LD` set causes Xcode to invoke `ld` instead of `clang` as the linker, but it still + # passes flags intended for clang. + '' - substituteInPlace src/MacVim/MacVim.xcodeproj/project.pbxproj \ - --replace-fail 'make \' $'for x in ''${(k)parameters}; do if [[ $x = *_DEPLOYMENT_TARGET ]]; then [[ $x = MACOSX_DEPLOYMENT_TARGET ]] || unset $x; fi; done\nmake \\' + unset LD + '' + # When building with nix-daemon, we need to pass -derivedDataPath or else it tries to use + # a folder rooted in /var/empty and fails. Unfortunately we can't just pass -derivedDataPath + # by itself as this flag requires the use of -scheme or -xctestrun (not sure why), but MacVim + # by default just runs `xcodebuild -project src/MacVim/MacVim.xcodeproj`, relying on the default + # behavior to build the first target in the project. Experimentally, there seems to be a scheme + # called MacVim, so we'll explicitly select that. We also need to specify the configuration too + # as the scheme seems to have the wrong default. + # Passing ENABLE_CODE_COVERAGE=NO because it's defaulting on for some reason. + # Passing ONLY_ACTIVE_ARCH=YES because QuickLookStephen.xcodeproj is building Universal by default. + + '' + configureFlagsArray+=( + XCODEFLAGS="-scheme MacVim -derivedDataPath $NIX_BUILD_TOP/derivedData ENABLE_CODE_COVERAGE=NO ONLY_ACTIVE_ARCH=YES" + --with-xcodecfg="Release" + ) ''; - # This is unfortunate, but we need to use the same compiler as Xcode, but Xcode doesn't provide a - # way to configure the compiler. We also need to pull in lib/include paths for some of our build - # inputs since we don't have cc-wrapper to do that for us. - preConfigure = - let - # ideally we'd recurse, but we don't need that right now - inputs = [ ncurses ] ++ perl.propagatedBuildInputs; - ldflags = map (drv: "-L${lib.getLib drv}/lib") inputs ++ [ "-headerpad_max_install_names" ]; - cppflags = map (drv: "-isystem ${lib.getDev drv}/include") inputs; - in - '' - unset DEVELOPER_DIR # Use the system Xcode not the nixpkgs SDK. - - CC=/usr/bin/clang - - DEV_DIR=$(/usr/bin/xcode-select -print-path)/Platforms/MacOSX.platform/Developer - configureFlagsArray+=( - --with-developer-dir="$DEV_DIR" - LDFLAGS=${lib.escapeShellArg ldflags} - CPPFLAGS=${lib.escapeShellArg cppflags} - CFLAGS="-Wno-error=implicit-function-declaration" - ) - '' - # For some reason having LD defined causes PSMTabBarControl to fail at link-time as it - # passes arguments to ld that it meant for clang. - + '' - unset LD - '' - # When building with nix-daemon, we need to pass -derivedDataPath or else it tries to use - # a folder rooted in /var/empty and fails. Unfortunately we can't just pass -derivedDataPath - # by itself as this flag requires the use of -scheme or -xctestrun (not sure why), but MacVim - # by default just runs `xcodebuild -project src/MacVim/MacVim.xcodeproj`, relying on the default - # behavior to build the first target in the project. Experimentally, there seems to be a scheme - # called MacVim, so we'll explicitly select that. We also need to specify the configuration too - # as the scheme seems to have the wrong default. - + '' - configureFlagsArray+=( - XCODEFLAGS="-scheme MacVim -derivedDataPath $NIX_BUILD_TOP/derivedData LDFLAGS='\$(inherited) -headerpad_max_install_names' ENABLE_CODE_COVERAGE=NO" - --with-xcodecfg="Release" - ) - ''; - - # Because we're building with system clang, this means we're building against Xcode's SDK and - # linking against system libraries. The configure script is picking up Nix Libsystem (via ruby) - # so we need to patch that out or we'll get linker issues. The MacVim binary built by Xcode links - # against the system anyway so it doesn't really matter that the Vim binary will too. If we - # decide that matters, we can always patch it back to the Nix libsystem post-build. - # It also picks up libiconv, libunwind, and objc4 from Nix. These seem relatively harmless but - # let's strip them out too. - # - # Note: If we do add a post-build install_name_tool patch, we need to add the - # "LDFLAGS=-headerpad_max_install_names" flag to configureFlags and either patch it into the - # Xcode project or pass it as a flag to xcodebuild as well. postConfigure = '' - substituteInPlace src/auto/config.mk \ - --replace-warn " -L${stdenv.cc.libc}/lib" "" \ - --replace-warn " -L${darwin.libunwind}/lib" "" \ - --replace-warn " -L${libiconv}/lib" "" - - # All the libraries we stripped have -osx- in their name as of this time. - # Assert now that this pattern no longer appears in config.mk. - ( # scope variable - while IFS="" read -r line; do - if [[ "$line" == LDFLAGS*-osx-* ]]; then - echo "WARNING: src/auto/config.mk contains reference to Nix osx library" >&2 - fi - done &6; } +@@ -6686,10 +6686,7 @@ printf "%s\n" "not found" >&6; } for path in "${vi_cv_path_mzscheme_pfx}/lib" "${SCHEME_LIB}"; do if test "X$path" != "X"; then @@ -79,7 +66,7 @@ index ecf10c4..4b691d0 100755 MZSCHEME_LIBS="${path}/libmzscheme3m.a" MZSCHEME_CFLAGS="-DMZ_PRECISE_GC" elif test -f "${path}/libracket3m.a"; then -@@ -6646,23 +6643,6 @@ printf "%s\n" ">>> too old; need Perl version 5.003_01 or later <<<" >&6; } +@@ -7128,23 +7125,6 @@ printf "%s\n" ">>> too old; need Perl version 5.003_01 or later <<<" >&6; } fi if test "x$MACOS_X" = "xyes"; then @@ -97,13 +84,13 @@ index ecf10c4..4b691d0 100755 - if test -n "$PERL"; then - PERL_DIR="$dir" - PERL_CFLAGS="-DFEAT_PERL -I$darwindir/CORE" -- PERL_OBJ="objects/if_perl.o objects/if_perlsfio.o $darwindir/auto/DynaLoader/DynaLoader.a" +- PERL_OBJ="objects/if_perl.o $darwindir/auto/DynaLoader/DynaLoader.a" - PERL_LIBS="-L$darwindir/CORE -lperl" - fi PERL_LIBS=`echo "$PERL_LIBS" | sed -e 's/-arch\ ppc//' -e 's/-arch\ i386//' -e 's/-arch\ x86_64//'` PERL_CFLAGS=`echo "$PERL_CFLAGS" | sed -e 's/-arch\ ppc//' -e 's/-arch\ i386//' -e 's/-arch\ x86_64//'` fi -@@ -6902,13 +6882,7 @@ __: +@@ -7393,13 +7373,7 @@ __: eof eval "`cd ${PYTHON_CONFDIR} && make -f "${tmp_mkf}" __ | sed '/ directory /d'`" rm -f -- "${tmp_mkf}" @@ -114,19 +101,11 @@ index ecf10c4..4b691d0 100755 - vi_cv_path_python_plibs="-F${python_PYTHONFRAMEWORKPREFIX} -framework Python" - fi - else -+ ++ if true; then vi_cv_path_python_plibs="-L${PYTHON_CONFDIR} -lpython${vi_cv_var_python_version}" if test -n "${python_LINKFORSHARED}" && test -n "${python_PYTHONFRAMEWORKPREFIX}"; then python_link_symbol=`echo ${python_LINKFORSHARED} | sed 's/\([^ \t][^ \t]*[ \t][ \t]*[^ \t][^ \t]*\)[ \t].*/\1/'` -@@ -6923,7 +6897,6 @@ eof - fi - vi_cv_path_python_plibs="${vi_cv_path_python_plibs} ${python_BASEMODLIBS} ${python_LIBS} ${python_SYSLIBS} ${python_LINKFORSHARED}" - vi_cv_path_python_plibs=`echo $vi_cv_path_python_plibs | sed s/-ltermcap//` -- fi - - fi - -@@ -7004,13 +6977,6 @@ rm -f core conftest.err conftest.$ac_objext conftest.beam \ +@@ -7498,13 +7472,6 @@ rm -f core conftest.err conftest.$ac_objext conftest.beam \ printf "%s\n" "no" >&6; } fi @@ -140,7 +119,7 @@ index ecf10c4..4b691d0 100755 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if compile and link flags for Python are sane" >&5 printf %s "checking if compile and link flags for Python are sane... " >&6; } cflags_save=$CFLAGS -@@ -8060,11 +8026,7 @@ printf "%s\n" "$tclver - OK" >&6; }; +@@ -8593,11 +8560,7 @@ printf "%s\n" "$tclver - OK" >&6; }; { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for location of Tcl include" >&5 printf %s "checking for location of Tcl include... " >&6; } @@ -152,7 +131,7 @@ index ecf10c4..4b691d0 100755 TCL_INC= for try in $tclinc; do if test -f "$try/tcl.h"; then -@@ -8082,13 +8044,8 @@ printf "%s\n" "" >&6; } +@@ -8615,13 +8578,8 @@ printf "%s\n" "" >&6; } if test -z "$SKIP_TCL"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for location of tclConfig.sh script" >&5 printf %s "checking for location of tclConfig.sh script... " >&6; } @@ -166,9 +145,9 @@ index ecf10c4..4b691d0 100755 for try in $tclcnf; do if test -f "$try/tclConfig.sh"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $try/tclConfig.sh" >&5 -@@ -8285,10 +8242,6 @@ printf "%s\n" "$rubyhdrdir" >&6; } +@@ -8819,10 +8777,6 @@ printf "%s\n" "$rubyhdrdir" >&6; } rubylibdir=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig.expand($ruby_rbconfig::CONFIG['libdir'])"` - if test -f "$rubylibdir/$librubya" || expr "$librubyarg" : "-lruby"; then + if test -f "$rubylibdir/$librubya" || expr "$librubyarg" : "-lruby" >/dev/null; then RUBY_LIBS="$RUBY_LIBS -L$rubylibdir" - elif test "$vi_cv_path_ruby" = "/usr/bin/ruby" -a -d "/System/Library/Frameworks/Ruby.framework"; then - RUBY_LIBS="-framework Ruby" @@ -177,25 +156,3 @@ index ecf10c4..4b691d0 100755 fi if test "X$librubyarg" != "X"; then -diff --git a/src/vim.h b/src/vim.h -index 6e33142..6185f45 100644 ---- a/src/vim.h -+++ b/src/vim.h -@@ -270,17 +270,6 @@ - # define SUN_SYSTEM - #endif - --// If we're compiling in C++ (currently only KVim), the system --// headers must have the correct prototypes or nothing will build. --// Conversely, our prototypes might clash due to throw() specifiers and --// cause compilation failures even though the headers are correct. For --// a concrete example, gcc-3.2 enforces exception specifications, and --// glibc-2.2.5 has them in their system headers. --#if !defined(__cplusplus) && defined(UNIX) \ -- && !defined(MACOS_X) // MACOS_X doesn't yet support osdef.h --# include "auto/osdef.h" // bring missing declarations in --#endif -- - #ifdef AMIGA - # include "os_amiga.h" - #endif