1
0
Fork 0
NixOS configuration files for Aires. https://aires.fyi/blog/my-nixos-configuration/
Find a file
Aires 4a583d60b8 flake.lock: Update
Flake lock file updates:

• Updated input 'nixos-hardware':
    'github:NixOS/nixos-hardware/b12e314726a4226298fe82776b4baeaa7bcf3dcd' (2024-12-16)
  → 'github:NixOS/nixos-hardware/e8516a23524cc9083f5a02a8d64d14770e4c7c09' (2024-12-22)
• Updated input 'nixpkgs-unstable':
    'github:nixos/nixpkgs/d3c42f187194c26d9f0309a8ecc469d6c878ce33' (2024-12-17)
  → 'github:nixos/nixpkgs/d70bd19e0a38ad4790d3913bf08fcbfc9eeca507' (2024-12-19)
2024-12-23 00:18:55 +00:00
.vscode General: switch to Snowfall lib 2024-12-06 13:04:47 -05:00
bin Services: tweak Syncthing tray option 2024-12-13 10:38:23 -05:00
lib General: turn templates into actual templates 2024-12-08 11:12:00 -05:00
modules/nixos Apps: add Floorp browser 2024-12-22 14:58:05 -05:00
overlays/pkgs/unstable General: code cleanup; Khanda: replace Intel driver 2024-12-07 12:07:12 -05:00
packages Packages: update Duplicacy Web to 1.8.3 2024-12-20 15:02:24 -05:00
systems Hosts: update connection info for gremlin-lab 2024-12-20 13:00:19 -05:00
templates System: futzing with bootloader modules 2024-12-09 16:06:14 -05:00
.gitattributes General: switch to Snowfall lib 2024-12-06 13:04:47 -05:00
.gitignore Initial public commit! 2024-02-29 09:53:34 -05:00
flake.lock flake.lock: Update 2024-12-23 00:18:55 +00:00
flake.nix General: point back to official nixos-hardware 2024-12-16 09:30:22 -05:00
README.md Secrets: configure jump hosts for Pihole and lab VM 2024-12-19 10:48:29 -05:00
treefmt.nix General: code cleanup; Khanda: replace Intel driver 2024-12-07 12:07:12 -05:00

NixOS Configuration

A full set of configuration files managed via NixOS. This project uses the Snowfall library.

Note

Are you new to NixOS? Hi, hello, and welcome! This repository probably won't make much sense to you 😅 If you're looking for a good beginner configuration or template, check out https://github.com/Misterio77/nix-starter-configs

Warning: DO NOT DOWNLOAD AND RUN nixos-rebuild ON THIS REPOSITORY! These are my personal configuration files. I invite you to look through them, modify them, and take inspiration from them, but if you run nixos-rebuild, it will completely overwrite your current system!

Using this repo

Note on secrets management

Secrets are managed using transcrypt. To unlock the repo, use transcrypt -c [cipher] -p '[password]'. Transcrypt will transparently encrypt/decrypt files stored in modules/nixos/secrets going forward. You can get the cipher and password from a host with transcrypt already configured by running transcrypt --display.

Note

This is a poor man's secret management solution. If you use this, your secrets will be world-readable in the /nix/store/.

First-time installation

When installing on a brand new system, partition the main drive into two partitions: a /boot partition, and a LUKS partition. Then, run bin/format-drives.sh --root [root partition] --luks [luks partition] (the script will request sudo privileges):

./bin/format-drives.sh --boot /dev/nvme0n1p1 --luks /dev/nvme0n1p2

Next, set up the host's config in the systems/[architecture] folder by copying default.nix.template and hardware-configuration.nix.template into a new folder named after the hostname. Running format-drives.sh also generates a hardware-configuration.nix file you can use.

If necessary, import modules by adding the host to flake.nix under the outputs.systems.hosts section.

Finally, run the NixOS installer, replacing host with your actual hostname:

sudo nixos-install --verbose --root /mnt --flake .#host --no-root-password

Tip

This config installs a nixos-rebuild wrapper called nos (NixOS Operations Script) that handles pulling and pushing changes to your configuration repository via git. For more info, run nixos-operations-script --help.

Running updates

To update a system, run nixos-operations-script (or just nos). To commit updates back to the repo, use nos --update. Do not run this script as root - it will automatically request sudo permissions as needed.

Automatic updates

To enable automatic updates for a host, set config.${namespace}.services.autoUpgrade = true;. You can configure the autoUpgrade module with additional settings, e.g.:

services.autoUpgrade = {
  enable = true;
  configDir = config.${namespace}.secrets.nixConfigFolder;
  onCalendar = "daily";
  user = config.users.users.aires.name;
};

Automatic updates work by running nos. There's an additional pushUpdates option that, when enabled, updates the flake.lock file and pushes it back up to the Git repository. Only one host needs to do this (in this case, it's Hevana), but you can safely enable it on multiple hosts as long as they use the same repository and update at different times.

Manually updating

Run nos to update the system. Use the --update flag to update flake.lock as part of the process. For the first build, you'll need to specify the path to your flake.nix file and the hostname using nos --hostname my_hostname --flake /path/to/flake.nix.

After the first build, you can omit the hostname and path:

nos

This is the equivalent of running:

cd [flake dir]
git pull
nix flake update --commit-lock-file
git push
sudo nixos-rebuild switch --flake .

There are a few different actions for handling the update:

  • switch replaces the running system immediately.
  • boot switches to the new generation during the next reboot.
  • build creates and caches the update without applying it.
  • test creates the generation and switches to it, but doesn't add it to the bootloader.

Using Remote builds

Nix can create builds for or on remote systems, and transfer them via SSH.

Generating a build on a remote system

You can run a build on a remote server by using --build-host:

nixos-rebuild build --flake . --build-host [remote hostname]
Pushing a build to a remote system

Conversely, you can run a build on the local host, then push it to a remote system.

NIX_SSHOPTS="-o RequestTTY=force" nixos-rebuild --target-host user@example.com --use-remote-sudo switch

Testing without modifying the system

If you want to test without doing a whole build, or without modifying the current system, there are a couple additional tools to try.

Dry builds

To quickly validate your configuration, create a dry build. This analyzes your configuration to determine whether it'll actually build:

nixos-rebuild dry-build --flake .

Virtual machines

You can also build a virtual machine image to preview changes. The first command builds the VM, and the second runs it:

nixos-rebuild build-vm --flake .
./result/bin/run-nixos-vm

Note

Running the VM also creates a .qcow2 file for data persistence. Remove this file after a while, otherwise data might persist between builds and muck things up.

About this repository

This config uses the Snowfall lib, along with some default options and settings for common software. It features:

  • Flakes
  • Home Manager
  • Automatic daily updates
  • AMD, Intel, and Raspberry Pi (ARM64) hardware configurations
  • Support for various GUIs and desktop environments including Gnome, KDE, XFCE, and Hyprland
  • Boot splash screens via Plymouth
  • Secure Boot support via Lanzaboote
  • Disk encryption via LUKS with TPM auto-unlocking
  • Custom packages and systemd services
  • Flatpaks
  • Default ZSH shell using Oh My ZSH
  • Secrets (sorta - using Transcrypt)