diff --git a/flake.lock b/flake.lock index 637e02de95..9ad829f444 100644 --- a/flake.lock +++ b/flake.lock @@ -59,23 +59,6 @@ "type": "github" } }, - "flake-utils": { - "inputs": { - "systems": "systems" - }, - "locked": { - "lastModified": 1710146030, - "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", - "type": "github" - }, - "original": { - "id": "flake-utils", - "type": "indirect" - } - }, "nixpkgs": { "locked": { "lastModified": 1710159071, @@ -115,7 +98,6 @@ "crane": "crane", "fenix": "fenix", "flake-parts": "flake-parts", - "flake-utils": "flake-utils", "nixpkgs": "nixpkgs" } }, @@ -135,21 +117,6 @@ "repo": "rust-analyzer", "type": "github" } - }, - "systems": { - "locked": { - "lastModified": 1681028828, - "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", - "owner": "nix-systems", - "repo": "default", - "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", - "type": "github" - }, - "original": { - "owner": "nix-systems", - "repo": "default", - "type": "github" - } } }, "root": "root", diff --git a/flake.nix b/flake.nix index 8c5ea3a871..fc34525554 100644 --- a/flake.nix +++ b/flake.nix @@ -8,36 +8,58 @@ fenix.inputs.nixpkgs.follows = "nixpkgs"; }; - outputs = { self, nixpkgs, crane, fenix, flake-utils, ... }: - flake-utils.lib.eachDefaultSystem (system: - let - craneLib = crane.lib.${system}; - - pkgs = import nixpkgs { - inherit system; - packages.${system}.default = - fenix.packages.${system}.default.toolchain; - }; + outputs = inputs@{ nixpkgs, flake-parts, ... }: + flake-parts.lib.mkFlake { inherit inputs; } { + systems = [ "aarch64-linux" "x86_64-linux" "x86_64-darwin" ]; - gitu = craneLib.buildPackage { - src = craneLib.cleanCargoSource (craneLib.path ./.); - doCheck = false; - buildInputs = with pkgs; - [ openssl pkg-config ] ++ nixpkgs.lib.optionals stdenv.isDarwin [ - libiconv - darwin.apple_sdk.frameworks.Security + perSystem = { config, pkgs, system, inputs', self', ... }: + let + toolchain = with inputs.fenix.packages.${system}; + combine [ + latest.rustc + latest.cargo + latest.clippy + latest.rust-analysis + latest.rust-src + latest.rustfmt ]; - }; - in { - checks = { inherit gitu; }; - packages.default = gitu; - apps.default = flake-utils.lib.mkApp { drv = gitu; }; + craneLib = inputs.crane.lib.${system}.overrideToolchain toolchain; + common-build-args = { + src = craneLib.cleanCargoSource (craneLib.path ./.); + }; + deps-only = craneLib.buildDepsOnly ({ } // common-build-args); + + packages = { + default = packages.gitu; + gitu = craneLib.buildPackage (common-build-args // { + doCheck = false; + buildInputs = with pkgs; + [ openssl pkg-config ] ++ pkgs.lib.optionals stdenv.isDarwin [ + libiconv + darwin.apple_sdk.frameworks.Security + ]; + }); + }; + + checks = { + clippy = craneLib.cargoClippy ({ + cargoArtifacts = deps-only; + cargoClippyExtraArgs = "--all-features -- --deny warnings"; + } // common-build-args); + + rust-fmt = craneLib.cargoFmt + ({ inherit (common-build-args) src; } // common-build-args); + + rust-tests = craneLib.cargoNextest ({ + cargoArtifacts = deps-only; + partitions = 1; + partitionType = "count"; + } // common-build-args); + }; - devShells.default = craneLib.devShell { - checks = self.checks.${system}; - inputsFrom = [ gitu ]; - packages = with pkgs; [ clippy rust-analyzer rustfmt ]; + in rec { + inherit packages checks; }; - }); + }; }