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
|
|
|
|
];
|
|
|
|
};
|
|
|
|
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;
|
|
|
|
};
|
2022-02-20 18:42:01 +00:00
|
|
|
in
|
|
|
|
{
|
2023-01-27 10:54:52 +00:00
|
|
|
packages = {
|
|
|
|
jujutsu = pkgs.rustPlatform.buildRustPackage rec {
|
|
|
|
pname = "jujutsu";
|
|
|
|
version = "unstable-${self.shortRev or "dirty"}";
|
|
|
|
buildNoDefaultFeatures = true;
|
2023-03-29 18:13:28 +00:00
|
|
|
buildFeatures = [];
|
2023-06-24 05:39:27 +00:00
|
|
|
cargoBuildFlags = ["--bin" "jj"]; # don't build and install the fake editors
|
|
|
|
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
|
|
|
];
|
2023-01-27 10:54:52 +00:00
|
|
|
cargoLock = {
|
|
|
|
lockFile = ./Cargo.lock;
|
2023-01-26 17:51:25 +00:00
|
|
|
};
|
2023-01-27 10:54:52 +00:00
|
|
|
nativeBuildInputs = with pkgs; [
|
|
|
|
gzip
|
|
|
|
installShellFiles
|
|
|
|
makeWrapper
|
|
|
|
pkg-config
|
|
|
|
];
|
2023-05-05 21:33:14 +00:00
|
|
|
buildInputs = with pkgs; [ openssl zstd libgit2 libssh2 ]
|
2023-01-26 17:06:51 +00:00
|
|
|
++ lib.optionals stdenv.isDarwin [
|
2023-01-27 10:54:52 +00:00
|
|
|
darwin.apple_sdk.frameworks.Security
|
|
|
|
darwin.apple_sdk.frameworks.SystemConfiguration
|
|
|
|
libiconv
|
2023-03-07 06:06:29 +00:00
|
|
|
];
|
|
|
|
ZSTD_SYS_USE_PKG_CONFIG = "1";
|
|
|
|
LIBSSH2_SYS_USE_PKG_CONFIG = "1";
|
2023-06-24 05:39:27 +00:00
|
|
|
NIX_JJ_GIT_HASH = self.rev or "";
|
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 \
|
2023-04-13 00:04:24 +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;
|
|
|
|
};
|
|
|
|
apps.default = {
|
|
|
|
type = "app";
|
|
|
|
program = "${self.packages.${system}.jujutsu}/bin/jj";
|
|
|
|
};
|
|
|
|
checks.jujutsu = self.packages.${system}.jujutsu.overrideAttrs ({ ... }: {
|
|
|
|
cargoBuildType = "debug";
|
|
|
|
cargoCheckType = "debug";
|
|
|
|
preCheck = ''
|
|
|
|
export RUST_BACKTRACE=1
|
|
|
|
'';
|
|
|
|
});
|
|
|
|
formatter = pkgs.nixpkgs-fmt;
|
|
|
|
devShells.default = pkgs.mkShell {
|
|
|
|
buildInputs = with pkgs; [
|
|
|
|
# Using the minimal profile with explicit "clippy" extension to avoid
|
|
|
|
# two versions of rustfmt
|
2023-03-17 22:42:55 +00:00
|
|
|
(rust-bin.stable."1.64.0".minimal.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-01-27 10:54:52 +00:00
|
|
|
# The CI checks against the latest nightly rustfmt, so we should too.
|
|
|
|
(rust-bin.selectLatestNightlyWith (toolchain: toolchain.rustfmt))
|
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-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-01-27 10:54:52 +00:00
|
|
|
};
|
|
|
|
}));
|
2022-02-20 18:42:01 +00:00
|
|
|
}
|