update: 更新开发必要的包,但是因为 nb-cli 上游打包中并未包含 nonebot2,因此目前本配置并不能用于运行和调试
This commit is contained in:
61
flake.lock
generated
Normal file
61
flake.lock
generated
Normal file
@@ -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
|
||||
}
|
||||
69
flake.nix
69
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!"
|
||||
'';
|
||||
};
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user