2022-02-20 18:42:01 +00:00
|
|
|
{
|
2023-01-26 17:08:55 +00:00
|
|
|
description = "Jujutsu VCS, a Git-compatible DVCS that is both simple and powerful";
|
2022-02-20 18:42:01 +00:00
|
|
|
|
2023-01-17 11:41:33 +00:00
|
|
|
inputs = {
|
2023-01-26 17:08:55 +00:00
|
|
|
# For listing and iterating nix systems
|
|
|
|
flake-utils.url = "github:numtide/flake-utils";
|
|
|
|
|
2024-12-05 20:36:17 +00:00
|
|
|
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
|
|
|
|
2023-01-17 11:41:33 +00:00
|
|
|
# For installing non-standard rustc versions
|
|
|
|
rust-overlay.url = "github:oxalica/rust-overlay";
|
|
|
|
rust-overlay.inputs.nixpkgs.follows = "nixpkgs";
|
|
|
|
};
|
|
|
|
|
2025-01-09 00:34:26 +00:00
|
|
|
outputs = {
|
|
|
|
self,
|
|
|
|
nixpkgs,
|
|
|
|
flake-utils,
|
|
|
|
rust-overlay,
|
|
|
|
}:
|
|
|
|
{
|
|
|
|
overlays.default = final: prev: {
|
|
|
|
jujutsu = self.packages.${final.system}.jujutsu;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
// (flake-utils.lib.eachDefaultSystem (system: let
|
2023-01-27 10:54:52 +00:00
|
|
|
pkgs = import nixpkgs {
|
|
|
|
inherit system;
|
|
|
|
overlays = [
|
|
|
|
rust-overlay.overlays.default
|
|
|
|
];
|
|
|
|
};
|
2023-07-14 11:34:36 +00:00
|
|
|
|
2023-01-27 10:54:52 +00:00
|
|
|
filterSrc = src: regexes:
|
|
|
|
pkgs.lib.cleanSourceWith {
|
|
|
|
inherit src;
|
2025-01-09 00:34:26 +00:00
|
|
|
filter = path: type: let
|
|
|
|
relPath = pkgs.lib.removePrefix (toString src + "/") (toString path);
|
|
|
|
in
|
2023-01-27 10:54:52 +00:00
|
|
|
pkgs.lib.all (re: builtins.match re relPath == null) regexes;
|
|
|
|
};
|
2023-11-09 01:10:39 +00:00
|
|
|
|
2024-10-17 21:46:48 +00:00
|
|
|
ourRustVersion = pkgs.rust-bin.selectLatestNightlyWith (toolchain: toolchain.default);
|
2023-07-11 13:08:13 +00:00
|
|
|
|
|
|
|
ourRustPlatform = pkgs.makeRustPlatform {
|
2024-02-24 23:35:17 +00:00
|
|
|
rustc = ourRustVersion;
|
|
|
|
cargo = ourRustVersion;
|
2023-07-11 13:08:13 +00:00
|
|
|
};
|
|
|
|
|
2025-01-09 00:34:26 +00:00
|
|
|
nativeBuildInputs = with pkgs;
|
|
|
|
[
|
|
|
|
gzip
|
|
|
|
pkg-config
|
|
|
|
|
|
|
|
# for libz-ng-sys (zlib-ng)
|
|
|
|
# TODO: switch to the packaged zlib-ng and drop this dependency
|
|
|
|
cmake
|
|
|
|
]
|
|
|
|
++ lib.optionals stdenv.isLinux [
|
|
|
|
mold-wrapped
|
|
|
|
];
|
|
|
|
|
|
|
|
buildInputs = with pkgs;
|
|
|
|
[
|
|
|
|
openssl
|
|
|
|
libgit2
|
|
|
|
libssh2
|
|
|
|
]
|
|
|
|
++ lib.optionals stdenv.isDarwin [
|
|
|
|
darwin.apple_sdk.frameworks.Security
|
|
|
|
darwin.apple_sdk.frameworks.SystemConfiguration
|
|
|
|
libiconv
|
|
|
|
];
|
2023-11-04 19:18:34 +00:00
|
|
|
|
2025-01-09 00:34:26 +00:00
|
|
|
nativeCheckInputs = with pkgs; [
|
|
|
|
# for signing tests
|
|
|
|
gnupg
|
|
|
|
openssh
|
2023-07-14 11:34:36 +00:00
|
|
|
];
|
|
|
|
|
2025-01-09 00:34:26 +00:00
|
|
|
env = {
|
|
|
|
LIBSSH2_SYS_USE_PKG_CONFIG = "1";
|
|
|
|
RUST_BACKTRACE = 1;
|
|
|
|
};
|
|
|
|
in {
|
|
|
|
formatter = pkgs.alejandra;
|
|
|
|
checks.jujutsu = self.packages.${system}.jujutsu;
|
|
|
|
|
2023-01-27 10:54:52 +00:00
|
|
|
packages = {
|
2024-02-13 01:53:54 +00:00
|
|
|
jujutsu = ourRustPlatform.buildRustPackage {
|
2023-01-27 10:54:52 +00:00
|
|
|
pname = "jujutsu";
|
|
|
|
version = "unstable-${self.shortRev or "dirty"}";
|
nix: merge (now redundant) flake check with normal build
Summary: Since 066032b6e69 was merged, the `nix flake check` build no longer
overrides the 'cargo test' profile explicitly, to save disk space. The CI seems
to be in a better spot. This will stem the tide for a while hopefully.
However, with that change in place, the `nix flake check` build was
essentially a redundant, nearly-identical copy of a normal `nix build` with no
differentiating features, except: `RUST_BACKTRACE` is set to 1.
Delete all this code, and remove it from the CI matrix, and instead just export
`RUST_BACKTRACE` on the `checkPhase` of the normal `nix build` instead, which is
functionally equivalent.
Also does some minor, no-functional-change touchups to `flake.nix` while I was
there (whitespace, etc.)
Signed-off-by: Austin Seipp <aseipp@pobox.com>
Change-Id: I87336b16e2a0b973343ecbde8ffd7b8f
2023-10-07 20:05:32 +00:00
|
|
|
|
2025-01-09 00:34:26 +00:00
|
|
|
buildFeatures = ["packaging"];
|
|
|
|
cargoBuildFlags = ["--bin" "jj"]; # don't build and install the fake editors
|
2023-06-24 05:39:27 +00:00
|
|
|
useNextest = true;
|
2023-01-27 10:54:52 +00:00
|
|
|
src = filterSrc ./. [
|
|
|
|
".*\\.nix$"
|
|
|
|
"^.jj/"
|
|
|
|
"^flake\\.lock$"
|
|
|
|
"^target/"
|
2023-01-17 11:41:33 +00:00
|
|
|
];
|
nix: merge (now redundant) flake check with normal build
Summary: Since 066032b6e69 was merged, the `nix flake check` build no longer
overrides the 'cargo test' profile explicitly, to save disk space. The CI seems
to be in a better spot. This will stem the tide for a while hopefully.
However, with that change in place, the `nix flake check` build was
essentially a redundant, nearly-identical copy of a normal `nix build` with no
differentiating features, except: `RUST_BACKTRACE` is set to 1.
Delete all this code, and remove it from the CI matrix, and instead just export
`RUST_BACKTRACE` on the `checkPhase` of the normal `nix build` instead, which is
functionally equivalent.
Also does some minor, no-functional-change touchups to `flake.nix` while I was
there (whitespace, etc.)
Signed-off-by: Austin Seipp <aseipp@pobox.com>
Change-Id: I87336b16e2a0b973343ecbde8ffd7b8f
2023-10-07 20:05:32 +00:00
|
|
|
|
|
|
|
cargoLock.lockFile = ./Cargo.lock;
|
2025-01-09 00:34:26 +00:00
|
|
|
nativeBuildInputs = nativeBuildInputs ++ [pkgs.installShellFiles];
|
|
|
|
inherit buildInputs nativeCheckInputs;
|
|
|
|
|
|
|
|
env =
|
|
|
|
env
|
|
|
|
// {
|
|
|
|
RUSTFLAGS = pkgs.lib.optionalString pkgs.stdenv.isLinux "-C link-arg=-fuse-ld=mold";
|
|
|
|
NIX_JJ_GIT_HASH = self.rev or "";
|
|
|
|
CARGO_INCREMENTAL = "0";
|
|
|
|
};
|
2024-02-24 23:41:50 +00:00
|
|
|
|
2023-01-27 10:54:52 +00:00
|
|
|
postInstall = ''
|
2025-01-07 17:27:41 +00:00
|
|
|
$out/bin/jj util install-man-pages man
|
|
|
|
installManPage ./man/man1/*
|
2023-01-26 17:06:51 +00:00
|
|
|
|
2023-03-21 14:31:42 +00:00
|
|
|
installShellCompletion --cmd jj \
|
2025-01-01 06:00:47 +00:00
|
|
|
--bash <(COMPLETE=bash $out/bin/jj) \
|
|
|
|
--fish <(COMPLETE=fish $out/bin/jj) \
|
|
|
|
--zsh <(COMPLETE=zsh $out/bin/jj)
|
2022-02-20 18:42:01 +00:00
|
|
|
'';
|
2024-11-09 02:20:57 +00:00
|
|
|
|
|
|
|
meta = {
|
|
|
|
description = "Git-compatible DVCS that is both simple and powerful";
|
2024-12-17 19:01:42 +00:00
|
|
|
homepage = "https://github.com/jj-vcs/jj";
|
2024-11-09 02:20:57 +00:00
|
|
|
license = pkgs.lib.licenses.asl20;
|
|
|
|
mainProgram = "jj";
|
|
|
|
};
|
2023-01-27 10:54:52 +00:00
|
|
|
};
|
|
|
|
default = self.packages.${system}.jujutsu;
|
|
|
|
};
|
github(nix): don't build everything twice
When running the `nix build`, the `buildRustPackage` function -- which builds
the `jj` crates -- calls `cargo build --release` with flags like `HOST_CXX`
set. This is called the `buildPhase`. Then, it runs the `checkPhase`, which
calls `cargo nextest`, in our case. However, it does not set `HOST_CXX`, for
some reason.
The intent of `buildRustPackage` is that the `buildPhase` and `checkPhase`
have their compilation options fully aligned so that they reuse the local cargo
`target/` cache directory, avoiding a full recompilation. However, the lack
of `HOST_CXX` above among others causes a cache miss, and a bunch of cascading
recompilations. The net impact is that we compile all of the codebase once in
`buildPhase`, then again in `checkPhase`, making the Nix CI build 2x slower on
average than the other Linux runners; 2-3 minutes versus 7 minutes, on average.
Instead, re-introduce a 'check' into the Flake directly, which overrides the
`jujustsu` package, but stubs out the `buildPhase`. This means it will only run
`checkPhase`, which is what we want. Then, modify the CI to run `nix flake check`
again, like it used to in the past.
Unfortunately, this doesn't fix the cache miss when running `nix build`
yourself, it recompiles from scratch in both phases still. That needs to be
fixed in the future, but it's tolerable for now.
This reverts most of 71a3045032f512.
Signed-off-by: Austin Seipp <aseipp@pobox.com>
2024-02-22 01:50:47 +00:00
|
|
|
|
2025-01-09 00:34:26 +00:00
|
|
|
devShells.default = let
|
2024-11-01 22:17:29 +00:00
|
|
|
packages = with pkgs; [
|
2024-10-17 21:46:48 +00:00
|
|
|
# NOTE (aseipp): explicitly add rust-src to the rustc compiler only in
|
|
|
|
# devShell. this in turn causes a dependency on the rust compiler src,
|
|
|
|
# which bloats the closure size by several GiB. but doing this here
|
|
|
|
# and not by default avoids the default flake install from including
|
|
|
|
# that dependency, so it's worth it
|
|
|
|
#
|
|
|
|
# relevant PR: https://github.com/rust-lang/rust/pull/129687
|
|
|
|
(ourRustVersion.override {
|
2025-01-09 00:34:26 +00:00
|
|
|
extensions = ["rust-src" "rust-analyzer"];
|
2024-10-17 21:46:48 +00:00
|
|
|
})
|
2023-01-17 11:41:33 +00:00
|
|
|
|
2023-01-27 10:54:52 +00:00
|
|
|
# Additional tools recommended by contributing.md
|
2025-01-09 01:40:21 +00:00
|
|
|
bacon
|
2023-01-27 10:54:52 +00:00
|
|
|
cargo-deny
|
|
|
|
cargo-insta
|
|
|
|
cargo-nextest
|
2023-08-27 02:18:07 +00:00
|
|
|
|
2024-06-25 08:26:02 +00:00
|
|
|
# Miscellaneous tools
|
|
|
|
watchman
|
|
|
|
|
2023-11-09 01:10:39 +00:00
|
|
|
# In case you need to run `cargo run --bin gen-protos`
|
|
|
|
protobuf
|
|
|
|
|
2023-08-27 02:18:07 +00:00
|
|
|
# For building the documentation website
|
2024-11-09 21:32:29 +00:00
|
|
|
uv
|
2025-01-09 00:34:26 +00:00
|
|
|
];
|
2024-04-04 06:35:05 +00:00
|
|
|
|
2025-01-09 00:34:26 +00:00
|
|
|
# on macOS and Linux, use faster parallel linkers that are much more
|
|
|
|
# efficient than the defaults. these noticeably improve link time even for
|
|
|
|
# medium sized rust projects like jj
|
|
|
|
rustLinkerFlags =
|
|
|
|
if pkgs.stdenv.isLinux
|
|
|
|
then ["-fuse-ld=mold" "-Wl,--compress-debug-sections=zstd"]
|
|
|
|
else if pkgs.stdenv.isDarwin
|
|
|
|
then
|
|
|
|
# on darwin, /usr/bin/ld actually looks at the environment variable
|
|
|
|
# $DEVELOPER_DIR, which is set by the nix stdenv, and if set,
|
|
|
|
# automatically uses it to route the `ld` invocation to the binary
|
|
|
|
# within. in the devShell though, that isn't what we want; it's
|
|
|
|
# functional, but Xcode's linker as of ~v15 (not yet open source)
|
|
|
|
# is ultra-fast and very shiny; it is enabled via -ld_new, and on by
|
|
|
|
# default as of v16+
|
|
|
|
["--ld-path=$(unset DEVELOPER_DIR; /usr/bin/xcrun --find ld)" "-ld_new"]
|
|
|
|
else [];
|
|
|
|
|
|
|
|
rustLinkFlagsString =
|
|
|
|
pkgs.lib.concatStringsSep " "
|
|
|
|
(pkgs.lib.concatMap (x: ["-C" "link-arg=${x}"]) rustLinkerFlags);
|
|
|
|
|
2025-01-10 19:21:35 +00:00
|
|
|
# The `RUSTFLAGS` environment variable is set in `shellHook` instead of `env`
|
|
|
|
# to allow the `xcrun` command above to be interpreted by the shell.
|
|
|
|
shellHook = ''
|
|
|
|
export RUSTFLAGS="-Zthreads=0 ${rustLinkFlagsString}"
|
|
|
|
'';
|
2025-01-09 00:34:26 +00:00
|
|
|
in
|
|
|
|
pkgs.mkShell {
|
|
|
|
name = "jujutsu";
|
|
|
|
packages = packages ++ nativeBuildInputs ++ buildInputs ++ nativeCheckInputs;
|
2025-01-10 19:21:35 +00:00
|
|
|
inherit env shellHook;
|
2025-01-09 00:34:26 +00:00
|
|
|
};
|
2023-01-27 10:54:52 +00:00
|
|
|
}));
|
2022-02-20 18:42:01 +00:00
|
|
|
}
|