jujutsu: overhaul build expression

The `jujutsu` expression has changed very lightly in the past year since
it was introduced, but the upstream Nix flake expression has gotten a
lot of updates in that time, to make builds faster and more featureful.

This is a port of some of those upstream changes. Among other things,
this:

- Stops zstd from being vendored via crate
- Stops libgit2 from being vendored via crate
- Removes a spurious dbus(?) dependency
- Installs man pages
- Runs the testsuite via nextest

Signed-off-by: Austin Seipp <aseipp@pobox.com>
This commit is contained in:
Austin Seipp 2023-07-16 21:18:28 -05:00
parent 128d2c2a0b
commit a9584671c3

View file

@ -1,14 +1,18 @@
{ lib
, rustPlatform
{ stdenv
, lib
, fetchFromGitHub
, pkg-config
, openssl
, stdenv
, dbus
, sqlite
, rustPlatform
, Security
, SystemConfiguration
, pkg-config
, libiconv
, openssl
, gzip
, libssh2
, libgit2
, zstd
, fetchpatch
, installShellFiles
, nix-update-script
, testers
, jujutsu
@ -27,23 +31,55 @@ rustPlatform.buildRustPackage rec {
cargoHash = "sha256-qbCOVcKpNGWGonRAwPsr3o3yd+7qUTy3IVmC3Ifn4xE=";
# Needed to get openssl-sys to use pkg-config.
OPENSSL_NO_VENDOR = 1;
buildNoDefaultFeatures = true;
buildFeatures = [
# enable 'packaging' feature, which enables extra features such as support
# for watchman
"packaging"
];
patches = [
# this patch (hopefully!) fixes a very, very rare test failure that can
# occasionally be cajoled out of Nix and GitHub CI builds. go ahead and
# apply it to be safe.
(fetchpatch {
url = "https://github.com/martinvonz/jj/commit/8e7e32710d29010423f3992bb920aaf2a0fa04ec.patch";
hash = "sha256-ySieobB1P/DpWOurcCb4BXoHk9IqrjzMfzdc3O5cTXk=";
})
];
cargoBuildFlags = [ "--bin" "jj" ]; # don't install the fake editors
useNextest = true; # nextest is the upstream integration framework
ZSTD_SYS_USE_PKG_CONFIG = "1"; # disable vendored zlib
LIBSSH2_SYS_USE_PKG_CONFIG = "1"; # disable vendored libssh2
nativeBuildInputs = [
gzip
installShellFiles
pkg-config
];
buildInputs = [
openssl
dbus
sqlite
zstd
libgit2
libssh2
] ++ lib.optionals stdenv.isDarwin [
Security
SystemConfiguration
libiconv
];
postInstall = ''
$out/bin/jj util mangen > ./jj.1
installManPage ./jj.1
installShellCompletion --cmd jj \
--bash <($out/bin/jj util completion --bash) \
--fish <($out/bin/jj util completion --fish) \
--zsh <($out/bin/jj util completion --zsh)
'';
passthru = {
updateScript = nix-update-script { };
tests = {