feat: add opencode, comment-checker packages; update README and flake.lock

- Add opencode and comment-checker to home packages
- Package comment-checker via prebuilt GitHub Releases binaries
- Register comment-checker overlay and flake packages output
- Add flake.lock to pin dependency versions
- Update README to match actual repo structure
- Add Node.js version notes in languages.nix
This commit is contained in:
2026-04-03 20:40:00 +08:00
parent b446c018aa
commit c73e36a1be
7 changed files with 246 additions and 15 deletions
+48 -12
View File
@@ -50,25 +50,61 @@ sudo nixos-rebuild switch --flake .#bare
```
├── flake.nix # 入口:输入源 + 输出配置
├── flake.lock # 依赖锁定文件(需手动生成)
├── hosts/
│ ├── wsl/default.nix # WSL:用户、WSL 设置
│ └── bare/default.nix # 裸机:引导、网络、硬件
├── modules/
│ ├── base.nix # 基础包(现代 CLI 工具)
│ ├── dev.nix # 开发工具链 + LSP
│ ├── docker.nix # Docker
│ ├── locale.nix # 区域 / 语言
│ └── shell.nix # Zsh 系统级启用
├── home/
── default.nix # Home Manager 入口
├── shell.nix # Zsh + 终端增强工具
└── git.nix # Git + Delta
│ ├── nixos/ # NixOS 专用模块
│ ├── base.nix # 基础包
│ ├── docker.nix # Docker 配置
│ ├── locale.nix # 区域 / 语言
│ └── default.nix # 入口
│ ├── darwin/ # macOS 专用模块(预留)
── shared/ # 共享模块
├── nix.nix # Nix 设置
└── default.nix # 入口
├── home/ # Home Manager 配置
│ ├── default.nix # 入口
│ ├── theme.nix # Catppuccin 主题
│ ├── dev/ # 开发工具
│ │ ├── neovim.nix
│ │ ├── languages.nix # 语言运行时、LSP
│ │ ├── git.nix
│ │ └── default.nix
│ └── shell/ # Shell 配置
│ ├── zsh.nix
│ ├── tmux.nix
│ ├── starship.nix
│ ├── tools.nix # fzf, atuin, zoxide 等
│ └── default.nix
├── lib/ # 辅助函数
│ └── default.nix
├── overlays/ # 自定义包覆盖
│ └── default.nix
├── pkgs/ # 自定义包(预留)
│ └── default.nix
└── scripts/
└── install.sh # 一键安装脚本
```
**配置层级**`hosts/*`(主机特定) → `modules/*`(共享系统) → `home/*`(用户级)
## 首次设置(重要)
### 生成 flake.lock
首次克隆仓库后,必须生成锁定文件以确保依赖版本一致:
```bash
cd ~/.config/nix-config
nix flake lock
git add flake.lock
git commit -m "Add flake.lock"
```
**为什么需要?** `flake.lock` 锁定所有输入(nixpkgs、home-manager 等)的确切版本,确保不同机器构建结果一致。
## 日常使用
```bash
@@ -100,7 +136,7 @@ let
### 添加包
编辑 `modules/base.nix``modules/dev.nix`,在 `environment.systemPackages` 中添加:
编辑 `modules/nixos/base.nix``home/dev/languages.nix`,在对应 `packages` 列表中添加:
```nix
environment.systemPackages = with pkgs; [
@@ -108,8 +144,8 @@ environment.systemPackages = with pkgs; [
];
```
> 查包名:`nix search nixpkgs <关键词>`
> 查包名:`nix search nixpkgs <关键词>` 或查看 [NixOS 包搜索](https://search.nixos.org/packages)
### 添加 Shell 别名
编辑 `home/shell.nix` 中的 `shellAliases`
编辑 `home/shell/zsh.nix` 中的 `shellAliases`
Generated
+128
View File
@@ -0,0 +1,128 @@
{
"nodes": {
"catppuccin": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1775213373,
"narHash": "sha256-wJHsijC2l/E+ovmlpPGha8pXA6RHSwHWmBV97gvkmyI=",
"owner": "catppuccin",
"repo": "nix",
"rev": "ba73719e673e7c2d89ac2f8df0bc0d48983e4907",
"type": "github"
},
"original": {
"owner": "catppuccin",
"repo": "nix",
"type": "github"
}
},
"flake-compat": {
"flake": false,
"locked": {
"lastModified": 1767039857,
"narHash": "sha256-vNpUSpF5Nuw8xvDLj2KCwwksIbjua2LZCqhV1LNRDns=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "5edf11c44bc78a0d334f6334cdaf7d60d732daab",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"home-manager": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1775143651,
"narHash": "sha256-S0RqAyDPMTcv9vASMaE8eY1QexFysAOdnxUxFHIPOyE=",
"owner": "nix-community",
"repo": "home-manager",
"rev": "d166a078541982a76f14d3e06e9665fa5c9ed85e",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "home-manager",
"type": "github"
}
},
"nix-darwin": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1775037210,
"narHash": "sha256-KM2WYj6EA7M/FVZVCl3rqWY+TFV5QzSyyGE2gQxeODU=",
"owner": "nix-darwin",
"repo": "nix-darwin",
"rev": "06648f4902343228ce2de79f291dd5a58ee12146",
"type": "github"
},
"original": {
"owner": "nix-darwin",
"repo": "nix-darwin",
"type": "github"
}
},
"nixos-wsl": {
"inputs": {
"flake-compat": "flake-compat",
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1774972752,
"narHash": "sha256-DnLIpFxznohpLkIFs390uZ0gxwkVyhtknhKNu+lQJK8=",
"owner": "nix-community",
"repo": "NixOS-WSL",
"rev": "d97e078f4788cddb8d11c3c99f72a4bb9ddec221",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "NixOS-WSL",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1775036866,
"narHash": "sha256-ZojAnPuCdy657PbTq5V0Y+AHKhZAIwSIT2cb8UgAz/U=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "6201e203d09599479a3b3450ed24fa81537ebc4e",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"catppuccin": "catppuccin",
"home-manager": "home-manager",
"nix-darwin": "nix-darwin",
"nixos-wsl": "nixos-wsl",
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}
+8
View File
@@ -73,6 +73,14 @@
};
};
# ── Packages ────────────────────────────────────────
packages = nixpkgs.lib.genAttrs [ "aarch64-darwin" "x86_64-linux" ] (system: {
comment-checker = (import nixpkgs {
inherit system;
overlays = [ self.overlays.default ];
}).comment-checker;
});
# ── Overlays ───────────────────────────────────────
overlays.default = import ./overlays;
};
+4
View File
@@ -47,6 +47,10 @@
nvd # nix version diff
nh # nix helper (nixos-rebuild wrapper)
# AI coding agent
opencode
comment-checker # AI code comment detection hook
# Misc
micro # simple editor fallback
];
+2
View File
@@ -3,6 +3,8 @@
{
home.packages = with pkgs; [
# ── Language runtimes ──
# Node.js: 默认跟随 nixpkgs,当前 unstable 为 v24.14.0
# 如需固定 LTS 版本,改为: nodejs_22 或 nodejs_20
nodejs
go
bun
+1 -3
View File
@@ -1,7 +1,5 @@
final: prev: {
# ── Custom overlays ──────────────────────────────────
# Override or extend nixpkgs packages here.
#
# Example:
# my-tool = final.callPackage ../pkgs/my-tool { };
comment-checker = final.callPackage ../pkgs/comment-checker { };
}
+55
View File
@@ -0,0 +1,55 @@
{ lib
, stdenv
, fetchurl
, autoPatchelfHook
}:
let
version = "0.7.0";
# 预编译二进制来自 GitHub Releasesgoreleaser 构建,tree-sitter 已静态链接)
srcs = {
"aarch64-darwin" = {
url = "https://github.com/code-yeongyu/go-claude-code-comment-checker/releases/download/v${version}/comment-checker_v${version}_darwin_arm64.tar.gz";
hash = "sha256-0woeTNx7MXraKsshJB7aTkpnfi9GQn9dJEy+/VUfDX8=";
};
"x86_64-linux" = {
url = "https://github.com/code-yeongyu/go-claude-code-comment-checker/releases/download/v${version}/comment-checker_v${version}_linux_amd64.tar.gz";
hash = "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=";
};
"aarch64-linux" = {
url = "https://github.com/code-yeongyu/go-claude-code-comment-checker/releases/download/v${version}/comment-checker_v${version}_linux_arm64.tar.gz";
hash = "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=";
};
};
platformSrc = srcs.${stdenv.hostPlatform.system} or (throw "Unsupported system: ${stdenv.hostPlatform.system}");
in
stdenv.mkDerivation {
pname = "comment-checker";
inherit version;
src = fetchurl {
inherit (platformSrc) url hash;
};
sourceRoot = ".";
nativeBuildInputs = lib.optionals stdenv.hostPlatform.isLinux [ autoPatchelfHook ];
unpackPhase = ''
tar -xzf $src
'';
installPhase = ''
install -Dm755 comment-checker $out/bin/comment-checker
'';
meta = with lib; {
description = "Multi-language comment detection hook for Claude Code / OpenCode";
homepage = "https://github.com/code-yeongyu/go-claude-code-comment-checker";
license = licenses.mit;
platforms = [ "aarch64-darwin" "x86_64-linux" "aarch64-linux" ];
mainProgram = "comment-checker";
};
}