about summary refs log tree commit diff
path: root/pkgs/applications/version-management/jujutsu
diff options
context:
space:
mode:
authorAustin Seipp <aseipp@pobox.com>2023-07-16 21:18:28 -0500
committerAustin Seipp <aseipp@pobox.com>2023-07-16 23:16:10 -0500
commita9584671c3ae1f458a11e9eac80b6eec55ef76e6 (patch)
tree100bef5cf7ca0a1e25c3bb626b191710e9661ca9 /pkgs/applications/version-management/jujutsu
parent128d2c2a0b74621e697bbf1ad572210b43aebb13 (diff)
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>
Diffstat (limited to 'pkgs/applications/version-management/jujutsu')
-rw-r--r--pkgs/applications/version-management/jujutsu/default.nix58
1 files changed, 47 insertions, 11 deletions
diff --git a/pkgs/applications/version-management/jujutsu/default.nix b/pkgs/applications/version-management/jujutsu/default.nix
index eea11c062fad3..6aea2cedcc96d 100644
--- a/pkgs/applications/version-management/jujutsu/default.nix
+++ b/pkgs/applications/version-management/jujutsu/default.nix
@@ -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 = {