
NixOS Config for Shelken
# 0. 如果有用到secrets,将新机器加入secrets.nix
ssh-keygen -t ed25519 -C "shelken@[host]"
cat ~/.ssh/id_ed25519.pub
## 将公钥放到github上
# 1. install homebrew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
## 将brew命令加入path
eval "$(/opt/homebrew/bin/brew shellenv)"
# 2. install nix
## macOS 使用 Determinate Nix;NixOS 使用系统 NixOS 配置管理。
## note:在此说明,linux目前使用nixos源,mac使用determinate的管理。此项配置分别在`nix.nix`文件中有体现
curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix \
| sh -s -- install --determinate
# 3. clone repo
git clone https://github.com/shelken/nix-config.git ~/nix-config && cd ~/nix-config
# 4. 选择 flake.nix 中定义的机器配置
# Darwin: mio / sakamoto / yuuko / nano / ling
# NixOS: pve155 / pve156 / arm-test-1 / work-test
echo "PROFILE=mio" >> .env
# 5. 首次应用:此时不能假设 just/nh/home-manager 已存在
# note: sudo launchctl stop systems.determinate.nix-daemon && sudo launchctl start systems.determinate.nix-daemon
sudo nix run nix-darwin/master#darwin-rebuild -- switch --flake .#$PROFILE
# 6. 日常应用:打开新 shell 后执行
just sw# before run, you should have just. `brew install just`
# switch
just switch
just sw
# only build result
just b
# only home manager switch
just hm
# update flake inputs
just up
just upp <input># on mac
sudo darwin-uninstaller
# uninstall nix
/nix/nix-installer uninstall
git -C "$(brew --repo)" remote set-url origin https://github.com/Homebrew/brew优先用 Git + HTTPS:将 flake input 改为 git+https://github.com/shelken/secrets.nix.git,Nix 会走本机 Git HTTPS 认证。
如果继续使用 github:shelken/secrets.nix,私有仓库需要 Nix access token。Determinate Nix 的系统配置入口是:
/etc/nix/nix.custom.conf
解决:sudo rm -rf /nix/store/**.lock
尝试在wezterm.lua中配置front_end = "WebGpu"。
给nix完整的磁盘访问权限
尝试使用热点数据和使用Quantumult X来代理
例如 squirrel-app 改名自 squirrel,如果 Caskroom
里残留旧目录,会导致 Homebrew 每次都判定未安装。
解决:
rm -rf "$(brew --prefix)/Caskroom/squirrel"
brew info squirrel-app尝试使用热点数据和使用Quantumult X来代理
sudo darwin-rebuild switch --flake .#sakamoto --show-trace --verbose
building the system configuration...
Using saved setting for 'experimental-features = nix-command flakes' from ~/.local/share/nix/trusted-settings.json.
/run/current-system/sw/bin/darwin-rebuild: line 248: /nix/store/8jfid13h8p5gmy7llb4kvp0m357lswd0-darwin-system-25.11.8df64f8/activate: No such file or directory解决:理论上不是问题,只要随便一个变化就能跳过。如果想解决,可以随便加个小变化让版本切换。然后gc掉所有版本。然后执行
nix store delete /nix/store/8jfid13h8p5gmy7llb4kvp0m357lswd0-darwin-system-25.11.8df64f8然后把变化撤销,重新switch
在本地部署其他机器
# 1 deploy pve156 config on host(pve156)
just deploy pve156 shelken@pve156
# 2
just deploy pve156 shelken@192.168.6.156使用
nixos-generators
# 该命令将构建镜像并上传到我的`pve`路径下
just gen-image {host} {format}
# 例如 生成 iso 格式的 work-test 的镜像
just gen-image work-test iso
just gen-image work-test qcow
配置参考来源



