flake.nix
44 lines · 1428 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 = { self, nixpkgs, flake-utils, rust-overlay, ... }:
12 flake-utils.lib.eachDefaultSystem (system:
13 let
14 # We only need the nightly overlay in the devShell because .rs files are formatted with nightly.
15 overlays = [ (import rust-overlay) ];
16 pkgs = import nixpkgs { inherit system overlays; };
17 rustNightly = pkgs.rust-bin.nightly."2024-03-08".default;
18 in
19 with pkgs;
20 {
21 packages.default = rustPlatform.buildRustPackage {
22 pname = "iamb";
23 version = self.shortRev or self.dirtyShortRev;
24 src = ./.;
25 cargoLock = {
26 lockFile = ./Cargo.lock;
27 };
28 nativeBuildInputs = [ pkg-config ];
29 buildInputs = [ openssl ] ++ lib.optionals stdenv.isDarwin
30 (with darwin.apple_sdk.frameworks; [ AppKit Security Cocoa]);
31 };
32
33 devShell = mkShell {
34 buildInputs = [
35 (rustNightly.override {
36 extensions = [ "rust-src" "rust-analyzer-preview" "rustfmt" "clippy" ];
37 })
38 pkg-config
39 cargo-tarpaulin
40 cargo-watch
41 ];
42 };
43 });
44}