Skip to content

Commit 3c2dc9e

Browse files
committed
Add nix flake for a development shell
1 parent 3ac603e commit 3c2dc9e

File tree

3 files changed

+147
-0
lines changed

3 files changed

+147
-0
lines changed

.envrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
use flake

flake.lock

+96
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
{
2+
description = "Rust dev environment for Panamax";
3+
4+
inputs = {
5+
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
6+
rust-overlay.url = "github:oxalica/rust-overlay";
7+
};
8+
9+
outputs = { self, nixpkgs, rust-overlay }:
10+
let
11+
overlays = [
12+
rust-overlay.overlays.default
13+
(final: prev: {
14+
rustToolchain =
15+
let
16+
rust = prev.rust-bin;
17+
in
18+
if builtins.pathExists ./rust-toolchain.toml then
19+
rust.fromRustupToolchainFile ./rust-toolchain.toml
20+
else if builtins.pathExists ./rust-toolchain then
21+
rust.fromRustupToolchainFile ./rust-toolchain
22+
else
23+
rust.stable.latest.default.override {
24+
extensions = [ "rust-src" ];
25+
targets = [ "x86_64-unknown-linux-gnu" "wasm32-unknown-unknown" ];
26+
};
27+
})
28+
];
29+
supportedSystems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
30+
forEachSupportedSystem = f: nixpkgs.lib.genAttrs supportedSystems (system: f {
31+
pkgs = import nixpkgs { inherit overlays system; };
32+
});
33+
in
34+
{
35+
devShells = forEachSupportedSystem ({ pkgs }: {
36+
default = pkgs.mkShell {
37+
packages = with pkgs; [
38+
rustToolchain
39+
openssl
40+
pkg-config
41+
libgit2
42+
cargo-deny
43+
cargo-edit
44+
cargo-watch
45+
rust-analyzer
46+
];
47+
};
48+
});
49+
};
50+
}

0 commit comments

Comments
 (0)