From 0c930271235ab88f4cd8d2773223cd035f5cdf31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A1=9E=E9=A9=AC?= Date: Thu, 9 Oct 2025 16:55:49 +0800 Subject: [PATCH] init --- .envrc | 1 + .gitignore | 3 + LICENSE | 21 ++++++ README.md | 116 ++++++++++++++++++++++++++++++++ com/default.nix | 4 ++ com/github/default.nix | 4 ++ com/github/ksdme/default.nix | 4 ++ com/github/ksdme/ut/package.nix | 26 +++++++ default.nix | 1 + flake.lock | 62 +++++++++++++++++ flake.nix | 47 +++++++++++++ treefmt.nix | 4 ++ 12 files changed, 293 insertions(+) create mode 100644 .envrc create mode 100644 .gitignore create mode 100644 LICENSE create mode 100644 README.md create mode 100644 com/default.nix create mode 100644 com/github/default.nix create mode 100644 com/github/ksdme/default.nix create mode 100644 com/github/ksdme/ut/package.nix create mode 100644 default.nix create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 treefmt.nix diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..8392d15 --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use flake \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3c1eec2 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +.direnv +test +result \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..24de9bd --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2025 Kilari Teja + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..632353e --- /dev/null +++ b/README.md @@ -0,0 +1,116 @@ +# T-Packs T 老师精选软件 + +T-Packs 是一个使用 Nix 构建系统管理的精选软件包集合,旨在提供高质量、实用的开发工具和实用程序。 + +## 🚀 项目特点 + +- 使用 Nix Flakes 管理依赖和构建过程 +- 包含精选的开发工具和实用程序 +- 提供统一的配置和安装方式 +- 支持 NixOS 模块集成 + +## 📦 包含的软件包 + +### ut - 开发者工具盒 + +`ut` 是一个基于 Rust 开发的开发者工具盒,灵感来自 [it-tools.tech](https://it-tools.tech)。 + +- 轻量级、高性能的命令行工具 +- 提供多种实用功能 +- 开源 (MIT 许可证) + +## 🛠️ 快速开始 + +### 前提条件 + +确保您已安装 Nix 包管理器,并启用了 Flakes 支持。 + +### 使用方法 + +#### 作为依赖引入 + +在您的 flake.nix 中添加: + +```nix +{ inputs.t-packs.url = "github:your-username/t-packs"; + + outputs = { self, nixpkgs, t-packs }: { + # 使用 t-packs 中的包 + yourPackage = t-packs.packages.${system}.com.github.ksdme.ut; + }; +} +``` + +#### 在 NixOS 中使用 + +在您的 NixOS 配置中导入模块: + +```nix +{ config, pkgs, ... }: +{ + imports = [ + t-packs.nixosModules.default + ]; + + # 配置相关服务 +} +``` + +#### 开发环境 + +进入开发环境: + +```bash +nix develop +``` + +这将提供以下开发工具: +- `tokei` - 代码统计工具 +- `nil` - Nix 语言服务器 + +## 📋 项目结构 + +``` +├── com/ # 软件包定义 +│ └── github/ # GitHub 来源的包 +│ └── ksdme/ # 作者 ksdme 的包 +│ └── ut/ # ut 工具包 +├── default.nix # 默认包定义 +├── flake.nix # Flake 配置 +├── flake.lock # 依赖锁定文件 +├── treefmt.nix # 代码格式化配置 +└── README.md # 项目说明文档 +``` + +## 📝 开发指南 + +### 格式化代码 + +使用 treefmt 格式化项目代码: + +```bash +nix fmt +``` + +### 添加新软件包 + +1. 在适当的目录下创建新的 Nix 文件 +2. 在 default.nix 或 flake.nix 中添加相应的导入和配置 +3. 运行 `nix flake update` 更新依赖 + +## 📄 许可证 + +[MIT License](LICENSE) + +## 👨‍🏫 关于 T 老师 + +T 老师精选软件 (T-Packs) 是由 T 老师精心挑选和维护的实用软件集合,旨在为开发者提供高质量、易于使用的工具。 + +## 🤝 贡献指南 + +欢迎提交 Issue 和 Pull Request 来改进这个项目! + +--- + +*使用 Nix,让软件管理更简单!* + \ No newline at end of file diff --git a/com/default.nix b/com/default.nix new file mode 100644 index 0000000..b7af160 --- /dev/null +++ b/com/default.nix @@ -0,0 +1,4 @@ +{ pkgs, ... }: +{ + github = import ./github { inherit pkgs; }; +} diff --git a/com/github/default.nix b/com/github/default.nix new file mode 100644 index 0000000..dd2affb --- /dev/null +++ b/com/github/default.nix @@ -0,0 +1,4 @@ +{ pkgs, ... }: +{ + ksdme = import ./ksdme { inherit pkgs; }; +} diff --git a/com/github/ksdme/default.nix b/com/github/ksdme/default.nix new file mode 100644 index 0000000..fc3c759 --- /dev/null +++ b/com/github/ksdme/default.nix @@ -0,0 +1,4 @@ +{ pkgs, ... }: +{ + ut = pkgs.callPackage ./ut/package.nix { }; +} \ No newline at end of file diff --git a/com/github/ksdme/ut/package.nix b/com/github/ksdme/ut/package.nix new file mode 100644 index 0000000..dbc5317 --- /dev/null +++ b/com/github/ksdme/ut/package.nix @@ -0,0 +1,26 @@ +{ + rustPlatform, + fetchFromGitHub, + lib, + ... +}: +rustPlatform.buildRustPackage rec { + pname = "ut"; + version = "0.2.0"; + + src = fetchFromGitHub { + owner = "ksdme"; + repo = "ut"; + tag = "v${version}"; + hash = "sha256-+dKDLBgmwhc9LnXTDgtqGxcFxgu4cdkauY6X5FpE3+8="; + }; + + cargoHash = "sha256-jWSp0NzeXQu38fAaZ8eTqVN+uvpn6v5xgoi3N5SCQoc="; + + meta = with lib; { + description = "A Rust based utilty toolbox for developers. Inspired from https://it-tools.tech"; + homepage = "https://github.com/ksdme/ut"; + license = licenses.mit; + platforms = platforms.all; + }; +} \ No newline at end of file diff --git a/default.nix b/default.nix new file mode 100644 index 0000000..ffcd441 --- /dev/null +++ b/default.nix @@ -0,0 +1 @@ +{ } diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..f261aec --- /dev/null +++ b/flake.lock @@ -0,0 +1,62 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1759917807, + "narHash": "sha256-WoSazth5EXIJmveWf0zbTMycrgpbLYOth6KhmltMuv0=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "fb5cf53218b987f2703a5bbc292a030c0fe33443", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1754340878, + "narHash": "sha256-lgmUyVQL9tSnvvIvBp7x1euhkkCho7n3TMzgjdvgPoU=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "cab778239e705082fe97bb4990e0d24c50924c04", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs", + "treefmt-nix": "treefmt-nix" + } + }, + "treefmt-nix": { + "inputs": { + "nixpkgs": "nixpkgs_2" + }, + "locked": { + "lastModified": 1758728421, + "narHash": "sha256-ySNJ008muQAds2JemiyrWYbwbG+V7S5wg3ZVKGHSFu8=", + "owner": "numtide", + "repo": "treefmt-nix", + "rev": "5eda4ee8121f97b218f7cc73f5172098d458f1d1", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "treefmt-nix", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..87634fd --- /dev/null +++ b/flake.nix @@ -0,0 +1,47 @@ +{ + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + treefmt-nix.url = "github:numtide/treefmt-nix"; + }; + + outputs = + { + self, + nixpkgs, + treefmt-nix, + ... + }: + let + system = "x86_64-linux"; + pkgs = import nixpkgs { inherit system; }; + treefmtEval = treefmt-nix.lib.evalModule pkgs ./treefmt.nix; + inherit (pkgs) mkShell; + in + { + formatter.${system} = treefmtEval.config.build.wrapper; + devShell."${system}" = mkShell { + nativeBuildInputs = with pkgs; [ + tokei + nil + ]; + }; + + packages."${system}" = { + com = import ./com { inherit pkgs; }; + }; + + nixosModules = + let + t-packs = self.packages."${system}"; + in + rec { + t-packs = + { config, lib, ... }: + { + imports = []; + }; + + default = t-packs; + }; + }; +} diff --git a/treefmt.nix b/treefmt.nix new file mode 100644 index 0000000..2e3d471 --- /dev/null +++ b/treefmt.nix @@ -0,0 +1,4 @@ +{ + projectRootFile = "flake.nix"; + programs.nixfmt.enable = true; +}