dotfiles-nix

使用 Nix 管理 dotfiles

quick start

install

pitfalls

Troubleshooting

  1. 通过 REPL 排查 ```

    进入 nix repl 解释器

    nix –experimental-features ‘nix-command flakes’ repl

    加载 flake 然后查看 flake 内容

    nix-repl> :lf .

    在 repl 中输出 json 格式

    nix-repl> builtins.toJSON outputs.darwinConfigurations.

nix repl -f ‘'


2. 通过 build 结果分析

darwin-rebuild build –flake .#mini –show-trace –print-build-logs –verbose


## Nix

Nix 配置文件:
- `/etc/nix/nix.conf` 文件
- `NIX_CONFIG` 环境变量
- command line flags 方式 `--option <name> <value>`

```shell
# 查看配置
nix config show
# 指定 Nix 配置
NIX_CONFIG="substituters = https://mirrors.tuna.tsinghua.edu.cn/nix-channels/store" darwin-rebuild build  --flake .#mini -v
darwin-rebuild build --flake .#mini --option substituters "https://mirrors.tuna.tsinghua.edu.cn/nix-channels/store"

Derivation

# 查看本地 drv 内容
nix derivation show /nix/store/j4avzn6fll1d1v588pss8nrmjfxlwlar-maven-3.6.3.drv
# 查看 pkgs 仓库 drv 内容
nix derivation show nixpkgs#maven
# 查看当前系统 drv 内容
nix derivation show -r /run/current-system
# 构建 drv
nix-store -r /nix/store/5y616j03c24dinqz74zr745i6nybmgkx-maven-3.9.9.drv

stdenv

使用 stdenv 构建 derivation。

zsh

mac spoofing

openssl rand -hex 6 | sed 's/\(..\)/\1:/g; s/:$//'
sudo /System/Library/PrivateFrameworks/Apple80211.framework/Resources/airport -z
ifconfig en0 ether
# Change the MAC address  14:7d:da:a9:a8:8c(mbp)/84:8c:8d:b1:22:26(router)
sudo ifconfig en0 ether d8:18:fd:c0:41:96
networksetup -detectnewhardware
# Turn off the Wi-Fi device:
networksetup -setairportpower en0 off

macOS

# 查看所有
defaults domains
# 查看指定
defaults read com.apple.dock

reference