Upgrade flake build process

The previous build process was MASSIVELY inefficient in multiple
ways. This is a massive improvement.
This commit is contained in:
Kiana Sheibani 2023-08-27 01:46:20 -04:00
parent 41475046ed
commit 303f955de4
Signed by: toki
GPG key ID: 6CB106C25E86A9F7

View file

@ -14,21 +14,39 @@
flake-utils.lib.eachDefaultSystem (system: flake-utils.lib.eachDefaultSystem (system:
let pkgs = import nixpkgs { inherit system; }; let pkgs = import nixpkgs { inherit system; };
craneLib = crane.lib.${system}; craneLib = crane.lib.${system};
in {
packages.ggelo = craneLib.buildPackage { commonArgs = {
pname = "ggelo";
version = "0.1.0"; version = "0.1.0";
src = ./.; src = craneLib.path ./.;
cargoBuildFlags = "-p cli"; cargoBuildFlags = "-p cli";
buildInputs = [ pkgs.openssl ];
nativeBuildInputs = [ pkgs.pkg-config ]; nativeBuildInputs = [ pkgs.pkg-config ];
PKG_CONFIG_PATH = "${pkgs.openssl.dev}/lib/pkgconfig";
doCheck = true;
}; };
packages.default = self.packages.${system}.ggelo; # Cargo build dependencies/artifacts only
checks.default = self.packages.${system}.ggelo; # This derivation exists so that multiple builds can reuse
# the same build artifacts
cargoArtifacts = craneLib.buildDepsOnly (commonArgs // {
pname = "ggelo-deps";
});
# Run clippy (and deny all warnings) on the crate source
runClippy = craneLib.cargoClippy (commonArgs // {
pname = "ggelo-clippy-check";
cargoClippyExtraArgs = "--all-targets -- --deny warnings";
inherit cargoArtifacts;
});
ggelo = craneLib.buildPackage (commonArgs // {
pname = "ggelo";
inherit cargoArtifacts;
});
in {
packages.ggelo = ggelo;
packages.default = ggelo;
checks.build = ggelo;
checks.runClippy = runClippy;
devShells.default = pkgs.mkShell { devShells.default = pkgs.mkShell {
packages = with pkgs; [ rustc cargo pkg-config rust-analyzer ]; packages = with pkgs; [ rustc cargo pkg-config rust-analyzer ];