crane for cached dep builds, clippy pedantic, extract paths module
This commit is contained in:
parent
4c17146b6f
commit
888eddf093
7 changed files with 167 additions and 80 deletions
87
flake.nix
87
flake.nix
|
|
@ -4,6 +4,8 @@
|
|||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||
|
||||
crane.url = "github:ipetkov/crane";
|
||||
|
||||
treefmt-nix = {
|
||||
url = "github:numtide/treefmt-nix";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
|
|
@ -14,6 +16,7 @@
|
|||
{
|
||||
self,
|
||||
nixpkgs,
|
||||
crane,
|
||||
treefmt-nix,
|
||||
...
|
||||
}:
|
||||
|
|
@ -26,9 +29,31 @@
|
|||
f:
|
||||
nixpkgs.lib.genAttrs systems (
|
||||
system:
|
||||
f {
|
||||
let
|
||||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
treefmt-eval = treefmt-nix.lib.evalModule nixpkgs.legacyPackages.${system} treefmt-config;
|
||||
craneLib = crane.mkLib pkgs;
|
||||
src = craneLib.cleanCargoSource ./.;
|
||||
commonArgs = {
|
||||
inherit src;
|
||||
pname = "damocles-daemon";
|
||||
version = "0.1.0";
|
||||
nativeBuildInputs = with pkgs; [ pkg-config ];
|
||||
buildInputs = with pkgs; [
|
||||
openssl
|
||||
sqlite
|
||||
];
|
||||
};
|
||||
# deps-only build - cached separately, only rebuilds when Cargo.lock changes
|
||||
cargoArtifacts = craneLib.buildDepsOnly commonArgs;
|
||||
in
|
||||
f {
|
||||
inherit
|
||||
pkgs
|
||||
craneLib
|
||||
commonArgs
|
||||
cargoArtifacts
|
||||
;
|
||||
treefmt-eval = treefmt-nix.lib.evalModule pkgs treefmt-config;
|
||||
}
|
||||
);
|
||||
treefmt-config = {
|
||||
|
|
@ -40,26 +65,24 @@
|
|||
in
|
||||
{
|
||||
packages = forAllSystems (
|
||||
{ pkgs, ... }:
|
||||
{
|
||||
default = pkgs.rustPlatform.buildRustPackage {
|
||||
pname = "damocles-daemon";
|
||||
version = "0.1.0";
|
||||
src = nixpkgs.lib.cleanSource ./.;
|
||||
cargoLock.lockFile = ./Cargo.lock;
|
||||
|
||||
nativeBuildInputs = with pkgs; [ pkg-config ];
|
||||
buildInputs = with pkgs; [
|
||||
openssl
|
||||
sqlite
|
||||
];
|
||||
|
||||
meta = {
|
||||
description = "Matrix chat daemon for Damocles";
|
||||
mainProgram = "damocles-daemon";
|
||||
platforms = nixpkgs.lib.platforms.linux;
|
||||
};
|
||||
};
|
||||
craneLib,
|
||||
commonArgs,
|
||||
cargoArtifacts,
|
||||
...
|
||||
}:
|
||||
{
|
||||
default = craneLib.buildPackage (
|
||||
commonArgs
|
||||
// {
|
||||
inherit cargoArtifacts;
|
||||
meta = {
|
||||
description = "Matrix chat daemon for Damocles";
|
||||
mainProgram = "damocles-daemon";
|
||||
platforms = nixpkgs.lib.platforms.linux;
|
||||
};
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
|
|
@ -84,10 +107,30 @@
|
|||
formatter = forAllSystems ({ treefmt-eval, ... }: treefmt-eval.config.build.wrapper);
|
||||
|
||||
checks = forAllSystems (
|
||||
{ pkgs, treefmt-eval, ... }:
|
||||
{
|
||||
pkgs,
|
||||
craneLib,
|
||||
commonArgs,
|
||||
cargoArtifacts,
|
||||
treefmt-eval,
|
||||
...
|
||||
}:
|
||||
{
|
||||
formatting = treefmt-eval.config.build.check self;
|
||||
build = self.packages.${pkgs.stdenv.hostPlatform.system}.default;
|
||||
clippy = craneLib.cargoClippy (
|
||||
commonArgs
|
||||
// {
|
||||
inherit cargoArtifacts;
|
||||
cargoClippyExtraArgs = "--all-targets";
|
||||
}
|
||||
);
|
||||
tests = craneLib.cargoTest (
|
||||
commonArgs
|
||||
// {
|
||||
inherit cargoArtifacts;
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue