Skip to content

Commit

Permalink
Add Nix dev shell and direnv support
Browse files Browse the repository at this point in the history
  • Loading branch information
ryze312 committed May 24, 2024
1 parent 1eca609 commit 216688e
Show file tree
Hide file tree
Showing 6 changed files with 115 additions and 0 deletions.
1 change: 1 addition & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
use flake
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/target
/.direnv
65 changes: 65 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 32 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
inputs = {
nixpkgs.url = "nixpkgs/nixpkgs-unstable";

fenix = {
url = "github:nix-community/fenix";
inputs.nixpkgs.follows = "nixpkgs";
};
};

outputs = { self, nixpkgs, fenix }:
let
overlays = [ fenix.overlays.default ];

getPkgsFor = (system: import nixpkgs {
inherit system overlays;
});

forEachSystem = func: nixpkgs.lib.genAttrs [
"x86_64-linux"
"aarch64-linux"

"aarch64-darwin"
"x86_64-darwin"
] (system: func (getPkgsFor system));

in {
devShells = forEachSystem (pkgs: {
default = pkgs.callPackage ./shell.nix {};
});
};
}
4 changes: 4 additions & 0 deletions rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[toolchain]
channel = "stable"
profile = "default"
targets = ["x86_64-unknown-linux-gnu", "aarch64-unknown-linux-gnu"]
12 changes: 12 additions & 0 deletions shell.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{ mkShell, fenix }:

let
toolchain = fenix.fromToolchainFile {
file = ./rust-toolchain.toml;
sha256 = "opUgs6ckUQCyDxcB9Wy51pqhd0MPGHUVbwRKKPGiwZU=";
};
in

mkShell {
packages = [ toolchain ];
}

0 comments on commit 216688e

Please sign in to comment.