Skip to content

Commit 725db86

Browse files
committed
feat: nix flake
1 parent b50aa5b commit 725db86

File tree

4 files changed

+136
-0
lines changed

4 files changed

+136
-0
lines changed

.envrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
use flake

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
/target
2+
3+
.direnv

flake.lock

Lines changed: 80 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
{
2+
description = "A Nix-flake-based Rust development environment";
3+
4+
inputs = {
5+
nixpkgs.url = "https://flakehub.com/f/NixOS/nixpkgs/0.1.*.tar.gz";
6+
rust-overlay = {
7+
url = "github:oxalica/rust-overlay";
8+
inputs.nixpkgs.follows = "nixpkgs";
9+
};
10+
};
11+
12+
outputs = { self, nixpkgs, rust-overlay }:
13+
let
14+
overlays = [
15+
rust-overlay.overlays.default
16+
(final: prev: {
17+
rustToolchain =
18+
let
19+
rust = prev.rust-bin;
20+
in
21+
if builtins.pathExists ./rust-toolchain.toml then
22+
rust.fromRustupToolchainFile ./rust-toolchain.toml
23+
else if builtins.pathExists ./rust-toolchain then
24+
rust.fromRustupToolchainFile ./rust-toolchain
25+
else
26+
rust.stable.latest.default.override {
27+
extensions = [ "rust-src" "rustfmt" ];
28+
};
29+
})
30+
];
31+
supportedSystems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
32+
forEachSupportedSystem = f: nixpkgs.lib.genAttrs supportedSystems (system: f {
33+
pkgs = import nixpkgs { inherit overlays system; };
34+
});
35+
in
36+
{
37+
devShells = forEachSupportedSystem ({ pkgs }: {
38+
default = pkgs.mkShell {
39+
packages = with pkgs; [
40+
rustToolchain
41+
openssl
42+
pkg-config
43+
cargo-deny
44+
cargo-edit
45+
cargo-watch
46+
rhack
47+
rust-analyzer
48+
protobuf
49+
];
50+
};
51+
});
52+
};
53+
}

0 commit comments

Comments
 (0)