flake.nix

47 lines · 1558 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            outputHashes = {
28              "keybindings-0.0.1" = "sha256-6gGviJF4/gzoPxgh0XJXXrhQoWxOTqyI9fwiOE+TY7s=";
29            };
30          };
31          nativeBuildInputs = [ pkg-config ];
32          buildInputs = [ openssl ] ++ lib.optionals stdenv.isDarwin
33            (with darwin.apple_sdk.frameworks; [ AppKit Security ]);
34        };
35
36        devShell = mkShell {
37          buildInputs = [
38            (rustNightly.override {
39              extensions = [ "rust-src" "rust-analyzer-preview" "rustfmt" "clippy" ];
40            })
41            pkg-config
42            cargo-tarpaulin
43            cargo-watch
44          ];
45        };
46      });
47}