commit 195e3fcce6c27b877f6a5116d10224b615cc1440 Author: Daan Vanoverloop Date: Sat Jul 1 14:00:43 2023 +0200 Initial commit diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..747c648 --- /dev/null +++ b/flake.nix @@ -0,0 +1,44 @@ +{ + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs"; # also valid: "nixpkgs" + rust-overlay.url = "github:oxalica/rust-overlay"; # A helper for Rust + Nix + }; + + outputs = { nixpkgs }: + let + # Overlays enable you to customize the Nixpkgs attribute set + overlays = [ + # Makes a `rust-bin` attribute available in Nixpkgs + (import rust-overlay) + # Provides a `rustToolchain` attribute for Nixpkgs that we can use to + # create a Rust environment + (self: super: { + rustToolchain = super.rust-bin.stable.latest.default; + }) + ]; + + # Systems supported + allSystems = [ + "x86_64-linux" # 64-bit Intel/AMD Linux + "aarch64-linux" # 64-bit ARM Linux + ]; + + # Helper to provide system-specific attributes + forAllSystems = f: nixpkgs.lib.genAttrs allSystems (system: f { + pkgs = import nixpkgs { inherit overlays system; }; + }); + in + { + # Development environment output + devShells = forAllSystems ({ pkgs }: { + rust = pkgs.mkShell { + # The Nix packages provided in the environment + packages = (with pkgs; [ + # The package provided by our custom overlay. Includes cargo, Clippy, cargo-fmt, + # rustdoc, rustfmt, and other tools. + rustToolchain + ]); + }; + }); + }; +}