buscemi/flake.nix

68 lines
2.1 KiB
Nix

{
description = "FILL-ME-IN";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-parts.url = "github:hercules-ci/flake-parts";
crane.url = "github:ipetkov/crane";
crane.inputs.nixpkgs.follows = "nixpkgs";
pre-commit.url = "github:cachix/pre-commit-hooks.nix";
pre-commit.inputs.nixpkgs.follows = "nixpkgs";
};
outputs = inputs@{ self, flake-parts, crane, pre-commit, ... }:
flake-parts.lib.mkFlake { inherit inputs; } {
imports = [ pre-commit.flakeModule ];
systems = [
"aarch64-darwin"
"aarch64-linux"
"x86_64-darwin"
"x86_64-linux"
];
perSystem = { config, pkgs, system, ... }:
let
crane-lib = crane.lib.${system};
package = crane-lib.buildPackage {
src = crane-lib.cleanCargoSource ./.;
nativeBuildInputs = pkgs.lib.optionals pkgs.stdenv.isDarwin [ pkgs.libiconv ];
};
in
{
pre-commit.settings.hooks = {
rustfmt.enable = true;
clippy.enable = true;
cargo-check.enable = true;
};
checks = { inherit package; };
packages.default = package;
devShells.default = pkgs.mkShell {
shellHook = ''
${config.pre-commit.installationScript}
echo "welcome to your rust project ()" 1>&2
'';
inputsFrom = builtins.attrValues self.checks;
RUST_SRC_PATH = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}";
nativeBuildInputs = builtins.attrValues ({
inherit (pkgs)
cargo
cargo-watch
rustc
;
} // pkgs.lib.optionalAttrs pkgs.stdenv.isDarwin {
inherit (pkgs) libiconv;
inherit (pkgs.darwin.apple_sdk.frameworks) Security;
});
buildInputs = builtins.attrValues {
inherit (pkgs)
rust-analyzer
rustfmt
clippy
docker-client
;
};
};
};
};
}