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";
|
|
|
|
|
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";
|
2023-01-26 17:08:55 +00:00
|
|
|
rust-overlay.inputs.flake-utils.follows = "flake-utils";
|
2023-01-17 11:41:33 +00:00
|
|
|
};
|
|
|
|
|
2023-01-27 10:54:52 +00:00
|
|
|
outputs = { self, nixpkgs, flake-utils, rust-overlay }: {
|
|
|
|
overlays.default = (final: prev: {
|
|
|
|
jujutsu = self.packages.${final.system}.jujutsu;
|
|
|
|
});
|
|
|
|
} //
|
|
|
|
(flake-utils.lib.eachDefaultSystem (system:
|
2022-02-20 18:42:01 +00:00
|
|
|
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;
|
|
|
|
filter = path: type:
|
|
|
|
let
|
|
|
|
relPath = pkgs.lib.removePrefix (toString src + "/") (toString path);
|
|
|
|
in
|
|
|
|
pkgs.lib.all (re: builtins.match re relPath == null) regexes;
|
|
|
|
};
|
2023-11-09 01:10:39 +00:00
|
|
|
|
2024-02-24 23:35:17 +00:00
|
|
|
ourRustVersion = pkgs.rust-bin.stable."1.76.0".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
|
|
|
};
|
|
|
|
|
2023-11-04 19:18:34 +00:00
|
|
|
# these are needed in both devShell and buildInputs
|
|
|
|
darwinDeps = with pkgs; lib.optionals stdenv.isDarwin [
|
|
|
|
darwin.apple_sdk.frameworks.Security
|
|
|
|
darwin.apple_sdk.frameworks.SystemConfiguration
|
|
|
|
libiconv
|
|
|
|
];
|
|
|
|
|
2024-02-24 23:41:50 +00:00
|
|
|
# work around https://github.com/nextest-rs/nextest/issues/267
|
|
|
|
# this needs to exist in both the devShell and preCheck phase!
|
|
|
|
darwinNextestHack = pkgs.lib.optionalString pkgs.stdenv.isDarwin ''
|
|
|
|
export DYLD_FALLBACK_LIBRARY_PATH=$(${ourRustVersion}/bin/rustc --print sysroot)/lib
|
|
|
|
'';
|
|
|
|
|
2023-07-14 11:34:36 +00:00
|
|
|
# NOTE (aseipp): on Linux, go ahead and use mold by default to improve
|
|
|
|
# link times a bit; mostly useful for debug build speed, but will help
|
|
|
|
# over time if we ever get more dependencies, too
|
|
|
|
useMoldLinker = pkgs.stdenv.isLinux;
|
|
|
|
|
|
|
|
# these are needed in both devShell and buildInputs
|
|
|
|
linuxNativeDeps = with pkgs; lib.optionals stdenv.isLinux [
|
|
|
|
mold-wrapped
|
|
|
|
];
|
|
|
|
|
2022-02-20 18:42:01 +00:00
|
|
|
in
|
|
|
|
{
|
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
|
|
|
|
2023-07-12 16:18:30 +00:00
|
|
|
buildFeatures = [ "packaging" ];
|
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
|
|
|
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;
|
2023-01-27 10:54:52 +00:00
|
|
|
nativeBuildInputs = with pkgs; [
|
|
|
|
gzip
|
|
|
|
installShellFiles
|
|
|
|
makeWrapper
|
|
|
|
pkg-config
|
2024-02-07 14:09:25 +00:00
|
|
|
|
|
|
|
# for signing tests
|
|
|
|
gnupg
|
|
|
|
openssh
|
2023-07-14 11:34:36 +00:00
|
|
|
] ++ linuxNativeDeps;
|
2023-07-11 13:08:13 +00:00
|
|
|
buildInputs = with pkgs; [
|
|
|
|
openssl zstd libgit2 libssh2
|
2023-11-04 19:18:34 +00:00
|
|
|
] ++ darwinDeps;
|
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
|
|
|
|
2023-03-07 06:06:29 +00:00
|
|
|
ZSTD_SYS_USE_PKG_CONFIG = "1";
|
|
|
|
LIBSSH2_SYS_USE_PKG_CONFIG = "1";
|
2023-07-14 11:34:36 +00:00
|
|
|
RUSTFLAGS = pkgs.lib.optionalString useMoldLinker "-C link-arg=-fuse-ld=mold";
|
2023-06-24 05:39:27 +00:00
|
|
|
NIX_JJ_GIT_HASH = self.rev or "";
|
2023-07-10 07:01:17 +00:00
|
|
|
CARGO_INCREMENTAL = "0";
|
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
|
|
|
|
2024-02-24 23:41:50 +00:00
|
|
|
preCheck = ''
|
|
|
|
export RUST_BACKTRACE=1
|
|
|
|
'' + darwinNextestHack;
|
|
|
|
|
2023-01-27 10:54:52 +00:00
|
|
|
postInstall = ''
|
2023-04-13 00:04:24 +00:00
|
|
|
$out/bin/jj util mangen > ./jj.1
|
2023-01-27 10:54:52 +00:00
|
|
|
installManPage ./jj.1
|
2023-01-26 17:06:51 +00:00
|
|
|
|
2023-03-21 14:31:42 +00:00
|
|
|
installShellCompletion --cmd jj \
|
2024-02-16 22:13:08 +00:00
|
|
|
--bash <($out/bin/jj util completion bash) \
|
|
|
|
--fish <($out/bin/jj util completion fish) \
|
|
|
|
--zsh <($out/bin/jj util completion zsh)
|
2022-02-20 18:42:01 +00:00
|
|
|
'';
|
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
|
|
|
|
2023-01-27 10:54:52 +00:00
|
|
|
apps.default = {
|
|
|
|
type = "app";
|
|
|
|
program = "${self.packages.${system}.jujutsu}/bin/jj";
|
|
|
|
};
|
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
|
|
|
|
2023-01-27 10:54:52 +00:00
|
|
|
formatter = pkgs.nixpkgs-fmt;
|
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
|
|
|
|
|
|
|
checks.jujutsu = self.packages.${system}.jujutsu.overrideAttrs ({ ... }: {
|
|
|
|
# FIXME (aseipp): when running `nix flake check`, this will override the
|
|
|
|
# main package, and nerf the build and installation phases. this is
|
|
|
|
# because for some inexplicable reason, the cargo cache gets invalidated
|
|
|
|
# in between buildPhase and checkPhase, causing every nix CI build to be
|
|
|
|
# 2x as long.
|
|
|
|
#
|
|
|
|
# upstream issue: https://github.com/NixOS/nixpkgs/issues/291222
|
|
|
|
buildPhase = "true";
|
|
|
|
installPhase = "touch $out";
|
|
|
|
# NOTE (aseipp): buildRustPackage also, by default, runs `cargo check`
|
|
|
|
# in `--release` mode, which is far slower; the existing CI builds all
|
|
|
|
# use the default `test` profile, so we should too.
|
|
|
|
cargoCheckType = "test";
|
|
|
|
});
|
|
|
|
|
2023-01-27 10:54:52 +00:00
|
|
|
devShells.default = pkgs.mkShell {
|
|
|
|
buildInputs = with pkgs; [
|
2023-11-03 00:46:49 +00:00
|
|
|
# The CI checks against the latest nightly rustfmt, so we should too.
|
2024-02-24 23:35:17 +00:00
|
|
|
# NOTE (aseipp): include this FIRST before the ourRustVersion override
|
|
|
|
# below; otherwise, it will be overridden by the ourRustVersion and
|
2023-11-03 00:46:49 +00:00
|
|
|
# we'll get stable rustfmt instead.
|
|
|
|
(rust-bin.selectLatestNightlyWith (toolchain: toolchain.rustfmt))
|
|
|
|
|
2023-01-27 10:54:52 +00:00
|
|
|
# Using the minimal profile with explicit "clippy" extension to avoid
|
|
|
|
# two versions of rustfmt
|
2024-02-24 23:35:17 +00:00
|
|
|
(ourRustVersion.override {
|
2023-01-27 10:54:52 +00:00
|
|
|
extensions = [
|
|
|
|
"rust-src" # for rust-analyzer
|
|
|
|
"clippy"
|
|
|
|
];
|
|
|
|
})
|
2023-01-17 11:41:33 +00:00
|
|
|
|
2023-05-05 20:59:24 +00:00
|
|
|
# Foreign dependencies
|
|
|
|
openssl zstd libgit2 libssh2
|
|
|
|
pkg-config
|
2023-01-17 11:41:33 +00:00
|
|
|
|
2023-06-24 05:39:27 +00:00
|
|
|
# Make sure rust-analyzer is present
|
|
|
|
rust-analyzer
|
|
|
|
|
2023-01-27 10:54:52 +00:00
|
|
|
# Additional tools recommended by contributing.md
|
|
|
|
cargo-deny
|
|
|
|
cargo-insta
|
|
|
|
cargo-nextest
|
|
|
|
cargo-watch
|
2023-08-27 02:18:07 +00:00
|
|
|
|
2023-11-09 01:10:39 +00:00
|
|
|
# In case you need to run `cargo run --bin gen-protos`
|
|
|
|
protobuf
|
|
|
|
|
2024-02-13 01:53:54 +00:00
|
|
|
# To run the signing tests
|
|
|
|
gnupg
|
2024-02-07 14:09:25 +00:00
|
|
|
openssh
|
2024-02-13 01:53:54 +00:00
|
|
|
|
2023-08-27 02:18:07 +00:00
|
|
|
# For building the documentation website
|
|
|
|
poetry
|
2023-07-14 11:34:36 +00:00
|
|
|
] ++ darwinDeps ++ linuxNativeDeps;
|
2023-05-05 20:59:24 +00:00
|
|
|
|
|
|
|
shellHook = ''
|
|
|
|
export RUST_BACKTRACE=1
|
|
|
|
export ZSTD_SYS_USE_PKG_CONFIG=1
|
|
|
|
export LIBSSH2_SYS_USE_PKG_CONFIG=1
|
2023-07-14 11:34:36 +00:00
|
|
|
'' + pkgs.lib.optionalString useMoldLinker ''
|
2024-02-21 23:23:38 +00:00
|
|
|
export RUSTFLAGS="-C link-arg=-fuse-ld=mold"
|
2024-02-24 23:41:50 +00:00
|
|
|
'' + darwinNextestHack;
|
2023-01-27 10:54:52 +00:00
|
|
|
};
|
|
|
|
}));
|
2022-02-20 18:42:01 +00:00
|
|
|
}
|