cover/flake.nix

71 lines
2.3 KiB
Nix
Raw Normal View History

2023-04-17 22:22:35 +00:00
{
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
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
;
rustfmt = pkgs.rustfmt.overrideAttrs (old: {
preFixup = pkgs.lib.optionalString pkgs.stdenv.isDarwin ''
install_name_tool -add_rpath "${pkgs.rustc}/lib" "$out/bin/rustfmt"
'';
});
};
};
};
};
}