Fix mg building on darwin by changing to new upstream #85627
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
For context, this is for the issue #71136.
This PR now sets the upstream to https://github.com/ibara/mg. For context I will leave the original comment (which patched the original upstream using patches from https://github.com/ibara/mg which apply missing header files on darwin) below.
Original comment:
I am not happy with this at all. It avoids using libbsd at all on darwin because there are conflicting header files, particularly the header string.h.
Ideally that would be the thing to fix upstream. But in the meantime, this patch should do the trick. This is taken from https://github.com/ibara/mg and the license of the patch is the same as
mg
itself. Homebrew and macports carry https://github.com/ibara/mg. Fink does not package it. Debian and many Linux distributions carry https://github.com/hboetes/mg. NetBSD pkgsrc carries the hboetes version albeit from 2011 (!). Something also relevant, is that MacOS as of MacOS Catalina removed their very old (pre-GPLv3) Emacs from the base operating system, and actually replaced it with a reasonably recent version ofmg
.The patch declares a header file
apple.h
, which files include if target is darwin (checks for presence of__APPLE__
). This header file also references the three source filesfutimens.c
,reallocarray.c
andstrtonum.c
. The former and latter are from https://github.com/ibara/mg. Also of note is thatfutimens
was added to macOS as of 10.13, but 10.12 does not have it so it still is necessary to patch it for now. There might be a better way.From the OpenBSD source tree is
_null.h
andtree.h
. There is a check so that if__APPLE__
is present then it will include them from this source tree.Now, the makefile GNUMakefile will not link against
libbsd
on darwin, by checking the output of uname in much the same way as it did already for FreeBSD.I would really appreciate testing on NixOS and other Linux distributions!
This applies to the same version in 19.09 and nixpkgs-unstable.
Motivation for this change
This package is not marked as broken, but it is on macOS. It is a generally useful small emacs-like editor. The package in nixpkgs is also quite old, so it makes sense to update it to the most recent release from the upstream source repository.
Things done
sandbox
innix.conf
on non-NixOS linux)nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
./result/bin/
)nix path-info -S
before and after)