diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..bc49353 --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use flake .# diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..b395df7 --- /dev/null +++ b/flake.lock @@ -0,0 +1,82 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1726560853, + "narHash": "sha256-X6rJYSESBVr3hBoH0WbKE5KvhPU5bloyZ2L4K60/fPQ=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "c1dfcf08411b08f6b8615f7d8971a2bfa81d5e8a", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1729880355, + "narHash": "sha256-RP+OQ6koQQLX5nw0NmcDrzvGL8HDLnyXt/jHhL1jwjM=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "18536bf04cd71abd345f9579158841376fdd0c5a", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs", + "rust-overlay": "rust-overlay" + } + }, + "rust-overlay": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1730255392, + "narHash": "sha256-9pydem8OVxa0TwjUai1PJe0yHAJw556CWCEwyoAq8Ik=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "7509d76ce2b3d22b40bd25368b45c0a9f7f36c89", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "rust-overlay", + "type": "github" + } + }, + "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..9a20a47 --- /dev/null +++ b/flake.nix @@ -0,0 +1,67 @@ +{ + description = "Only Provide the support of qemu"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + rust-overlay.url = "github:oxalica/rust-overlay"; + rust-overlay.inputs.nixpkgs.follows = "nixpkgs"; + flake-utils.url = "github:numtide/flake-utils"; + }; + + outputs = { self, nixpkgs, rust-overlay, flake-utils, ... }: + flake-utils.lib.eachDefaultSystem (system: + let + overlays = [ + (import rust-overlay) + (_: super: { + rust-toolchain = + let + rust = super.rust-bin; + in + if builtins.pathExists ./rust-toolchain.toml then + rust.fromRustupToolchainFile ./rust-toolchain.toml + else if builtins.pathExists ./rust-toolchain then + rust.fromRustupToolchainFile ./rust-toolchain + else + # rust.nightly.latest.default; + # The rust-toolchain when i make this file, which maybe change + (rust.nightly.latest.default.override { + extensions = [ "rust-src" "llvm-tools-preview" "rustfmt" "clippy" "cargo" ]; + targets = [ "x86_64-unknown-linux-gnu" ]; + }); + }) + ]; + pkgs = import nixpkgs { + inherit system overlays; + }; + in { + devShells.default = with pkgs; mkShell { + buildInputs = [ + # Require of repos + gnumake + + # Require of rust-overlay + openssl + pkg-config + eza + fd + + # Development Tools + ripgrep + zellij + fzf + + rust-toolchain + ]; + + shellHook = '' + alias ls=eza + alias find=fd + + export RUSTUP_DIST_SERVER=https://mirrors.ustc.edu.cn/rust-static + export RUSTUP_UPDATE_ROOT=https://mirrors.ustc.edu.cn/rust-static/rustup + ''; + }; + } + ); +}