flake.nix 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. {
  2. description = "dragonos-nix-dev";
  3. inputs = {
  4. nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
  5. fenix.url = "github:nix-community/fenix";
  6. fenix.inputs.nixpkgs.follows = "nixpkgs";
  7. utils.url = "github:numtide/flake-utils";
  8. };
  9. outputs = { self, nixpkgs, fenix, utils, ... } @ inputs:
  10. utils.lib.eachDefaultSystem (system:
  11. let
  12. pkgs = nixpkgs.legacyPackages.${system};
  13. rustVer = fenix.packages.${system}.fromToolchainName {
  14. name = "nightly-2024-11-05";
  15. sha256 = "sha256-muM2tfsMpo2gsFsofhwHutPWgiPjjuwfBUvYCrwomAY=";
  16. };
  17. # 组合工具链并提取二进制路径
  18. rustToolChain = rustVer.withComponents [
  19. "cargo"
  20. "clippy"
  21. "rust-src"
  22. "rustfmt"
  23. "rust-analyzer"
  24. ];
  25. in {
  26. devShells.default = pkgs.mkShell {
  27. # 基础工具链
  28. buildInputs = with pkgs; [
  29. git
  30. llvm
  31. libclang
  32. rustToolChain
  33. ];
  34. env = {
  35. LIBCLANG_PATH = "${pkgs.libclang.lib}/lib";
  36. };
  37. # Shell启动脚本
  38. shellHook = ''
  39. '';
  40. };
  41. # 兼容旧版nix-shell命令
  42. defaultPackage = self.devShells.${system}.default;
  43. }
  44. );
  45. }