|
|
|
@ -49,27 +49,38 @@
|
|
|
|
|
filter = pkgs.lib.cleanSourceFilter;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
buildInputs = with pkgs;
|
|
|
|
|
[ ffmpeg imagemagick pandoc poppler_utils ripgrep tesseract ]
|
|
|
|
|
++ pkgs.lib.optionals pkgs.stdenv.isDarwin [
|
|
|
|
|
# Additional darwin specific inputs can be set here
|
|
|
|
|
pkgs.libiconv
|
|
|
|
|
];
|
|
|
|
|
nativeBuildInputs = pkgs.lib.optionals pkgs.stdenv.isDarwin [
|
|
|
|
|
# Additional darwin specific inputs can be set here
|
|
|
|
|
pkgs.libiconv
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
runtimeInputs = with pkgs; [ ffmpeg pandoc poppler_utils ripgrep zip ];
|
|
|
|
|
|
|
|
|
|
# Build *just* the cargo dependencies, so we can reuse
|
|
|
|
|
# all of that work (e.g. via cachix) when running in CI
|
|
|
|
|
cargoArtifacts = craneLib.buildDepsOnly { inherit src buildInputs; };
|
|
|
|
|
cargoArtifacts =
|
|
|
|
|
craneLib.buildDepsOnly { inherit src nativeBuildInputs; };
|
|
|
|
|
|
|
|
|
|
# Build the actual crate itself, reusing the dependency
|
|
|
|
|
# artifacts from above.
|
|
|
|
|
rga = craneLib.buildPackage { inherit cargoArtifacts src buildInputs; };
|
|
|
|
|
rgaBinary = craneLib.buildPackage {
|
|
|
|
|
inherit cargoArtifacts src nativeBuildInputs;
|
|
|
|
|
buildInputs = runtimeInputs; # needed for tests
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
# Provide a shell script of the Rust binary plus runtime dependencies.
|
|
|
|
|
rga = pkgs.pkgs.writeShellApplication {
|
|
|
|
|
name = "rga";
|
|
|
|
|
text = ''rga "$@"'';
|
|
|
|
|
runtimeInputs = runtimeInputs ++ [ rgaBinary ];
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
pre-commit = pre-commit-hooks.lib."${system}".run;
|
|
|
|
|
in {
|
|
|
|
|
# `nix flake check`
|
|
|
|
|
checks = {
|
|
|
|
|
# Build the crate as part of `nix flake check` for convenience
|
|
|
|
|
inherit rga;
|
|
|
|
|
inherit rgaBinary;
|
|
|
|
|
|
|
|
|
|
# Run clippy (and deny all warnings) on the crate source,
|
|
|
|
|
# again, resuing the dependency artifacts from above.
|
|
|
|
@ -78,7 +89,7 @@
|
|
|
|
|
# we can block the CI if there are issues here, but not
|
|
|
|
|
# prevent downstream consumers from building our crate by itself.
|
|
|
|
|
rga-clippy = craneLib.cargoClippy {
|
|
|
|
|
inherit cargoArtifacts src buildInputs;
|
|
|
|
|
inherit cargoArtifacts src;
|
|
|
|
|
cargoClippyExtraArgs = "--all-targets -- --deny warnings";
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
@ -92,7 +103,8 @@
|
|
|
|
|
|
|
|
|
|
# Run tests with cargo-nextest.
|
|
|
|
|
rga-nextest = craneLib.cargoNextest {
|
|
|
|
|
inherit cargoArtifacts src buildInputs;
|
|
|
|
|
inherit cargoArtifacts src nativeBuildInputs;
|
|
|
|
|
buildInputs = runtimeInputs; # needed for tests
|
|
|
|
|
partitions = 1;
|
|
|
|
|
partitionType = "count";
|
|
|
|
|
};
|
|
|
|
@ -113,7 +125,7 @@
|
|
|
|
|
|
|
|
|
|
# `nix build`
|
|
|
|
|
packages = {
|
|
|
|
|
inherit rga; # `nix build .#rga`
|
|
|
|
|
inherit rgaBinary rga;
|
|
|
|
|
default = rga; # `nix build`
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
@ -121,11 +133,10 @@
|
|
|
|
|
apps.default = flake-utils.lib.mkApp { drv = rga; };
|
|
|
|
|
|
|
|
|
|
# `nix develop`
|
|
|
|
|
devShells.default = pkgs.mkShell {
|
|
|
|
|
devShells.default = craneLib.devShell {
|
|
|
|
|
inherit (self.checks.${system}.pre-commit) shellHook;
|
|
|
|
|
inputsFrom = builtins.attrValues self.checks;
|
|
|
|
|
buildInputs = buildInputs
|
|
|
|
|
++ (with pkgs; [ cargo nixfmt rustc rustfmt ]);
|
|
|
|
|
packages = runtimeInputs ++ nativeBuildInputs;
|
|
|
|
|
};
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|