Files
squad-quote-store/flake.nix
2026-02-18 18:14:12 -06:00

109 lines
2.8 KiB
Nix

{
description = "Rust tool";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
flake-parts.url = "github:hercules-ci/flake-parts";
treefmt-nix = {
url = "github:numtide/treefmt-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
crane.url = "github:ipetkov/crane";
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = {
nixpkgs,
flake-parts,
treefmt-nix,
crane,
rust-overlay,
...
} @ inputs:
flake-parts.lib.mkFlake {inherit inputs;} {
imports = [
treefmt-nix.flakeModule
];
systems = ["aarch64-linux" "x86_64-linux" "aarch64-darwin" "x86_64-darwin"];
perSystem = {system, ...}: let
src = craneLib.cleanCargoSource ./.;
# runtime dependencies
buildInputs = with pkgs; [
# openssl
];
# build dependencies
nativeBuildInputs = with pkgs; [
# pkg-config
];
pkgs = import nixpkgs {
inherit system;
overlays = [(import rust-overlay)];
};
craneLib = (crane.mkLib pkgs).overrideToolchain (
p:
p.rust-bin.stable.latest.default.override {
targets = ["wasm32-unknown-unknown"];
}
);
# Build *just* the cargo dependencies, so we can reuse
# all of that work (e.g. via cachix) when running in CI
cargoArtifacts = craneLib.buildDepsOnly {
inherit src buildInputs nativeBuildInputs;
};
in rec {
# Dev Shell that lets you enter an environment with all the necessary utilites
# Available through 'nix develop'
# Also can be activated automatically if direnv is installed on the system with 'direnv allow'
devShells.default = craneLib.devShell {
inherit checks;
# extra tooling dependencies
packages = with pkgs; [
rust-analyzer
dioxus-cli
];
inputsFrom = [packages.default];
};
# Formatter for nix files, available through 'nix fmt'
treefmt = {
programs.alejandra.enable = true;
programs.rustfmt = {
enable = true;
edition = (builtins.fromTOML (builtins.readFile "${src}/Cargo.toml")).package.edition;
};
};
# Your custom packages
# Accessible through 'nix build', 'nix shell', 'nix run', etc
packages = {
default = craneLib.buildPackage {
inherit src buildInputs nativeBuildInputs cargoArtifacts;
};
};
checks = {
clippy = craneLib.cargoClippy {
inherit src buildInputs nativeBuildInputs cargoArtifacts;
cargoClippyExtraArgs = "-- --deny warnings";
};
};
};
};
}