- Add deadnix, nixfmt, and statix to flake inputs - Add formatter output to flake for nix fmt support - Add deadnix, nixfmt, statix to Home Manager packages - Format all nix files with nixfmt - Add GitHub Actions workflow for CI validation - Support x86_64-darwin in formatter |
||
|---|---|---|
| .github/workflows | ||
| examples | ||
| lib | ||
| modules | ||
| windows | ||
| .gitattributes | ||
| .gitignore | ||
| .sops.yaml | ||
| flake.lock | ||
| flake.nix | ||
| INSTALLATION.md | ||
| LICENSE | ||
| README.md | ||
Dots
This repo is a Nix flake that manages most of my setup on macOS and fully manages machines I have that run NixOS as their operating system.
Flake structure
The Nix bits are driven by flake.nix which pulls in things under modules/. Both Intel and Apple Silicon macOS are supported, as is NixOS.
- inputs: all the places things are pulled from
- outputs:
- all the outputs from the inputs
- a
let...inblock that contains:mkDarwinHostwhich takes a set of parameters and pulls in all the things needed to use Nix on a macOS hostmkNixosHostwhich takes a set of parameters and pulls in all the things needed to configure a NixOS hostmkHomeConfigwhich takes a set of parameters and pulls in things for standalone Home Manager (non-NixOS Linux)
- the body of outputs that contains:
darwinConfigurations- an attribute set keyed by hostname for each macOS hostnixosConfigurations- an attribute set keyed by hostname for each NixOS hosthomeConfigurations- an attribute set keyed by username for standalone HM users
The parameters on mkDarwinHost, mkNixosHost, and mkHomeConfig are:
system:the system definition to use for nixpkgs (e.g., "x86_64-linux", "aarch64-darwin")hostname:the hostname of the machine being configuredusername:the username being configured on the host (all code currently assumes there is a single human user managed by Nix)additionalModules:any nix modules that are desired to supplement the default for the hostadditionalSpecialArgs:any supplemental arguments to be passed tospecialArgs
Repo structure
Key files at the root level:
flake.nix- Main flake entry point, defines all hosts and inputsflake.lock- Lock file for pinned dependencieslib/- Helper functions (mkDarwinHost, mkNixosHost, mkHomeConfig)modules/hosts/- All host configurations (see tree below).sops.yaml- SOPS secrets management configurationexamples/flake-structure.nix- Minimal example showing flake structure
The Nix stuff is structured like so:
$ tree modules -I secrets.yaml --dirsfirst
modules
├── shared # Shared configurations (formerly common)
│ ├── all-gui.nix
│ ├── default.nix
│ ├── files # Home manager files (nvim, powershell, tilix, waybar, xfce4)
│ ├── linux
│ │ ├── apps # Linux-specific apps (waybar, tilix, etc.)
│ │ ├── home.nix
│ │ ├── internationalisation.nix
│ │ ├── lets-encrypt.nix
│ │ ├── nixroutes.nix
│ │ └── restic.nix
│ └── linux-apps # (deprecated, apps moved to linux/)
└── hosts
├── darwin # macOS system & home configs
│ ├── AirPuppet
│ │ └── home-gene.nix
│ ├── Blue-Rock
│ │ ├── default.nix
│ │ └── home-gene.liverman.nix
│ ├── default.nix
│ ├── home.nix
│ └── mightymac
│ ├── default.nix
│ └── home-gene.liverman.nix
├── home-manager-only # Standalone Home Manager (non-NixOS Linux)
│ ├── default.nix
│ ├── home-gene.liverman.nix
│ └── home-gene.nix
└── nixos # NixOS system & home configs
├── bigboy
│ ├── default.nix
│ ├── hardware-configuration.nix
│ └── home-gene.nix
├── default.nix
├── hetznix01
│ ├── default.nix
│ ├── disk-config.nix
│ ├── hardware-configuration.nix
│ ├── home-gene.nix
│ ├── post-install # Post-install services
│ │ ├── containers
│ │ ├── default.nix
│ │ ├── matrix-synapse.nix
│ │ ├── monitoring.nix
│ │ ├── mosquitto.nix
│ │ └── nginx.nix
│ └── secrets.yaml
├── hetznix02
├── kiosk-entryway
├── kiosk-gene-desk
├── nixnas1
│ ├── default.nix
│ ├── disk-config.nix
│ ├── hardware-configuration.nix
│ ├── home-gene.nix
│ └── secrets.yaml
├── nixnuc
│ ├── containers
│ ├── default.nix
│ ├── hardware-configuration.nix
│ ├── home-gene.nix
│ └── monitoring-stack.nix
└── rainbow-planet
├── default.nix
├── gnome.nix
├── hardware-configuration.nix
└── home-gene.nix
Hosts
- Darwin (macOS): AirPuppet, Blue-Rock, mightymac
- NixOS: bigboy, hetznix01, hetznix02, kiosk-entryway, kiosk-gene-desk, nixnas1, nixnuc, rainbow-planet
- Home Manager only: gene (x86_64-linux, aarch64-linux)
Historical bits
This repo historically contained my dot files. Historically symlinked files on Windows are still in windows/. Everything else is just in git history now.
Adding a new macOS host
- run
xcode-select --installto install the command-line developer tools (this includes the Apple's stock version of Git). - create ed25519 ssh key via
ssh-keygen -t ed25519 - add key to GitHub account
- run macOS graphical installer from https://determinate.systems/posts/graphical-nix-installer
- run
mkdir ~/repos - run
cd ~/repos - run
git clone git@github.com/genebean/dots - create keys for SOPS via
mkdir -p ~/Library/Application\ Support/sops/age && nix run nixpkgs#ssh-to-age -- -private-key -i ~/.ssh/id_ed25519 > ~/Library/Application\ Support/sops/age/keys.txt && nix run nixpkgs#ssh-to-age -- -i ~/.ssh/id_ed25519.pub >~/Library/Application\ Support/sops/age/pub-keys.txt - run
cat ~/Library/Application\ Support/sops/age/pub-keys.txt |pbcopy - edit
.sops.yamland:- paste copied data into a new line under keys
- add creation rule
- add to common rule
- run
mkdir modules/home-manager/hosts/$(hostname -s) - run
nix run nixpkgs#sops -- modules/home-manager/hosts/$(hostname -s)/secrets.yaml - Add entries for
local_git_configcontaining something like this:[user] email = me@example.comlocal_private_envcontaining anything you want exported as env vars or local aliases that you want to keep privatetailscale_key
- create
modules/home-manager/hosts/darwin/$(hostname -s)/<username>.nixbased on needs for this machine - run
mkdir modules/hosts/darwin/$(hostname -s) - create
modules/hosts/darwin/$(hostname -s)/default.nixbased on need for this machine - add entry to
flake.nix - if not a fresh install of macOS,
- run
brew leavesand look for things installed from taps you don't want any more - uninstall the program and the tap if not adding it to nix
- run
- run
git add . - run
git status- it should look something like this:gene.liverman@mightymac dots % git status On branch main Your branch is up to date with 'origin/main'. Changes to be committed: (use "git restore --staged <file>..." to unstage) modified: .sops.yaml modified: flake.nix new file: modules/home-manager/hosts/mightymac/gene.liverman.nix new file: modules/home-manager/hosts/mightymac/secrets.yaml new file: modules/hosts/darwin/mightymac/default.nix - run
sudo mv /etc/nix/nix.conf{,.before-nix-darwin} - run
sudo mv /etc/zshenv{,.before-nix-darwin} - run
nix run --extra-experimental-features 'nix-command flakes repl-flake' nix-darwin -- check --flake ~/repos/dots - Run
nix run --extra-experimental-features 'nix-command flakes repl-flake' nix-darwin -- switch --flake ~/repos/dots- if prompted, run
sudo mv /etc/shells{,.before-nix-darwin} - if prompted, run
sudo mv /etc/zshenv{,.before-nix-darwin} - if prompted, you may also have to move or remove
~/.zshrc - on the first (or several) run(s) homebrew may well fail due to previously installed casks or programs in
/Applications. You may have to runbrew install --force <package name>to fix this - you may have to run brew multiple times to fix things
- if prompted, run
- in Settings > Privacy & Security > App Management you will need to allow iTerm
- After the nix command finally works, open a new iTerm window and it should have all the nixified settings in it.
- Go into iTerm2's preferences and use the Hack Nerd Mono font so that the prompt and other things look right. You will likely also want to adjust the size of the font.
Extras steps not done by Nix and/or Homebrew and/or mas
Firefox profile switcher
You will need to link firefox-profile-switcher-connector for it to work. The easiest way to do this is to run brew reinstall firefox-profile-switcher-connector and follow the directions printed in the terminal.
Setup sudo via Touch ID
- run
sudo cp /etc/pam.d/sudo_local{.template,}- this will generate a popup asking permission - run
sudo nvim /etc/pam.d/sudo_localand uncomment line as directed by top comments - save via
!wwhich will generate a popup asking permission
Atuin
Nix installs and configures Atuin, but you still need to log into the server:
- run
atuin import autoto import the shell history from before Atuin was installed and running - run
read -s akeyand enter the encryption key - run
read -s apassand enter the user password - run
atuin login --key=$akey --password=$apass --username=gene
Mouse support
Adding a NixOS host
Post-install
- clone this repo
- create keys for SOPS via
mkdir -p ~/.config/sops/age && nix run nixpkgs#ssh-to-age -- -private-key -i ~/.ssh/id_ed25519 > ~/.config/sops/age/keys.txt && nix run nixpkgs#ssh-to-age -- -i ~/.ssh/id_ed25519.pub > ~/.config/sops/age/pub-keys.txt - copy output of
~/.config/sops/age/pub-keys.txt - add entries to
.sops.yaml - run
sops modules/hosts/nixos/$(hostname)/secrets.yaml- if there is an empty yaml file in where you target you will get an error... just delete it and try again
- edit
sops modules/hosts/nixos/$(hostname)/default.nixand add the Tailscale service and the block of config for sops.- if there is an empty yaml file in where you target you will need to delete it