aboutsummaryrefslogtreecommitdiff
path: root/src/x509-info/flake.nix
diff options
context:
space:
mode:
authorFranck Cuny <franck@fcuny.net>2022-11-04 18:11:43 -0700
committerFranck Cuny <franck@fcuny.net>2022-11-04 18:11:43 -0700
commit9bb6132e02f00ede19f6fd929b0ebcd8d0e21fa8 (patch)
tree2fa46131432465da7112c5f96bd447843b8f9fec /src/x509-info/flake.nix
parentMerge pull request #4 from fcuny/fcuny/rewrite-actions (diff)
downloadx-9bb6132e02f00ede19f6fd929b0ebcd8d0e21fa8.tar.gz
buid: use crane to build the binary
crane is a nix library to build cargo projects, similar to naersk. The main advantage over naersk is the composability. I'll give it a try and see if it's faster for local development.
Diffstat (limited to 'src/x509-info/flake.nix')
-rw-r--r--src/x509-info/flake.nix60
1 files changed, 32 insertions, 28 deletions
diff --git a/src/x509-info/flake.nix b/src/x509-info/flake.nix
index 6061f08..c0e0eeb 100644
--- a/src/x509-info/flake.nix
+++ b/src/x509-info/flake.nix
@@ -11,6 +11,10 @@
nixpkgs.follows = "nixpkgs";
};
};
+ crane = {
+ url = "github:ipetkov/crane";
+ inputs.nixpkgs.follows = "nixpkgs";
+ };
pre-commit-hooks = {
url = "github:cachix/pre-commit-hooks.nix";
inputs = {
@@ -25,43 +29,45 @@
, flake-utils
, nixpkgs
, rust-overlay
+ , crane
, pre-commit-hooks
}:
- let
- # Borrow project metadata from the Rust config
- meta = (builtins.fromTOML (builtins.readFile ./Cargo.toml)).package;
- inherit (meta) name version;
- overlays = [
- # Rust helpers
- (import rust-overlay)
- # Build Rust toolchain using helpers from rust-overlay
- (self: super: {
- # This supplies cargo, rustc, rustfmt, etc.
- rustToolchain = super.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
- })
- ];
- in
flake-utils.lib.eachDefaultSystem
(system:
let
- pkgs = import nixpkgs { inherit overlays system; };
+ pkgs = import nixpkgs {
+ inherit system;
+ overlays = [ (import rust-overlay) ];
+ };
+ rust-toolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
+
+ craneLib = (crane.mkLib pkgs).overrideScope' (_: _: {
+ cargo = rust-toolchain;
+ clippy = rust-toolchain;
+ rustc = rust-toolchain;
+ rustfmt = rust-toolchain;
+ });
+
+ src = ./.;
+
+ cargoArtifacts = craneLib.buildDepsOnly {
+ inherit src;
+ };
+
+ x509-info = craneLib.buildPackage {
+ inherit cargoArtifacts src;
+ };
in
{
- packages = rec {
- default = x509-info;
- x509-info = pkgs.rustPlatform.buildRustPackage {
- pname = name;
- inherit version;
- src = ./.;
- release = true;
- cargoLock.lockFile = ./Cargo.lock;
- };
+ packages.default = x509-info;
+ apps.default = flake-utils.lib.mkApp {
+ drv = x509-info;
};
checks = {
pre-commit = pre-commit-hooks.lib.${system}.run {
- src = ./.;
+ inherit src;
hooks = {
clippy = {
enable = true;
@@ -80,10 +86,8 @@
devShell = pkgs.mkShell {
nativeBuildInputs = with pkgs; [
- rustToolchain
- cargo-audit
+ rust-toolchain
cargo-deny
- rust-analyzer
];
inherit (self.checks.${system}.pre-commit) shellHook;