常用命令

系统维护

------------------------------------ 代理 ------------------------------------
systemctl show nix-daemon -p Environment						# 查看
curl -I https://cache.nixos.org/nix-cache-info					# 测试
sudo systemctl edit nix-daemon --force							# 修改
sudo systemctl restart nix-daemon								# 生效
export http_proxy=http://<代理IP>:7890 https_proxy=$http_proxy	# 临时
------------------------------------ 配置 ------------------------------------
sudo -e /etc/nixos/configuration.nix                    # 修改:用vim 编辑
sudo nixos-rebuild switch								# 生效
sudo nix-collect-garbage -d                  			# 删掉所有旧世代并回收
sudo nix-collect-garbage --delete-older-than 14d   		# 删掉14天前旧世代并回收
sudo nix-store --optimise                    			# store占用手动去重
------------------------------------ 权限 ------------------------------------
sudo visudo 											# 修改:用vim 编辑
------------------------------------ 缓存 ------------------------------------
systemctl list-timers nix-gc        					# 下一次触发gc时间
nixos-rebuild list-generations      					# 看当前世代列表
du -sh /nix/store                   					# 看 store 实际占用

软件安装(非配置)

------------------------------------ 日常 ------------------------------------
command -v vim vi nano 					# 编辑器vi:确认有没有
nix-shell -p vim-full					# 编辑器vi:安装
------------------------------------ AI ------------------------------------
curl -fsSL https://raw.githubusercontent.com/NousResearch/hermes-agent/main/scripts/install.sh | bash	# 安装
hermes doctor
hermes setup                     # 选 provider / 填 key(key 只进 .env,别写进笔记)
hermes gateway install           # 建 systemd user 服务(需要上面的 linger)
systemctl --user status hermes-agent