Shitty project scaffolding
1{
2 inputs = {
3 nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
4 rust-overlay.url = "github:oxalica/rust-overlay";
5 treefmt-nix = {
6 url = "github:numtide/treefmt-nix";
7 inputs.nixpkgs.follows = "nixpkgs";
8 };
9 };
10
11 outputs = {
12 self,
13 nixpkgs,
14 rust-overlay,
15 treefmt-nix,
16 ...
17 }: let
18 lib = nixpkgs.lib;
19 supportedSystems = ["x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin"];
20 forEachSupportedSystem = f:
21 lib.genAttrs supportedSystems (system:
22 f {
23 pkgs = import nixpkgs {
24 inherit system;
25 overlays = [(import rust-overlay)];
26 };
27 });
28 treefmtEval = forEachSupportedSystem ({pkgs}: treefmt-nix.lib.evalModule pkgs ./treefmt.nix);
29 in {
30 devShells = forEachSupportedSystem ({pkgs}: let
31 rustToolchain =
32 pkgs.rust-bin.fromRustupToolchainFile ./toolchain.toml;
33 in {
34 default = pkgs.mkShell {
35 packages = with pkgs; [
36 rustToolchain
37 rust-analyzer-unwrapped
38 ];
39 env = {
40 RUST_SRC_PATH = "${rustToolchain}/lib/rustlib/src/rust/library";
41 };
42 };
43 });
44
45 formatter = forEachSupportedSystem ({pkgs}: treefmtEval.${pkgs.stdenv.hostPlatform.system}.config.build.wrapper);
46
47 checks = forEachSupportedSystem ({pkgs}: {
48 formatting =
49 treefmtEval.${pkgs.stdenv.hostPlatform.system}.config.build.check self;
50 });
51 };
52}