summary refs log tree commit diff
path: root/flake.nix
diff options
context:
space:
mode:
authortzlil <tzlils@protonmail.com>2023-02-17 13:25:23 +0200
committertzlil <tzlils@protonmail.com>2023-02-17 13:25:23 +0200
commitdd95456ec490d9119274f31e2f4fc4d1679477fc (patch)
tree77c85ed94970517f4ba0bf33bbed0c9e4a7785af /flake.nix
initial commit
Diffstat (limited to 'flake.nix')
-rw-r--r--flake.nix64
1 files changed, 64 insertions, 0 deletions
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