feat: Rust skeleton

(cherry picked from commit 41a09289cda3137f96c69c69c924af34f0e64865)
This commit is contained in:
Robert Hensing 2024-02-08 16:58:45 +01:00
parent bfa3b3a063
commit a4bdbe5618
9 changed files with 264 additions and 22 deletions

View file

@ -3,7 +3,9 @@
inputs = {
flake-parts.url = "github:hercules-ci/flake-parts";
flake-parts.inputs.nixpkgs.follows = "nixpkgs";
flake-parts.inputs.nixpkgs-lib.follows = "nixpkgs";
nix-cargo-integration.url = "github:yusdacra/nix-cargo-integration";
nix-cargo-integration.inputs.nixpkgs.follows = "nixpkgs";
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
pre-commit-hooks-nix.url = "github:cachix/pre-commit-hooks.nix";
pre-commit-hooks-nix.inputs.nixpkgs.follows = "nixpkgs";
@ -12,14 +14,27 @@
outputs = inputs@{ self, flake-parts, ... }:
flake-parts.lib.mkFlake
{ inherit inputs; }
{
({ lib, ... }: {
imports = [
inputs.pre-commit-hooks-nix.flakeModule
inputs.nix-cargo-integration.flakeModule
./rust/nci.nix
];
systems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
perSystem = { config, self', inputs', pkgs, ... }: {
pre-commit.settings.hooks.nixpkgs-fmt.enable = true;
pre-commit.settings.hooks.rustfmt.enable = true;
# Override to pass `--all`
pre-commit.settings.hooks.rustfmt.entry = lib.mkForce "${pkgs.rustfmt}/bin/cargo-fmt fmt --all --manifest-path ./rust/Cargo.toml -- --color always";
devShells.default = pkgs.mkShell {
inputsFrom = [ config.nci.outputs.nix-bindings.devShell ];
nativeBuildInputs = [
pkgs.rust-analyzer
pkgs.nixpkgs-fmt
pkgs.rustfmt
];
shellHook = ''
${config.pre-commit.installationScript}
echo 1>&2 "Welcome to the development shell!"
@ -27,5 +42,5 @@
};
};
flake = { };
};
});
}