| 1 |
{ |
| 2 |
lib, |
| 3 |
stdenv, |
| 4 |
rustPlatform, |
| 5 |
gitRev ? null, |
| 6 |
git, |
| 7 |
gnupg, |
| 8 |
installShellFiles, |
| 9 |
mold, |
| 10 |
openssh, |
| 11 |
}: let |
| 12 |
packageVersion = (builtins.fromTOML (builtins.readFile ./Cargo.toml)).workspace.package.version; |
| 13 |
filterSrc = src: regexes: |
| 14 |
lib.cleanSourceWith { |
| 15 |
inherit src; |
| 16 |
filter = path: type: let |
| 17 |
relPath = lib.removePrefix (toString src + "/") (toString path); |
| 18 |
in |
| 19 |
lib.all (re: builtins.match re relPath == null) regexes; |
| 20 |
}; |
| 21 |
in |
| 22 |
rustPlatform.buildRustPackage { |
| 23 |
pname = "jujutsu"; |
| 24 |
version = "${packageVersion}-unstable-${ |
| 25 |
if gitRev != null |
| 26 |
then gitRev |
| 27 |
else "dirty" |
| 28 |
}"; |
| 29 |
|
| 30 |
cargoBuildFlags = ["--bin" "jj"]; # don't build and install the fake editors |
| 31 |
useNextest = true; |
| 32 |
cargoTestFlags = ["--profile" "ci"]; |
| 33 |
src = filterSrc ./. [ |
| 34 |
".*\\.nix$" |
| 35 |
"^.jj/" |
| 36 |
"^flake\\.lock$" |
| 37 |
"^target/" |
| 38 |
]; |
| 39 |
|
| 40 |
cargoLock.lockFile = ./Cargo.lock; |
| 41 |
nativeBuildInputs = |
| 42 |
[ |
| 43 |
installShellFiles |
| 44 |
] |
| 45 |
++ lib.optionals stdenv.hostPlatform.isLinux [ |
| 46 |
mold |
| 47 |
]; |
| 48 |
buildInputs = []; |
| 49 |
nativeCheckInputs = [ |
| 50 |
# for signing tests |
| 51 |
gnupg |
| 52 |
openssh |
| 53 |
|
| 54 |
# for git subprocess test |
| 55 |
git |
| 56 |
]; |
| 57 |
|
| 58 |
env = { |
| 59 |
RUST_BACKTRACE = 1; |
| 60 |
CARGO_INCREMENTAL = "0"; # https://github.com/rust-lang/rust/issues/139110 |
| 61 |
RUSTFLAGS = lib.optionalString stdenv.hostPlatform.isLinux "-C link-arg=-fuse-ld=mold"; |
| 62 |
NIX_JJ_GIT_HASH = gitRev; |
| 63 |
}; |
| 64 |
|
| 65 |
postInstall = '' |
| 66 |
$out/bin/jj util install-man-pages man |
| 67 |
installManPage ./man/man1/* |
| 68 |
|
| 69 |
installShellCompletion --cmd jj \ |
| 70 |
--bash <(COMPLETE=bash $out/bin/jj) \ |
| 71 |
--fish <(COMPLETE=fish $out/bin/jj) \ |
| 72 |
--zsh <(COMPLETE=zsh $out/bin/jj) |
| 73 |
''; |
| 74 |
|
| 75 |
meta = { |
| 76 |
description = "Git-compatible DVCS that is both simple and powerful"; |
| 77 |
homepage = "https://github.com/jj-vcs/jj"; |
| 78 |
license = lib.licenses.asl20; |
| 79 |
mainProgram = "jj"; |
| 80 |
}; |
| 81 |
} |