Skip to content

chore: basic nixos develop environment with flake script #1213

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,10 @@ cppcheck.xml
compile_commands.json
/logs/
*.log

# Nix dev files
/.envrc
/.direnv/
/flake.nix
flake.lock
/default.nix
4 changes: 2 additions & 2 deletions kernel/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions tools/nix-dev-shell/envrc-flake
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# If you want to use this as an .envrc file to create a shell with necessary components
# to develop rustc, use the following command in the root of the rusr checkout:
#
# ln -s ./tools/nix-dev-shell/envrc-flake ./.envrc && nix flake update --flake ./tools/nix-dev-shell

if nix flake show path:./tools/nix-dev-shell &> /dev/null; then
use flake path:./tools/nix-dev-shell
fi
50 changes: 50 additions & 0 deletions tools/nix-dev-shell/flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
description = "dragonos-nix-dev";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
fenix.url = "github:nix-community/fenix";
fenix.inputs.nixpkgs.follows = "nixpkgs";
utils.url = "github:numtide/flake-utils";
};

outputs = { self, nixpkgs, fenix, utils, ... } @ inputs:
utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};
rustVer = fenix.packages.${system}.fromToolchainName {
name = "nightly-2024-11-05";
sha256 = "sha256-muM2tfsMpo2gsFsofhwHutPWgiPjjuwfBUvYCrwomAY=";
};
# 组合工具链并提取二进制路径
rustToolChain = rustVer.withComponents [
"cargo"
"clippy"
"rust-src"
"rustfmt"
"rust-analyzer"
];
in {
devShells.default = pkgs.mkShell {
# 基础工具链
buildInputs = with pkgs; [
git
llvm
libclang
rustToolChain
];

env = {
LIBCLANG_PATH = "${pkgs.libclang.lib}/lib";
};


# Shell启动脚本
shellHook = ''
'';
};

# 兼容旧版nix-shell命令
defaultPackage = self.devShells.${system}.default;
}
);
}