Skip to content

Commit

Permalink
Add clippy and fmt in multi-stage build
Browse files Browse the repository at this point in the history
  • Loading branch information
IGI-111 committed May 26, 2024
1 parent 116c494 commit a4a5472
Showing 1 changed file with 38 additions and 24 deletions.
62 changes: 38 additions & 24 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
githubActions = nix-github-actions.lib.mkGithubMatrix {
checks = nixpkgs.lib.getAttrs [
"x86_64-linux"
"x86_64-darwin"
] self.packages; # TODO use self.checks
# "x86_64-darwin"
] self.checks;
};
}
// (flake-utils.lib.eachDefaultSystem (
Expand Down Expand Up @@ -51,33 +51,47 @@
# kdialog
];
libPath = pkgs.lib.makeLibraryPath buildInputs;
src =
let
# Only keeps slint files
dirFilter = path: _type: builtins.match ".*(assets|src|ui)/.*$" path != null;
slintFilter = path: _type: builtins.match ".*slint$" path != null;
sourceFilter =
path: type:
(dirFilter path type) || (slintFilter path type) || (craneLib.filterCargoSources path type);
in
nixpkgs.lib.cleanSourceWith {
src = craneLib.path ./.;
filter = sourceFilter;
};
cargoArtifacts = craneLib.buildDepsOnly {
inherit src buildInputs nativeBuildInputs;
LD_LIBRARY_PATH = libPath;
};
kira = craneLib.buildPackage {
inherit
src
buildInputs
nativeBuildInputs
cargoArtifacts
;
LD_LIBRARY_PATH = libPath;
};
in
{
packages.default = craneLib.buildPackage {
src =
let
# Only keeps slint files
dirFilter = path: _type: builtins.match ".*(assets|src|ui)/.*$" path != null;
slintFilter = path: _type: builtins.match ".*slint$" path != null;
sourceFilter =
path: type:
(dirFilter path type) || (slintFilter path type) || (craneLib.filterCargoSources path type);
in
nixpkgs.lib.cleanSourceWith {
src = craneLib.path ./.;
filter = sourceFilter;
};
packages.default = kira;

# Add extra inputs here or any other derivation settings
# doCheck = true;
buildInputs = buildInputs;
nativeBuildInputs = nativeBuildInputs;
LD_LIBRARY_PATH = libPath;
checks = {
inherit kira;
kira-clippy = craneLib.cargoClippy {
inherit cargoArtifacts;
cargoClippyExtraArgs = "--all-targets -- --deny warnings";
};
kira-fmt = craneLib.cargoFmt { inherit src; };
};
# `nix develop`

devShell = pkgs.mkShell {
buildInputs = buildInputs;
nativeBuildInputs = nativeBuildInputs;
inherit buildInputs nativeBuildInputs;
LD_LIBRARY_PATH = libPath;
};
}
Expand Down

0 comments on commit a4a5472

Please sign in to comment.