Skip to content

Commit e025f0d

Browse files
committed
add nix flake
1 parent 9de9e0d commit e025f0d

File tree

4 files changed

+153
-14
lines changed

4 files changed

+153
-14
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 & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,2 @@
1-
# Generated by Cargo
2-
# will have compiled files and executables
3-
/target/
4-
5-
# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
6-
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
7-
Cargo.lock
8-
9-
# These are backup files generated by rustfmt
10-
**/*.rs.bk
11-
12-
**/.idea/*
13-
14-
**/main.rs
1+
target/**
2+
.direnv/**

flake.lock

Lines changed: 100 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: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
{
2+
inputs = {
3+
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
4+
fenix.url = "github:nix-community/fenix";
5+
fenix.inputs.nixpkgs.follows = "nixpkgs";
6+
flake-utils.url = "github:numtide/flake-utils";
7+
};
8+
9+
outputs =
10+
{
11+
nixpkgs,
12+
fenix,
13+
flake-utils,
14+
...
15+
}:
16+
flake-utils.lib.eachDefaultSystem (
17+
system:
18+
let
19+
pkgs = import nixpkgs {
20+
inherit system;
21+
};
22+
23+
# https://github.com/nix-community/fenix/issues/178
24+
cargo = fenix.packages.${system}.stable.cargo.overrideAttrs (old: {
25+
postBuild = pkgs.lib.optionalString pkgs.stdenv.isDarwin ''
26+
cargo="./cargo/bin/cargo"
27+
install_name_tool \
28+
-change "/usr/lib/libcurl.4.dylib" "${pkgs.curl.out}/lib/libcurl.4.dylib" \
29+
"$cargo"
30+
'';
31+
});
32+
rustToolchain =
33+
with fenix.packages.${system};
34+
combine [
35+
cargo
36+
stable.rustc
37+
stable.clippy
38+
stable.rustfmt
39+
];
40+
in
41+
{
42+
devShells.default = pkgs.mkShell {
43+
buildInputs = with pkgs; [
44+
rustToolchain
45+
rust-analyzer
46+
];
47+
};
48+
}
49+
);
50+
}

0 commit comments

Comments
 (0)