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.

Changed files
+53 -7
pkgs
applications
version-management
sapling
top-level
+50 -6
pkgs/applications/version-management/sapling/default.nix
···
-
{ lib, stdenv, python3Packages, fetchFromGitHub, fetchurl, sd, curl, pkg-config, openssl, rustPlatform, fetchYarnDeps, yarn, nodejs, fixup_yarn_lock, glibcLocales }:
let
inherit (lib.importJSON ./deps.json) links version versionHash;
src = fetchFromGitHub {
owner = "facebook";
···
};
# Builds the main `sl` binary and its Python extensions
-
sapling = python3Packages.buildPythonPackage {
pname = "sapling-main";
inherit src version;
···
sed -i "s|https://files.pythonhosted.org/packages/[[:alnum:]]*/[[:alnum:]]*/[[:alnum:]]*/|file://$NIX_BUILD_TOP/$sourceRoot/hack_pydeps/|g" $sourceRoot/setup.py
'';
-
postFixup = ''
wrapProgram $out/bin/sl \
--set LOCALE_ARCHIVE "${glibcLocales}/lib/locale/locale-archive"
'';
···
curl
pkg-config
] ++ (with rustPlatform; [
-
cargoSetupHook
rust.cargo
rust.rustc
]);
buildInputs = [
openssl
];
doCheck = false;
···
cp -r ${sapling}/* $out
-
sitepackages=$out/lib/${python3Packages.python.libPrefix}/site-packages
chmod +w $sitepackages
cp -r ${isl} $sitepackages/edenscm-isl
···
homepage = "https://sapling-scm.com";
license = licenses.gpl2Only;
maintainers = with maintainers; [ pbar thoughtpolice ];
-
platforms = platforms.linux;
mainProgram = "sl";
};
}
···
+
{ 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";
···
};
# Builds the main `sl` binary and its Python extensions
+
#
+
# 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;
···
sed -i "s|https://files.pythonhosted.org/packages/[[:alnum:]]*/[[:alnum:]]*/[[:alnum:]]*/|file://$NIX_BUILD_TOP/$sourceRoot/hack_pydeps/|g" $sourceRoot/setup.py
'';
+
postFixup = lib.optionalString stdenv.isLinux ''
wrapProgram $out/bin/sl \
--set LOCALE_ARCHIVE "${glibcLocales}/lib/locale/locale-archive"
'';
···
curl
pkg-config
] ++ (with rustPlatform; [
+
myCargoSetupHook
rust.cargo
rust.rustc
]);
buildInputs = [
+
curl
openssl
+
] ++ lib.optionals stdenv.isDarwin [
+
libiconv
+
CoreFoundation
+
CoreServices
+
Security
];
doCheck = false;
···
cp -r ${sapling}/* $out
+
sitepackages=$out/lib/${python38Packages.python.libPrefix}/site-packages
chmod +w $sitepackages
cp -r ${isl} $sitepackages/edenscm-isl
···
homepage = "https://sapling-scm.com";
license = licenses.gpl2Only;
maintainers = with maintainers; [ pbar thoughtpolice ];
+
platforms = platforms.unix;
mainProgram = "sl";
};
}
+3 -1
pkgs/top-level/all-packages.nix
···
inherit (darwin.apple_sdk.frameworks) ApplicationServices;
};
-
sapling = callPackage ../applications/version-management/sapling { };
mercurialFull = mercurial.override { fullBuild = true; };
···
inherit (darwin.apple_sdk.frameworks) ApplicationServices;
};
+
sapling = callPackage ../applications/version-management/sapling {
+
inherit (darwin.apple_sdk.frameworks) CoreFoundation CoreServices Security;
+
};
mercurialFull = mercurial.override { fullBuild = true; };