Skip to content

Latest commit

 

History

1,199 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Logo
NixOS Config for Shelken

 

darwin

初始化

# 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

常见问题

变更 Homebrew 的清华源 remote 为 官方

git -C "$(brew --repo)" remote set-url origin https://github.com/Homebrew/brew

启用 secret 时,无法引入 shelken/secrets.nix

优先用 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

font 文件 一直在等lock

解决:sudo rm -rf /nix/store/**.lock

wezterm 在 mac 上颜色显示错误

尝试在wezterm.lua中配置front_end = "WebGpu"

Operation not permitted?

给nix完整的磁盘访问权限

安装Homebrew错误?(即使设置http代理)

尝试使用热点数据和使用Quantumult X来代理

Homebrew Cask 已安装,但每次 brew bundle 仍然重复安装

例如 squirrel-app 改名自 squirrel,如果 Caskroom 里残留旧目录,会导致 Homebrew 每次都判定未安装。

解决:

rm -rf "$(brew --prefix)/Caskroom/squirrel"
brew info squirrel-app

go 编译出错

尝试使用热点数据和使用Quantumult X来代理

手动删除某个/nix/store中的编译结果出现No such file or directory

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

部署

在本地部署其他机器

example

# 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

引用

配置参考来源

About

❄️ 我的 nix-config 配置

Resources

Stars

5 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages