From dd95456ec490d9119274f31e2f4fc4d1679477fc Mon Sep 17 00:00:00 2001 From: tzlil Date: Fri, 17 Feb 2023 13:25:23 +0200 Subject: initial commit --- flake.nix | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 flake.nix (limited to 'flake.nix') diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..ff46275 --- /dev/null +++ b/flake.nix @@ -0,0 +1,64 @@ + +{ + # XXX: Change project description + description = "Rust project"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-21.11"; + fenix = { + url = "github:nix-community/fenix"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + flake-utils.url = "github:numtide/flake-utils"; + }; + + outputs = { self, nixpkgs, fenix, flake-utils }: + flake-utils.lib.eachDefaultSystem + (system: + let + pkgs = nixpkgs.legacyPackages."${system}"; + + # XXX: Change target platform + rust-target = "x86_64-unknown-linux-gnu"; + rust-toolchain = with fenix.packages."${system}"; let + rust-toolchain-spec = { + # XXX: Change compiler version + # see `toolchainOf` https://github.com/nix-community/fenix + # for supported options + channel = "nightly"; + sha256 = "sha256-E4uFH1xyP6u3KhsYf3gnuqWyee61O9uoLLvBEIF1+ko="; + }; + # Toolchain for the builder + host-toolchain = toolchainOf rust-toolchain-spec; + # Toolchain for the platform where the binary will run + # target-toolchain = targets."${rust-target}".toolchainOf rust-toolchain-spec; + in + combine [ + # Build tools are taken from the host + host-toolchain.rustc + host-toolchain.cargo + host-toolchain.clippy + host-toolchain.rust-docs + # Standard library is taken from the target + host-toolchain.rust-std + host-toolchain.rust-src + ]; + in + { + devShells.default = pkgs.mkShell { + # XXX: Change to project name + name = "rust-project"; + + # Build tools + nativeBuildInputs = with pkgs; [ + rust-toolchain + rust-analyzer + rustfmt + ]; + + RUST_BACKTRACE = 1; + # CARGO_BUILD_TARGET = rust-target; + }; + devShell = self.devShells."${system}".default; + }); +} \ No newline at end of file -- cgit 1.4.1