Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 50 additions & 6 deletions pkgs/applications/version-management/sapling/default.nix
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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"
'';
Expand All @@ -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;
Expand All @@ -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

Expand All @@ -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";
};
}
4 changes: 3 additions & 1 deletion pkgs/top-level/all-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -30351,7 +30351,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; };

Expand Down