add: nix flake
This commit is contained in:
81
flake.nix
Normal file
81
flake.nix
Normal file
@@ -0,0 +1,81 @@
|
||||
{
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.11";
|
||||
flake-parts.url = "github:hercules-ci/flake-parts";
|
||||
systems.url = "github:nix-systems/default";
|
||||
rust-overlay.url = "github:oxalica/rust-overlay";
|
||||
};
|
||||
|
||||
outputs =
|
||||
inputs@{ flake-parts, ... }:
|
||||
flake-parts.lib.mkFlake { inherit inputs; } {
|
||||
imports = [ ./shell.nix ];
|
||||
|
||||
perSystem =
|
||||
{
|
||||
self',
|
||||
pkgs,
|
||||
lib,
|
||||
system,
|
||||
...
|
||||
}:
|
||||
let
|
||||
cargoToml = lib.importTOML ./Cargo.toml;
|
||||
|
||||
rustToolchain = pkgs.rust-bin.stable.latest.default.override {
|
||||
extensions = [
|
||||
"rust-src"
|
||||
"rustfmt"
|
||||
"clippy"
|
||||
];
|
||||
};
|
||||
in
|
||||
{
|
||||
_module.args = {
|
||||
pkgs = import inputs.nixpkgs {
|
||||
inherit system;
|
||||
overlays = [
|
||||
inputs.rust-overlay.overlays.default
|
||||
];
|
||||
};
|
||||
|
||||
inherit rustToolchain;
|
||||
};
|
||||
|
||||
formatter = pkgs.nixfmt-tree;
|
||||
|
||||
packages.default = pkgs.rustPlatform.buildRustPackage {
|
||||
pname = cargoToml.package.name;
|
||||
version = cargoToml.package.version;
|
||||
src = ./.;
|
||||
|
||||
nativeBuildInputs = with pkgs; [
|
||||
pkg-config
|
||||
];
|
||||
|
||||
buildInputs = with pkgs; [
|
||||
openssl
|
||||
];
|
||||
|
||||
cargoLock.lockFile = ./Cargo.lock;
|
||||
};
|
||||
|
||||
checks = {
|
||||
default = self'.packages.default;
|
||||
|
||||
format =
|
||||
pkgs.runCommand "cargo-fmt"
|
||||
{
|
||||
nativeBuildInputs = [ rustToolchain ];
|
||||
}
|
||||
''
|
||||
cd ${./.}
|
||||
cargo fmt --all -- --check
|
||||
touch $out
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
systems = import inputs.systems;
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user