{ description = "A very basic flake"; inputs = { nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable"; crane.url = "github:ipetkov/crane"; flake-utils.url = "github:numtide/flake-utils"; rust-overlay = { url = "github:oxalica/rust-overlay"; inputs.nixpkgs.follows = "nixpkgs"; }; }; outputs = { nixpkgs, crane, flake-utils, rust-overlay, ... }: flake-utils.lib.eachDefaultSystem ( system: let pkgs = import nixpkgs { inherit system; overlays = [ (import rust-overlay) ]; }; inherit (pkgs) lib; craneLib = (crane.mkLib pkgs).overrideToolchain ( p: p.rust-bin.nightly.latest.default.override { extensions = [ "rustc-codegen-cranelift-preview" "rust-analyzer" "rust-src" ]; } ); src = craneLib.cleanCargoSource ./.; commonArgs = { inherit src; strictDeps = true; cargoArtifacts = craneLib.buildDepsOnly commonArgs; }; app = craneLib.buildPackage (commonArgs); in { packages.default = app; devShells.default = craneLib.devShell { inherit (commonArgs) nativeBuildInputs; RUSTFLAGS = "-Clinker=clang -Clink-arg=-fuse-ld=mold -Z macro-backtrace"; RUST_LOG = "debug,sqlx=warn"; packages = with pkgs; [ mold heaptrack llvmPackages.clang llvmPackages.lld sea-orm-cli watchexec cargo-watch cargo-edit cargo-nextest cargo-valgrind pkg-config # nix.dev boost.dev ]; }; } ); }