flake.nix
67 lines · 1692 bytes
1{
2 description = "iamb";
3 nixConfig.bash-prompt = "\[nix-develop\]$ ";
4
5 inputs = {
6 nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
7 flake-utils.url = "github:numtide/flake-utils";
8 rust-overlay.url = "github:oxalica/rust-overlay";
9 };
10
11 outputs =
12 {
13 self,
14 nixpkgs,
15 flake-utils,
16 rust-overlay,
17 ...
18 }:
19 flake-utils.lib.eachDefaultSystem (
20 system:
21 let
22 # We only need the nightly overlay in the devShell because .rs files are formatted with nightly.
23 overlays = [ (import rust-overlay) ];
24 pkgs = import nixpkgs { inherit system overlays; };
25 rustNightly = pkgs.rust-bin.nightly."2025-08-31".default;
26 in
27 with pkgs;
28 {
29 packages.default = rustPlatform.buildRustPackage {
30 pname = "iamb";
31 version = self.shortRev or self.dirtyShortRev;
32 src = ./.;
33 cargoLock = {
34 lockFile = ./Cargo.lock;
35 };
36 nativeBuildInputs = [ pkg-config ];
37 buildInputs =
38 [ openssl ]
39 ++ lib.optionals stdenv.isDarwin (
40 with darwin.apple_sdk.frameworks;
41 [
42 AppKit
43 Security
44 Cocoa
45 ]
46 );
47 };
48
49 devShell = mkShell {
50 buildInputs = [
51 (rustNightly.override {
52 extensions = [
53 "rust-src"
54 "rust-analyzer-preview"
55 "rustfmt"
56 "clippy"
57 ];
58 })
59 pkg-config
60 cargo-tarpaulin
61 cargo-watch
62 sqlite
63 ];
64 };
65 }
66 );
67}