diff options
Diffstat (limited to 'templates/rust/flake.nix')
| -rw-r--r-- | templates/rust/flake.nix | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/templates/rust/flake.nix b/templates/rust/flake.nix new file mode 100644 index 0000000..be1a8df --- /dev/null +++ b/templates/rust/flake.nix @@ -0,0 +1,61 @@ +{ + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + rust-overlay.url = "github:oxalica/rust-overlay"; + flake-utils.url = "github:numtide/flake-utils"; + }; + + outputs = + { + self, + nixpkgs, + rust-overlay, + flake-utils, + ... + }: + flake-utils.lib.eachDefaultSystem ( + system: + let + overlays = [ (import rust-overlay) ]; + pkgs = import nixpkgs { inherit system overlays; }; + rustToolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml; + rustPlatform = pkgs.makeRustPlatform { + cargo = rustToolchain; + rustc = rustToolchain; + }; + rustWithSrc = rustToolchain.override { + extensions = [ + "rust-analyzer" + "rust-src" + ]; + }; + deps = [ pkgs.openssl.dev ]; + in + with pkgs; + { + defaultPackage = rustPlatform.buildRustPackage { + name = "introvert"; + src = ./.; + cargoLock = { + lockFileContents = builtins.readFile ./Cargo.lock; + }; + buildInputs = deps; + nativeBuildInputs = [ pkgs.pkg-config ]; + }; + devShells.default = mkShell { + buildInputs = [ + rustWithSrc + sccache + cargo-make + lldb + ] + ++ deps; + nativeBuildInputs = [ pkg-config ]; + shellHook = '' + export RUSTC_WRAPPER="${sccache}/bin/sccache" + ''; + }; + formatter = alejandra; + } + ); +} |
