Skip to content

Commit 71d3cde

Browse files
committed
feat: add nix flake (try 1)
1 parent f9f29fd commit 71d3cde

File tree

3 files changed

+104
-0
lines changed

3 files changed

+104
-0
lines changed

flake.lock

Lines changed: 46 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: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
{
2+
description = "Devmoji git log";
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 = {
13+
self,
14+
nixpkgs,
15+
rust-overlay,
16+
}: let
17+
supportedSystems = ["x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin"];
18+
forEachSupportedSystem = f:
19+
nixpkgs.lib.genAttrs supportedSystems (system:
20+
f {
21+
pkgs = import nixpkgs {
22+
inherit system;
23+
overlays = [rust-overlay.overlays.default self.overlays.default];
24+
};
25+
});
26+
in {
27+
overlays.default = final: prev: {
28+
rustToolchain = let
29+
rust = prev.rust-bin;
30+
in
31+
if builtins.pathExists ./rust-toolchain.toml
32+
then rust.fromRustupToolchainFile ./rust-toolchain.toml
33+
else if builtins.pathExists ./rust-toolchain
34+
then rust.fromRustupToolchainFile ./rust-toolchain
35+
else
36+
rust.stable.latest.default.override {
37+
extensions = ["rust-src" "rustfmt"];
38+
};
39+
};
40+
41+
devShells = forEachSupportedSystem ({pkgs}: {
42+
default = pkgs.mkShell {
43+
packages = with pkgs; [
44+
rustToolchain
45+
rust-analyzer
46+
];
47+
48+
env = {
49+
# Required by rust-analyzer
50+
RUST_SRC_PATH = "${pkgs.rustToolchain}/lib/rustlib/src/rust/library";
51+
};
52+
};
53+
});
54+
};
55+
}

rust-toolchain.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[toolchain]
2+
channel = "stable"
3+
components = [ "rust-analyzer" ]

0 commit comments

Comments
 (0)