sapling: fix on macOS
There were two factors here: our cargo hook was messing up the cargo config, which broke the build, and also an upstream bug where Sapling didn't work on Python 3.10. The upstream issue was filed as https://github.com/facebook/sapling/issues/279 We can get rid of the python 3.8 override as soon as this patch gets into a released version.
This commit is contained in:
parent
eefa1a94a9
commit
6065d768e1
2 changed files with 53 additions and 7 deletions
|
@ -1,7 +1,41 @@
|
|||
{ lib, stdenv, python3Packages, fetchFromGitHub, fetchurl, sd, curl, pkg-config, openssl, rustPlatform, fetchYarnDeps, yarn, nodejs, fixup_yarn_lock, glibcLocales }:
|
||||
{ lib
|
||||
, stdenv
|
||||
, python38Packages
|
||||
, fetchFromGitHub
|
||||
, fetchurl
|
||||
, sd
|
||||
, curl
|
||||
, pkg-config
|
||||
, openssl
|
||||
, rustPlatform
|
||||
, fetchYarnDeps
|
||||
, yarn
|
||||
, nodejs
|
||||
, fixup_yarn_lock
|
||||
, glibcLocales
|
||||
, libiconv
|
||||
, CoreFoundation
|
||||
, CoreServices
|
||||
, Security
|
||||
}:
|
||||
|
||||
let
|
||||
inherit (lib.importJSON ./deps.json) links version versionHash;
|
||||
# Sapling sets a Cargo config containing lines like so:
|
||||
# [target.aarch64-apple-darwin]
|
||||
# rustflags = ["-C", "link-args=-Wl,-undefined,dynamic_lookup"]
|
||||
#
|
||||
# The default cargo config that's set by the build hook will set
|
||||
# unstable.host-config and unstable.target-applies-to-host which seems to
|
||||
# result in the link arguments above being ignored and thus link failures.
|
||||
# All it is there to do anyway is just to do stuff with musl and cross
|
||||
# compilation, which doesn't work on macOS anyway so we can just stub it
|
||||
# on macOS.
|
||||
#
|
||||
# See https://github.com/NixOS/nixpkgs/pull/198311#issuecomment-1326894295
|
||||
myCargoSetupHook = rustPlatform.cargoSetupHook.overrideAttrs (old: {
|
||||
cargoConfig = if stdenv.isDarwin then "" else old.cargoConfig;
|
||||
});
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "facebook";
|
||||
|
@ -54,7 +88,11 @@ let
|
|||
};
|
||||
|
||||
# Builds the main `sl` binary and its Python extensions
|
||||
sapling = python3Packages.buildPythonPackage {
|
||||
#
|
||||
# FIXME(lf-): when next updating this package, delete the python 3.8 override
|
||||
# here, since the fix for https://github.com/facebook/sapling/issues/279 that
|
||||
# required it will be in the next release.
|
||||
sapling = python38Packages.buildPythonPackage {
|
||||
pname = "sapling-main";
|
||||
inherit src version;
|
||||
|
||||
|
@ -85,7 +123,7 @@ let
|
|||
sed -i "s|https://files.pythonhosted.org/packages/[[:alnum:]]*/[[:alnum:]]*/[[:alnum:]]*/|file://$NIX_BUILD_TOP/$sourceRoot/hack_pydeps/|g" $sourceRoot/setup.py
|
||||
'';
|
||||
|
||||
postFixup = ''
|
||||
postFixup = lib.optionalString stdenv.isLinux ''
|
||||
wrapProgram $out/bin/sl \
|
||||
--set LOCALE_ARCHIVE "${glibcLocales}/lib/locale/locale-archive"
|
||||
'';
|
||||
|
@ -94,13 +132,19 @@ let
|
|||
curl
|
||||
pkg-config
|
||||
] ++ (with rustPlatform; [
|
||||
cargoSetupHook
|
||||
myCargoSetupHook
|
||||
rust.cargo
|
||||
rust.rustc
|
||||
]);
|
||||
|
||||
buildInputs = [
|
||||
curl
|
||||
openssl
|
||||
] ++ lib.optionals stdenv.isDarwin [
|
||||
libiconv
|
||||
CoreFoundation
|
||||
CoreServices
|
||||
Security
|
||||
];
|
||||
|
||||
doCheck = false;
|
||||
|
@ -124,7 +168,7 @@ stdenv.mkDerivation {
|
|||
|
||||
cp -r ${sapling}/* $out
|
||||
|
||||
sitepackages=$out/lib/${python3Packages.python.libPrefix}/site-packages
|
||||
sitepackages=$out/lib/${python38Packages.python.libPrefix}/site-packages
|
||||
chmod +w $sitepackages
|
||||
cp -r ${isl} $sitepackages/edenscm-isl
|
||||
|
||||
|
@ -145,7 +189,7 @@ stdenv.mkDerivation {
|
|||
homepage = "https://sapling-scm.com";
|
||||
license = licenses.gpl2Only;
|
||||
maintainers = with maintainers; [ pbar thoughtpolice ];
|
||||
platforms = platforms.linux;
|
||||
platforms = platforms.unix;
|
||||
mainProgram = "sl";
|
||||
};
|
||||
}
|
||||
|
|
|
@ -30435,7 +30435,9 @@ with pkgs;
|
|||
inherit (darwin.apple_sdk.frameworks) ApplicationServices;
|
||||
};
|
||||
|
||||
sapling = callPackage ../applications/version-management/sapling { };
|
||||
sapling = callPackage ../applications/version-management/sapling {
|
||||
inherit (darwin.apple_sdk.frameworks) CoreFoundation CoreServices Security;
|
||||
};
|
||||
|
||||
mercurialFull = mercurial.override { fullBuild = true; };
|
||||
|
||||
|
|
Loading…
Reference in a new issue