From cfcdcc653ece95a31595bbd9a6882c4473edb1ab Mon Sep 17 00:00:00 2001 From: Rikki Date: Fri, 7 Mar 2025 18:01:32 +0800 Subject: [PATCH] =?UTF-8?q?update:=20=E6=9B=B4=E6=96=B0=E5=BC=80=E5=8F=91?= =?UTF-8?q?=E5=BF=85=E8=A6=81=E7=9A=84=E5=8C=85=EF=BC=8C=E4=BD=86=E6=98=AF?= =?UTF-8?q?=E5=9B=A0=E4=B8=BA=20nb-cli=20=E4=B8=8A=E6=B8=B8=E6=89=93?= =?UTF-8?q?=E5=8C=85=E4=B8=AD=E5=B9=B6=E6=9C=AA=E5=8C=85=E5=90=AB=20nonebo?= =?UTF-8?q?t2=EF=BC=8C=E5=9B=A0=E6=AD=A4=E7=9B=AE=E5=89=8D=E6=9C=AC?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E5=B9=B6=E4=B8=8D=E8=83=BD=E7=94=A8=E4=BA=8E?= =?UTF-8?q?=E8=BF=90=E8=A1=8C=E5=92=8C=E8=B0=83=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- flake.lock | 61 +++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 69 ++++++++++++++++++++++++++++++------------------------ 2 files changed, 100 insertions(+), 30 deletions(-) create mode 100644 flake.lock diff --git a/flake.lock b/flake.lock new file mode 100644 index 000000000..dd215f1c6 --- /dev/null +++ b/flake.lock @@ -0,0 +1,61 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1741196730, + "narHash": "sha256-0Sj6ZKjCpQMfWnN0NURqRCQn2ob7YtXTAOTwCuz7fkA=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "48913d8f9127ea6530a2a2f1bd4daa1b8685d8a3", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-24.11", + "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 index df885fd83..54737d640 100644 --- a/flake.nix +++ b/flake.nix @@ -1,52 +1,61 @@ { description = "MaiMBot Nix Dev Env"; + # 本配置仅方便用于开发,但是因为 nb-cli 上游打包中并未包含 nonebot2,因此目前本配置并不能用于运行和调试 inputs = { - nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.11"; flake-utils.url = "github:numtide/flake-utils"; }; - outputs = { self, nixpkgs, flake-utils }: - flake-utils.lib.eachDefaultSystem (system: + outputs = + { + self, + nixpkgs, + flake-utils, + }: + flake-utils.lib.eachDefaultSystem ( + system: let pkgs = import nixpkgs { inherit system; }; - # 读取 requirements.txt 文件 - requirementsFile = builtins.readFile ./requirements.txt; - - # 解析 requirements.txt 文件,提取包名 - parseRequirements = content: - let - lines = builtins.split "\n" content; - # 过滤掉空行和注释 - filteredLines = builtins.filter (line: - line != "" && !(builtins.match "^ *#.*" line) - ) lines; - # 提取包名(去掉版本号) - packageNames = builtins.map (line: - builtins.head (builtins.split "[=<>]" line) - ) filteredLines; - in - packageNames; - - # 获取 requirements.txt 中的包名列表 - requirements = parseRequirements requirementsFile; - - # 动态生成 Python 环境 - pythonEnv = pkgs.python3.withPackages (ps: - builtins.map (pkg: ps.${pkg}) requirements + pythonEnv = pkgs.python3.withPackages ( + ps: with ps; [ + pymongo + python-dotenv + pydantic + jieba + openai + aiohttp + requests + urllib3 + numpy + pandas + matplotlib + networkx + python-dateutil + APScheduler + loguru + tomli + customtkinter + colorama + pypinyin + pillow + setuptools + ] ); in { devShell = pkgs.mkShell { - buildInputs = [ pythonEnv ]; + buildInputs = [ + pythonEnv + pkgs.nb-cli + ]; shellHook = '' - echo "Python environment is ready!" ''; }; } ); -} \ No newline at end of file +}