3.6 kB
126 lines
1{
2 description = "future_form";
3
4 inputs = {
5 nixpkgs.url = "nixpkgs/nixos-25.11";
6 flake-utils.url = "github:numtide/flake-utils";
7 rust-overlay = {
8 url = "github:oxalica/rust-overlay";
9 inputs.nixpkgs.follows = "nixpkgs";
10 };
11 command-utils.url = "git+https://codeberg.org/expede/nix-command-utils";
12 };
13
14 outputs = {
15 self,
16 flake-utils,
17 nixpkgs,
18 rust-overlay,
19 command-utils,
20 } @ inputs:
21 flake-utils.lib.eachDefaultSystem (
22 system: let
23 overlays = [
24 (import rust-overlay)
25 ];
26
27 pkgs = import nixpkgs {
28 inherit system overlays;
29 config.allowUnfree = true;
30 };
31
32 rustVersion = "1.90.0";
33
34 rust-toolchain = (pkgs.rust-bin.stable.${rustVersion}.default.override {
35 extensions = [
36 "cargo"
37 "clippy"
38 "llvm-tools-preview"
39 "rust-src"
40 "rust-std"
41 "rustfmt"
42 ];
43
44 targets = [
45 "aarch64-apple-darwin"
46 "x86_64-apple-darwin"
47
48 "x86_64-unknown-linux-musl"
49 "aarch64-unknown-linux-musl"
50
51 "wasm32-unknown-unknown"
52 "thumbv6m-none-eabi"
53 ];
54 }).overrideAttrs (old: {
55 meta = (old.meta or {}) // { mainProgram = "cargo"; };
56 });
57
58 format-pkgs = with pkgs; [
59 nixpkgs-fmt
60 alejandra
61 taplo
62 ];
63
64 cargo-installs = with pkgs; [
65 cargo-deny
66 cargo-expand
67 cargo-outdated
68 cargo-sort
69 cargo-udeps
70 cargo-component
71 ];
72
73 # Command utils
74 rust = command-utils.rust.${system};
75 asModule = command-utils.asModule.${system};
76 cmd = command-utils.cmd.${system};
77 cargo = "${rust-toolchain}/bin/cargo";
78
79 menu = command-utils.commands.${system} [
80 (rust.test { cargo = rust-toolchain; cargo-watch = pkgs.cargo-watch; })
81 (rust.lint { cargo = rust-toolchain; })
82 (rust.fmt { cargo = rust-toolchain; })
83 (rust.build { cargo = rust-toolchain; })
84 (rust.doc { cargo = rust-toolchain; })
85 (rust.watch { cargo-watch = pkgs.cargo-watch; })
86 (rust.audit { cargo-audit = pkgs.cargo-audit; })
87 (rust.semver { cargo-semver-checks = pkgs.cargo-semver-checks; })
88 (rust.ci { cargo = rust-toolchain; })
89 (asModule {
90 "ffi:test" = cmd "Run FFI e2e tests (Go, Java, Python)"
91 "${cargo} test --workspace --test ffi_e2e -- --include-ignored --nocapture";
92 "ffi:test:example" = cmd "Run example crate unit tests"
93 "${cargo} test --manifest-path future_form_ffi/examples/counter_effects/counter_effects/Cargo.toml && ${cargo} test --manifest-path future_form_ffi/examples/key_value_store/kv_store/Cargo.toml";
94 })
95 ];
96
97 in rec {
98 devShells.default = pkgs.mkShell {
99 name = "future_form shell";
100
101 nativeBuildInputs = with pkgs;
102 [
103 rust-toolchain
104 rust-analyzer
105 ]
106 ++ menu
107 ++ format-pkgs
108 ++ cargo-installs;
109
110 shellHook = ''
111 unset SOURCE_DATE_EPOCH
112 export WORKSPACE_ROOT="$(pwd)"
113 menu
114 '';
115 };
116
117 devShells.ffi = pkgs.mkShell {
118 name = "future_form ffi shell";
119 inputsFrom = [devShells.default];
120 nativeBuildInputs = [pkgs.go pkgs.jdk pkgs.python3];
121 };
122
123 formatter = pkgs.alejandra;
124 }
125 );
126}