This is my Nix configuration. It supports my macOS, nixOS, and home-manager configurations.
Nix and Flakes must be installed in order to build the derivations. I recommend using the Determinate Nix Installer.
curl --proto '=https' --tlsv1.2 -sSf -L \
https://install.determinate.systems/nix | sh -s -- installYou can now build a system configuration by running nix build and specifying the configuration target:
For nix-darwin (macOS):
nix build .#darwinConfigurations.bromanko-personal-mbp.system
./result/sw/bin/darwin-rebuild switch --flake .#bromanko-personal-mbpFor nixos:
nixos-rebuild switch --flake .#nixosConfigurations.dev-vmA dedicated host config exists at:
hosts/nixos/x86_64-linux/sleeper-service/default.nix
Provisioning automation and runbook are in this repo:
scripts/hetzner/create-server.shscripts/hetzner/bootstrap-nixos.shscripts/hetzner/apply-host-config.shdocs/runbooks/sleeper-service-provisioning.md
Quick flow:
scripts/hetzner/create-server.sh
scripts/hetzner/bootstrap-nixos.sh <server-ip>
INSTALL_BOOTLOADER=1 scripts/hetzner/apply-host-config.sh <server-ip> sleeper-service
# later applies: scripts/hetzner/apply-host-config.sh <server-ip> sleeper-serviceThis host is designed for one always-on Michael process (API + static frontend + in-process calendar sync), with a separate systemd timer for SQLite backups.
Backups are written locally to /var/lib/michael/backups and can be uploaded offsite to S3-compatible object storage by creating /var/lib/michael/backup-upload.env (see docs/runbooks/sleeper-service-provisioning.md).
For home-manager:
nix build .#homeManagerConfigurations.fb-devserver.activationPackage
./result/activateThe home-manager configuration is decoupled from the nixos or Darwin modules. This allows me to use the same config for both environments managed by nixos/nix-darwin and plain home-manager. Unfortunately it makes the organization of modules messy. The modules defining home-manager options must be in separate files from the config itself. This is because I need to import the home-manager config manually outside of the module loading process.
- The
/home-managerfolder contains the home-manager config and will get imported under ahome-manageroption. - The
/modules/home-managerfolder contains the options for enabling home-manager configuration.
This setup is heavily inspired by:
- malob's excellent nixpkgs configuration.
- hlissner's dotfiles