botoh/flake.nix

82 lines
2.1 KiB
Nix
Raw Normal View History

2024-05-14 22:31:32 -04:00
{
inputs = {
systems.url = "github:nix-systems/default-linux";
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
fenix.url = "github:nix-community/fenix/monthly";
pre-commit-hooks.url = "github:cachix/pre-commit-hooks.nix";
};
outputs = {
self,
systems,
nixpkgs,
fenix,
pre-commit-hooks,
}: let
eachSystem = nixpkgs.lib.genAttrs (import systems);
pkgsFor = eachSystem (system:
import nixpkgs {
localSystem.system = system;
overlays = [fenix.overlays.default];
});
in {
packages = eachSystem (system: let
pkgs = nixpkgs.legacyPackages.${system};
inherit ((builtins.fromTOML (builtins.readFile ./Cargo.toml)).package) version;
in {
default = pkgsFor.${system}.rustPlatform.buildRustPackage {
pname = "botoh";
version = "${version}";
src = self;
cargoLock = {
2024-06-07 22:00:43 -04:00
lockFile = ./Cargo.lock;
2024-05-14 22:31:32 -04:00
};
nativeBuildInputs = with pkgs; [pkg-config];
buildInputs = with pkgs; [openssl];
doCheck = false;
};
});
checks = eachSystem (system: {
pre-commit-check = pre-commit-hooks.lib.${system}.run {
src = ./.;
hooks = {
# rust
rustfmt.enable = true;
2024-06-07 15:20:29 -04:00
clippy.enable = false;
2024-05-14 22:41:25 -04:00
taplo.enable = true;
2024-05-14 22:31:32 -04:00
# nix
statix.enable = true;
alejandra.enable = true;
deadnix.enable = true;
};
};
});
devShells = eachSystem (system: {
default = pkgsFor.${system}.mkShell {
inherit (self.checks.${system}.pre-commit-check) shellHook;
packages = with pkgsFor.${system}; [
nil
alejandra
openssl
pkg-config
tokio-console
2024-12-14 12:07:29 -05:00
cargo
rustc
clippy
rustfmt
rust-analyzer
2024-05-14 22:31:32 -04:00
];
RUST_BACKTRACE = 1;
2024-06-16 08:45:57 -04:00
RUST_LOG = "info";
2024-05-14 22:31:32 -04:00
RUST_SRC_PATH = "${fenix.packages.${system}.complete.rust-src}/lib/rustlib/src/rust/library";
RUSTFLAGS = "--cfg tokio_unstable";
2024-05-14 22:31:32 -04:00
};
});
nixosModules.default = import ./nix/module.nix {inherit self;};
};
}