98 lines
2.3 KiB
Nix
98 lines
2.3 KiB
Nix
{
|
|
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;
|
|
nativeBuildInputs = with pkgs; [
|
|
pkg-config
|
|
nix.dev
|
|
];
|
|
strictDeps = true;
|
|
};
|
|
cargoArtifacts = craneLib.buildDepsOnly commonArgs;
|
|
individualCrateArgs = commonArgs // {
|
|
inherit cargoArtifacts;
|
|
inherit (craneLib.crateNameFromCargoToml { inherit src; }) version;
|
|
};
|
|
|
|
fileSetForCrate =
|
|
crate:
|
|
lib.fileset.toSource {
|
|
root = ./.;
|
|
fileset = lib.fileset.unions [
|
|
./Cargo.toml
|
|
./Cargo.lock
|
|
];
|
|
};
|
|
server = craneLib.buildPackage (
|
|
individualCrateArgs
|
|
// {
|
|
}
|
|
);
|
|
in
|
|
{
|
|
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
|
|
];
|
|
};
|
|
|
|
}
|
|
);
|
|
|
|
}
|