Skip to content

Commit

Permalink
chore: Setup nix devShell
Browse files Browse the repository at this point in the history
  • Loading branch information
bcyran committed Jul 7, 2024
1 parent 7b789bc commit b1b3389
Show file tree
Hide file tree
Showing 3 changed files with 105 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
48 changes: 48 additions & 0 deletions flake.lock

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

56 changes: 56 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
description = "A Nix-flake-based Rust development environment";

inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs.nixpkgs.follows = "nixpkgs";
};
};

outputs = {
self,
nixpkgs,
rust-overlay,
}: let
overlays = [
rust-overlay.overlays.default
(final: prev: {
rustToolchain = let
rust = prev.rust-bin;
in
if builtins.pathExists ./rust-toolchain.toml
then rust.fromRustupToolchainFile ./rust-toolchain.toml
else if builtins.pathExists ./rust-toolchain
then rust.fromRustupToolchainFile ./rust-toolchain
else
rust.stable.latest.default.override {
extensions = ["rust-src" "rustfmt"];
};
})
];
supportedSystems = ["x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin"];
forEachSupportedSystem = f:
nixpkgs.lib.genAttrs supportedSystems (system:
f {
pkgs = import nixpkgs {inherit overlays system;};
});
in {
devShells = forEachSupportedSystem ({pkgs}: {
default = pkgs.mkShell {
packages = with pkgs; [
(rustToolchain.override {extensions = ["llvm-tools-preview"];})
cargo-edit
cargo-watch
cargo-llvm-cov
rust-analyzer
just
];
buildInputs = with pkgs; [
libheif
];
};
});
};
}

0 comments on commit b1b3389

Please sign in to comment.