This commit is contained in:
wangfiox 2024-07-26 22:30:35 +08:00
parent b4a3cb98a8
commit a17a3c7314
2 changed files with 108 additions and 0 deletions

60
flake.lock Normal file
View File

@ -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
}

48
flake.nix Normal file
View File

@ -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 ];
};
});
}