Skip to content

Commit

Permalink
switch to flake-parts
Browse files Browse the repository at this point in the history
  • Loading branch information
t56k committed Mar 13, 2024
1 parent 7c84199 commit 14da72b
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 60 deletions.
33 changes: 0 additions & 33 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

76 changes: 49 additions & 27 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
});
};
}

0 comments on commit 14da72b

Please sign in to comment.