2021-01-11 07:54:33 +00:00
|
|
|
{ lib, stdenv, fetchFromGitHub, runCommand, ncurses, gettext
|
2021-01-19 06:50:56 +00:00
|
|
|
, pkg-config, cscope, ruby, tcl, perl, luajit
|
2016-05-07 01:50:52 +01:00
|
|
|
, darwin
|
2019-06-10 06:35:11 +01:00
|
|
|
|
|
|
|
, usePython27 ? false
|
|
|
|
, python27 ? null, python37 ? null
|
2014-06-06 22:45:22 +01:00
|
|
|
}:
|
|
|
|
|
2019-06-10 06:35:11 +01:00
|
|
|
let
|
|
|
|
python = if usePython27
|
|
|
|
then { pkg = python27; name = "python"; }
|
|
|
|
else { pkg = python37; name = "python3"; };
|
|
|
|
in
|
|
|
|
assert python.pkg != null;
|
|
|
|
|
|
|
|
let
|
|
|
|
# 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
|
|
|
|
|
2019-08-13 22:52:01 +01:00
|
|
|
stdenv.mkDerivation {
|
2019-08-15 13:41:18 +01:00
|
|
|
pname = "macvim";
|
2014-06-06 22:45:22 +01:00
|
|
|
|
2022-02-13 03:09:45 +00:00
|
|
|
version = "8.2.3455";
|
2014-06-06 22:45:22 +01:00
|
|
|
|
2015-11-15 05:50:31 +00:00
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "macvim-dev";
|
|
|
|
repo = "macvim";
|
2022-02-13 03:09:45 +00:00
|
|
|
rev = "snapshot-172";
|
|
|
|
sha256 = "sha256-LLLQ/V1vyKTuSXzHW3SOlOejZD5AV16NthEdMoTnfko=";
|
2014-06-06 22:45:22 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
enableParallelBuilding = true;
|
|
|
|
|
2021-01-19 06:50:56 +00:00
|
|
|
nativeBuildInputs = [ pkg-config buildSymlinks ];
|
2014-06-06 22:45:22 +01:00
|
|
|
buildInputs = [
|
2019-06-10 06:35:11 +01:00
|
|
|
gettext ncurses cscope luajit ruby tcl perl python.pkg
|
2014-06-06 22:45:22 +01:00
|
|
|
];
|
|
|
|
|
2020-03-04 02:02:27 +00:00
|
|
|
patches = [ ./macvim.patch ];
|
2014-06-06 22:45:22 +01:00
|
|
|
|
|
|
|
configureFlags = [
|
2019-06-10 06:35:11 +01:00
|
|
|
"--enable-cscope"
|
2014-06-06 22:45:22 +01:00
|
|
|
"--enable-fail-if-missing"
|
|
|
|
"--with-features=huge"
|
|
|
|
"--enable-gui=macvim"
|
|
|
|
"--enable-multibyte"
|
|
|
|
"--enable-nls"
|
|
|
|
"--enable-luainterp=dynamic"
|
2019-06-10 06:35:11 +01:00
|
|
|
"--enable-${python.name}interp=dynamic"
|
2014-06-06 22:45:22 +01:00
|
|
|
"--enable-perlinterp=dynamic"
|
|
|
|
"--enable-rubyinterp=dynamic"
|
|
|
|
"--enable-tclinterp=yes"
|
2014-10-18 06:15:45 +01:00
|
|
|
"--without-local-dir"
|
2014-06-06 22:45:22 +01:00
|
|
|
"--with-luajit"
|
|
|
|
"--with-lua-prefix=${luajit}"
|
2019-06-10 06:35:11 +01:00
|
|
|
"--with-${python.name}-command=${python.pkg}/bin/${python.name}"
|
2014-06-06 22:45:22 +01:00
|
|
|
"--with-ruby-command=${ruby}/bin/ruby"
|
|
|
|
"--with-tclsh=${tcl}/bin/tclsh"
|
|
|
|
"--with-tlib=ncurses"
|
|
|
|
"--with-compiledby=Nix"
|
2020-03-04 02:02:27 +00:00
|
|
|
"--disable-sparkle"
|
2014-06-06 22:45:22 +01:00
|
|
|
];
|
|
|
|
|
2020-03-04 02:02:27 +00:00
|
|
|
# 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
|
|
|
|
'';
|
|
|
|
|
2019-06-10 06:35:11 +01:00
|
|
|
# This is unfortunate, but we need to use the same compiler as Xcode,
|
|
|
|
# but Xcode doesn't provide a way to configure the compiler.
|
2014-06-06 22:45:22 +01:00
|
|
|
preConfigure = ''
|
2015-11-15 05:50:31 +00:00
|
|
|
CC=/usr/bin/clang
|
|
|
|
|
2014-06-06 22:45:22 +01:00
|
|
|
DEV_DIR=$(/usr/bin/xcode-select -print-path)/Platforms/MacOSX.platform/Developer
|
|
|
|
configureFlagsArray+=(
|
2020-09-28 23:12:07 +01:00
|
|
|
--with-developer-dir="$DEV_DIR"
|
|
|
|
LDFLAGS="-L${ncurses}/lib"
|
|
|
|
CPPFLAGS="-isystem ${ncurses.dev}/include"
|
|
|
|
CFLAGS="-Wno-error=implicit-function-declaration"
|
2014-06-06 22:45:22 +01:00
|
|
|
)
|
2019-06-10 06:35:11 +01:00
|
|
|
''
|
|
|
|
# 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
|
|
|
|
''
|
2020-11-06 02:00:31 +00:00
|
|
|
# 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"
|
|
|
|
--with-xcodecfg="Release"
|
|
|
|
)
|
|
|
|
''
|
2019-06-10 06:35:11 +01:00
|
|
|
;
|
2014-06-06 22:45:22 +01:00
|
|
|
|
2020-04-19 04:35:04 +01:00
|
|
|
# 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.
|
2016-05-07 01:50:52 +01:00
|
|
|
postConfigure = ''
|
2020-04-19 04:35:04 +01:00
|
|
|
substituteInPlace src/auto/config.mk \
|
|
|
|
--replace "PERL_CFLAGS =" "PERL_CFLAGS = -I${darwin.libutil}/include" \
|
|
|
|
--replace " -L${stdenv.cc.libc}/lib" "" \
|
|
|
|
--replace " -L${darwin.libobjc}/lib" "" \
|
|
|
|
--replace " -L${darwin.libunwind}/lib" "" \
|
|
|
|
--replace " -L${darwin.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 <src/auto/config.mk
|
|
|
|
)
|
2019-06-10 06:35:11 +01:00
|
|
|
|
|
|
|
substituteInPlace src/MacVim/vimrc --subst-var-by CSCOPE ${cscope}/bin/cscope
|
2016-05-07 01:50:52 +01:00
|
|
|
'';
|
|
|
|
|
2014-06-06 22:45:22 +01:00
|
|
|
postInstall = ''
|
2014-06-30 13:56:10 +01:00
|
|
|
mkdir -p $out/Applications
|
2014-06-07 21:18:27 +01:00
|
|
|
cp -r src/MacVim/build/Release/MacVim.app $out/Applications
|
2016-03-10 16:38:13 +00:00
|
|
|
rm -rf $out/MacVim.app
|
2014-06-06 22:45:22 +01:00
|
|
|
|
2019-06-10 06:35:11 +01:00
|
|
|
rm $out/bin/*
|
2014-06-06 22:45:22 +01:00
|
|
|
|
|
|
|
cp src/vimtutor $out/bin
|
2019-06-10 06:35:11 +01:00
|
|
|
for prog in mvim ex vi vim vimdiff view rvim rvimdiff rview; do
|
|
|
|
ln -s $out/Applications/MacVim.app/Contents/bin/mvim $out/bin/$prog
|
2014-06-06 22:45:22 +01:00
|
|
|
done
|
|
|
|
|
|
|
|
# Fix rpaths
|
2014-06-07 21:18:27 +01:00
|
|
|
exe="$out/Applications/MacVim.app/Contents/MacOS/Vim"
|
2014-06-06 22:45:22 +01:00
|
|
|
libperl=$(dirname $(find ${perl} -name "libperl.dylib"))
|
|
|
|
install_name_tool -add_rpath ${luajit}/lib $exe
|
|
|
|
install_name_tool -add_rpath ${tcl}/lib $exe
|
2019-06-10 06:35:11 +01:00
|
|
|
install_name_tool -add_rpath ${python.pkg}/lib $exe
|
2014-06-06 22:45:22 +01:00
|
|
|
install_name_tool -add_rpath $libperl $exe
|
|
|
|
install_name_tool -add_rpath ${ruby}/lib $exe
|
2019-06-10 06:35:11 +01:00
|
|
|
|
|
|
|
# Remove manpages from tools we aren't providing
|
|
|
|
find $out/share/man \( -name eVim.1 -or -name xxd.1 \) -delete
|
2014-06-06 22:45:22 +01:00
|
|
|
'';
|
|
|
|
|
2019-09-26 20:17:06 +01:00
|
|
|
# We rely on the user's Xcode install to build. It may be located in an arbitrary place, and
|
|
|
|
# it's not clear what system-level components it may require, so for now we'll just allow full
|
|
|
|
# filesystem access. This way the package still can't access the network.
|
|
|
|
sandboxProfile = ''
|
|
|
|
(allow file-read* file-write* process-exec mach-lookup)
|
|
|
|
; block homebrew dependencies
|
|
|
|
(deny file-read* file-write* process-exec mach-lookup (subpath "/usr/local") (with no-log))
|
|
|
|
'';
|
|
|
|
|
2021-01-11 07:54:33 +00:00
|
|
|
meta = with lib; {
|
2017-08-06 23:05:18 +01:00
|
|
|
description = "Vim - the text editor - for macOS";
|
2020-04-01 02:11:51 +01:00
|
|
|
homepage = "https://github.com/macvim-dev/macvim";
|
2015-05-28 18:20:29 +01:00
|
|
|
license = licenses.vim;
|
2019-06-10 06:35:11 +01:00
|
|
|
maintainers = with maintainers; [ cstrahan lilyball ];
|
2014-06-06 22:45:22 +01:00
|
|
|
platforms = platforms.darwin;
|
2019-10-19 08:19:46 +01:00
|
|
|
hydraPlatforms = []; # hydra can't build this as long as we rely on Xcode and sandboxProfile
|
2014-06-06 22:45:22 +01:00
|
|
|
};
|
|
|
|
}
|