作者明确声明这不是社区框架或发行版,不建议他人直接使用;安装脚本要求 dotfiles 部署在 /mnt/etc/dotfiles 这一固定路径;安装后 root 和用户密码默认都是 nixos,必须立即修改
sudo -i
bash <(curl -sL https://henrik.io/install.sh)README 未说明具体硬件要求,仅要求 NixOS 26.11+(nixos-unstable)x86_64 系统
作者个人的 NixOS 声明式 dotfiles 实验仓库,用 bin/hey 统一管理 NixOS 系统配置与重建
一套基于 Nix Flake 的 NixOS 个人配置与 dotfiles,用声明式方式统一管理系统设置和开发环境,适合想借鉴 NixOS 配置组织方式的用户。
核心能力
- 用 bin/hey 统一封装 nixos-rebuild、gc、profile 等分散命令
- 按 hosts/<HOST> 组织主机配置,支持从 flake 模板新建主机
- 用 agenix 管理密钥与 secrets
- 提供 install.sh 从 NixOS 安装盘一键部署到 /mnt
- 内置 test 命令运行 Hey 与 Nix 测试套件
容易踩的坑
暂无 release 数据(可能没有发版,或尚未同步)。
用户点评
登录用户的真实使用记录,可按版本和硬件筛选还没有人点评。第一个说出真实体验的人最有价值。
Hey, you. You're finally awake. You were trying to configure your OS declaratively, right? Walked right into that NixOS ambush, same as us, and those dotfiles over there.
[!IMPORTANT] Disclaimer: This is not a "community framework" or "NixOS distribution". Please do not use it like one. It is an ongoing and haphazard experiment to feel out NixOS and the Nix language for my own purposes, and is home to all manner of unspeakable, over-engineered hackery that make the other 9 circles of hell look like tropical beach resorts.
Until I can bend spoons with my Nix-fu, please divert your Nix(OS) questions to the NixOS discourse instead of my issue tracker. That said, I'm more than happy to hear input and discuss ideas, but be warned: I'm awful at staying on top of my Github notifications.
(screenshots coming soon)
- Shell: zsh + zpm
- WM: niri + noctalia
- Editor: Doom Emacs + Neovim
- Terminal: foot
- Launcher: rofi
- Browser: librewolf
Quick start
-
Acquire or build a NixOS 26.11+ image:
# Yoink nixos-unstable from upstream $ wget -O nixos.iso https://channels.nixos.org/nixos-unstable/latest-nixos-minimal-x86_64-linux.iso -
Write it to a USB drive:
# Replace /dev/sdX with the correct partition! $ cp nixos.iso /dev/sdX -
Restart and boot into the NixOS installer.
-
Do your partitions and mount your root to
/mnt(for example). -
Connect to the internet, if you haven't already. Wifi-capable devices can use
nmtui. -
Copy any keys/secrets over. If you're on a system with
bin/heyset up, runhey ops push-keys [KEYS](startsshdon the nixos installer first). Otherwise, scp them into/mnt/etc/sshd/: -
If you've already created a host config, then simply run the installer:
sudo -i # switch to root bash <(curl -sL https://henrik.io/install.sh)If you don't have a host config, use this flake's templates to create one from scratch:
-
Deploy the flake (sans my hosts) to
/mnt/etc/dotfiles(that location is required), andcdinto it:sudo -i # switch to root export NIX_CONFIG='experimental-features = nix-command flakes' nix flake new -t github:hlissner/dotfiles /mnt/etc/dotfiles cd /mnt/etc/dotfiles -
Deploy a host config to
hosts/<HOST>and fill it in (see my hosts for examples):HOST="hostname-of-your-system" nix flake new -t github:hlissner/dotfiles#host hosts/$HOST -
git addeverything so Nix will see your config:git init git add -A -
Finally, run the installer:
$ bash /mnt/etc/dotfiles/install.sh
-
-
Reboot!
[!WARNING] Don't forget to change your
rootand$USERpasswords! They are set tonixosby default.
Management
And I say, bin/hey, what's going on?.
SYNOPSIS:
hey [-?|-??|-???|-!] [-h|--help] COMMAND [ARGS...]
OPTIONS:
-!
Do a dry run. WARNING: It's up to called scripts to obey!
-? | -?? | -???
Enable debug (verbose) mode, at increasing verbosity.
-h, --help
Display the documentation embedded in a target script's header.
COMMANDS:
- build|b -- Build nix images, or recompile bin/hey.
- exec -- Execute a program on $PATH through hey.
- gc -- Garbage collect and optimize the nix store.
- get|set -- Alias for hey vars {get,set} ...
- help|h -- Display documentation for a command.
- hook -- Trigger an event.
- host -- Dispatch to hosts/$HOST/bin.
- info -- Display information about the current system (JSON).
- ops -- Operate on remote HeyOS-powered hosts.
- path -- Prints a path to a subarea of my dotfiles.
- profile|pr -- Operate on the nixos profile.
- pull -- Update one of (or all) HeyOS's inputs.
- reload|re -- Reload running services.
- repl -- Open a nix or janet repl with this flake preloaded.
- swap|sw -- Swap nix-store symlinks with mutable copies (and back)
- sync|s -- Rebuild this flake (using nixos-rebuild).
- test -- Run the Hey and/or Nix test suites.
- vars -- Get or set session or persistent state in userspace.
- which -- Print a command's path (with arguments) without running it.
- wm -- Dispatch to config/$WM/bin.
- .* -- Execute the first script found under host, wm, or bin/.
- ./ -- Execute a script by path.
- @* -- Dispatch to config/DIR/bin.
Frequently asked questions
-
Why NixOS?
Because managing a fleet of servers, a hundred strong, is the tenth circle of hell without a declarative, generational, and immutable single-source-of-truth configuration framework like NixOS.
Sure beats the nightmare of brittle capistrano/chef/puppet/ansible/shell scripts I left behind.
-
Should I use NixOS?
Short answer: no.
Long answer: no really. Don't.
Long long answer: I'm not kidding. Don't.
Unsigned long long answer: Alright alright. Here's why not:
- Its learning curve is steep.
- You will trial and error your way to enlightenment, if you survive the frustration long enough.
- NixOS is unlike other Linux distros. Your issues will be unique and difficult to google. A decent grasp of Linux and your chosen services is a must, if only to distinguish Nix(OS) issues from Linux (or upstream) issues -- as well as to debug them or report them to the correct authority (and coherently).
- If words like "declarative", "generational", and "immutable" don't put your sexuality in jeopardy, you're considering NixOS for the wrong reasons.
- The overhead of managing a NixOS config will rarely pay for itself with 3 systems or fewer (perhaps another distro with nix on top would suit you better?).
- Official documentation for Nix(OS) is vast, but shallow. Unofficial resources and example configs are sparse and tend toward too simple or too complex (and most are outdated). Case in point: this repo.
- The Nix language is obtuse and its toolchain is not intuitive. Your experience will be infinitely worse if functional languages are alien to you, however, learning Nix is a must to do even a fraction of what makes NixOS worth the trouble.
- If you need somebody else to tell you whether or not you need NixOS, you don't need NixOS.
If you're not discouraged by this, then you didn't need my advice in the first place. Stop procrastinating and try NixOS!
-
How do you manage secrets?
With agenix.
-
Why did you write bin/hey?
I envy Guix's CLI and want similar for NixOS, whose toolchain is spread across many commands, none of which are as intuitive:
nix,nix-collect-garbage,nixos-rebuild,nix-env,nix-shell, etc.I don't claim
heyis the answer, but who doesn't like their own brew? -
How 2 flakes?
Would it be the NixOS experience if I gave you all the answers in one, convenient place?
No. Suffer my pain:
- A three-part tweag article that everyone's read.
- An overengineered config to scare off beginners.
- A minimalistic config for scared beginners.
- A nixos wiki page that spells out the format of flake.nix.
- Official documentation that nobody reads.
- Some great videos on general nixOS tooling and hackery.
- A couple flake configs that I may have shamelessly rummaged through.
- Some notes about using Nix
- What helped me figure out generators (for npm, yarn, python and haskell)
- Learn from someone else's descent into madness; this journals his experience digging into the NixOS ecosystem
- What y'all will need when Nix drives you to drink.
And if all else fails, ask for help on the NixOS Discourse.