From a17a3c7314f1ce33b60fd10dcd86f39b5b8cc8f0 Mon Sep 17 00:00:00 2001 From: wangfiox Date: Fri, 26 Jul 2024 22:30:35 +0800 Subject: [PATCH] :wrench: --- flake.lock | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 48 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 108 insertions(+) create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..15ce42c --- /dev/null +++ b/flake.lock @@ -0,0 +1,60 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1710146030, + "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1719899612, + "narHash": "sha256-8dHhS9LNyhWAgQfYs6QBlRB/Bvi+ilUfKoIO39U8faE=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "08683639c23b5daa3f603fee68218a1812842511", + "type": "github" + }, + "original": { + "owner": "NixOS", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..e12ccf8 --- /dev/null +++ b/flake.nix @@ -0,0 +1,48 @@ +{ + description = "Rust development environment with Clang and LLVM support"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs"; + flake-utils.url = "github:numtide/flake-utils"; + }; + + outputs = { self, nixpkgs, flake-utils }: + flake-utils.lib.eachDefaultSystem (system: + let + pkgs = import nixpkgs { inherit system; }; + overrides = builtins.fromTOML (builtins.readFile ./rust-toolchain.toml); + libPath = pkgs.lib.makeLibraryPath [ + # load external libraries that you need in your rust project here + "./sysy-data/" + ]; + in { + devShell = pkgs.mkShell { + buildInputs = with pkgs; [ + llvmPackages_16.bintools + llvmPackages_16.libllvm + llvmPackages_16.llvm + llvmPackages_16.stdenv + rocmPackages.llvm.polly + clang + rustup + glib + gcc + libxml2 + (with pkgsCross.riscv64; [ glib.stdenv.cc buildPackages.gdb ]) + qemu + ]; + + LD_LIBRARY_PATH = libPath; + + RUSTC_VERSION = overrides.toolchain.channel; + + shellHook = '' + export PATH=$PATH:''${CARGO_HOME:-~/.cargo}/bin + export PATH=$PATH:''${RUSTUP_HOME:-~/.rustup}/toolchains/$RUSTC_VERSION-x86_64-unknown-linux-gnu/bin/ + ''; + + # LIBCLANG_PATH = pkgs.lib.makeLibraryPath [ pkgs.llvmPackages_latest.libclang.lib ]; + + }; + }); +}