Initial Version
Signed-off-by: Marcel Müller <neikos@neikos.email>
This commit is contained in:
commit
757d027a4d
5 changed files with 113 additions and 0 deletions
1
.envrc
Normal file
1
.envrc
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
use flake
|
||||||
8
.gitignore
vendored
Normal file
8
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
# Rust/Cargo
|
||||||
|
/target
|
||||||
|
|
||||||
|
# Direnv
|
||||||
|
/.direnv
|
||||||
|
|
||||||
|
# Nix
|
||||||
|
/result*
|
||||||
99
flake.nix
Normal file
99
flake.nix
Normal file
|
|
@ -0,0 +1,99 @@
|
||||||
|
{
|
||||||
|
description = "library";
|
||||||
|
inputs = {
|
||||||
|
nixpkgs.url = "nixpkgs/nixos-24.05";
|
||||||
|
flake-utils = {
|
||||||
|
url = "github:numtide/flake-utils";
|
||||||
|
};
|
||||||
|
crane = {
|
||||||
|
url = "github:ipetkov/crane";
|
||||||
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
};
|
||||||
|
rust-overlay = {
|
||||||
|
url = "github:oxalica/rust-overlay";
|
||||||
|
inputs = {
|
||||||
|
nixpkgs.follows = "nixpkgs";
|
||||||
|
flake-utils.follows = "flake-utils";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
outputs =
|
||||||
|
inputs:
|
||||||
|
inputs.flake-utils.lib.eachDefaultSystem (
|
||||||
|
system:
|
||||||
|
let
|
||||||
|
pkgs = import inputs.nixpkgs {
|
||||||
|
inherit system;
|
||||||
|
overlays = [ (import inputs.rust-overlay) ];
|
||||||
|
};
|
||||||
|
|
||||||
|
rustTarget = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
|
||||||
|
unstableRustTarget = pkgs.rust-bin.selectLatestNightlyWith (
|
||||||
|
toolchain:
|
||||||
|
toolchain.default.override {
|
||||||
|
extensions = [
|
||||||
|
"rust-src"
|
||||||
|
"miri"
|
||||||
|
"rustfmt"
|
||||||
|
];
|
||||||
|
}
|
||||||
|
);
|
||||||
|
craneLib = (inputs.crane.mkLib pkgs).overrideToolchain rustTarget;
|
||||||
|
unstableCraneLib = (inputs.crane.mkLib pkgs).overrideToolchain unstableRustTarget;
|
||||||
|
|
||||||
|
tomlInfo = craneLib.crateNameFromCargoToml { cargoToml = ./Cargo.toml; };
|
||||||
|
inherit (tomlInfo) version;
|
||||||
|
src = ./.;
|
||||||
|
|
||||||
|
rustfmt' = pkgs.writeShellScriptBin "rustfmt" ''
|
||||||
|
exec "${unstableRustTarget}/bin/rustfmt" "$@"
|
||||||
|
'';
|
||||||
|
|
||||||
|
cargoArtifacts = craneLib.buildDepsOnly {
|
||||||
|
inherit src;
|
||||||
|
cargoExtraArgs = "--all-features --all";
|
||||||
|
};
|
||||||
|
|
||||||
|
crate = craneLib.buildPackage {
|
||||||
|
inherit cargoArtifacts src version;
|
||||||
|
cargoExtraArgs = "--all-features --all";
|
||||||
|
};
|
||||||
|
|
||||||
|
in
|
||||||
|
rec {
|
||||||
|
checks = {
|
||||||
|
inherit crate;
|
||||||
|
|
||||||
|
crate-clippy = craneLib.cargoClippy {
|
||||||
|
inherit cargoArtifacts src;
|
||||||
|
cargoExtraArgs = "--all --all-features";
|
||||||
|
cargoClippyExtraArgs = "-- --deny warnings";
|
||||||
|
};
|
||||||
|
|
||||||
|
crate-fmt = unstableCraneLib.cargoFmt {
|
||||||
|
inherit src;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
packages.crate = crate;
|
||||||
|
packages.default = packages.crate;
|
||||||
|
|
||||||
|
apps.crate = inputs.flake-utils.lib.mkApp {
|
||||||
|
name = "library";
|
||||||
|
drv = crate;
|
||||||
|
};
|
||||||
|
apps.default = apps.crate;
|
||||||
|
|
||||||
|
devShells.default = devShells.crate;
|
||||||
|
devShells.crate = pkgs.mkShell {
|
||||||
|
buildInputs = [ ];
|
||||||
|
|
||||||
|
nativeBuildInputs = [
|
||||||
|
rustfmt'
|
||||||
|
rustTarget
|
||||||
|
];
|
||||||
|
};
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
2
rust-toolchain.toml
Normal file
2
rust-toolchain.toml
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
[toolchain]
|
||||||
|
channel = "1.82.0"
|
||||||
3
rustfmt.toml
Normal file
3
rustfmt.toml
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
imports_granularity = "Item"
|
||||||
|
reorder_imports = true
|
||||||
|
group_imports = "StdExternalCrate"
|
||||||
Loading…
Add table
Add a link
Reference in a new issue