Skip to content
rtucekPublic

Repository files navigation

Dotfiles

My dotfiles (and now, system configuration) - use them as a reference for your personal use and contribute suggestions and improvements.

As of 2026, I've switched from an Arch-based setup, where dotfiles were managed with Chezmoi, to NixOS via a flake-based approach.

Dotfiles in the home directory - including most tools whenever possible - are managed via Home Manager.

Historical Arch configuration may be inspected by looking at the arch-dotfiles tag.

Installation

While this is technically "just" a glorified Nix flake, the initial installation on a host requires some bootstrapping.

This is due to the following requirements:

  • disk partitioning is declaratively managed via disko.1
  • secret management is achieved via sops-nix.2
  • installation via nixos-anywhere.3

Onboarding a new machine

Assuming you want to add a new machine from scratch, perform the following steps in order:

Settle on the hostname

The computer's hostname is a key parameter in NixOS as it maps (by default) to the configuration target.

The example below adds a new laptop of type TUXEDO InfinityBook Pro AMD Gen9. As such, it uses tux-ibp-amdgen9-nixos-btw as the hostname.

Create a host key

The host key is required for decrypting secrets at boot time. For security reasons, each host is expected to have its own dedicated key, located at /secrets/keys.txt.

In order to generate a new key, run:

age-keygen -pq

This will dump an age identity - both the public and private keys - to stdout.4 Store the output in a temporary file.

Create the host SOPS file

Create a dedicated SOPS file for encrypting the host key. The general convention is to locate the host key in ./secrets/hosts/${HOSTNAME}.yaml.

# Create the file via
sops edit ./secrets/hosts/tux-ibp-amdgen9-nixos-btw.yaml

Then, add the previously generated age key in the host_key mapping:

host_key: |
  # created: 2026-08-05T20:01:32+02:00
  # public key:age1pq1f7nk5g0hcvy52[...]appfzrumnuawfy5mdlqd
  AGE-SECRET-KEY-PQ-[...]

Update secrets with the new key

With the new key, the host won't be able to decrypt existing secrets. Existing secrets can only be decrypted once they have been re-encrypted with the new public key.

Before being able to re-encrypt secrets, the new public key must be configured in .sops.yaml. Add the new public key as a YAML anchor to keys.hosts.${HOSTNAME} and alias the value as ${HOSTNAME}_age.

keys:
  hosts:
    # [...]
    tux-ibp-amdgen9-nixos-btw: &tux-ibp-amdgen9-nixos-btw_age |
      age1pq1f7nk5g0hcvy52[...]appfzrumnuawfy5mdlqd

Then, reference the new key in the default creation rule at the bottom:

creation_rules:
  # [...]

  # Default group for private devices
  - pgp:
    # [...]
    age:
    # [...]
    - *tux-ibp-amdgen9-nixos-btw_age

Finally, re-encrypt all secrets with the new key by running:

find secrets -name '*.yaml' -type f -print0 | xargs -0 -l sops updatekeys --yes

You should see all relevant secret files updated in the secrets folder. A notable exception may be secrets, for which other exclusive creation rules take precedence.

Extend the flake

First, make sure you add the baseline configuration by creating hosts/tux-ibp-amdgen9-nixos-btw/default.nix (the convention is hosts/${HOSTNAME}/default.nix).

Paste the following template into it.

{ ... }:
{
  imports = [
    ./hardware-configuration.nix
    # If a nixos-hardware module exists for this machine, import it too:
    # inputs.nixos-hardware.nixosModules.tuxedo-infinitybook-pro14-gen9-amd
    ../../modules
  ];

  networking.hostName = "tux-ibp-amdgen9-nixos-btw";
  sops.defaultSopsFile = ../../secrets/private/hosts/tux-ibp-amdgen9-nixos-btw.yaml;

  # If applicable, change the default LV size.
  # disko.devices.lvm_vg.volgroup0.lvs = {
  #   # 250 GB of available disk space
  #   lv_root.size = "250G";
  #   # 250 GB of available disk space
  #   lv_home.size = "250G";
  # };

  # If applicable, adjust the main monitor's default.
  # rtucek = {
  #   hyprland.monitors = [
  #     {
  #       output = "eDP-1";
  #       mode = "1900x1200@59.9500";
  #       position = "0x0";
  #       scale = 1;
  #     }
  #   ];
  # };
}

The referenced hardware-configuration.nix file must be present. The actual content will be generated during the installation by nixos-anywhere. It is sufficient to write the following content to hosts/tux-ibp-amdgen9-nixos-btw/hardware-configuration.nix (the convention is hosts/${HOSTNAME}/hardware-configuration.nix):

{ lib, ... }:
{
  nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
}

Finally, make sure the host configuration is imported in hosts/default.nix. Use the following template:

{ self, inputs, ... }:
{
  flake.nixosConfigurations =
    let
      sys = "${self}/system";

      # [...]

      specialArgs = { inherit inputs self; };
    in
    {
      # [...]

      tux-ibp-amdgen9-nixos-btw = inputs.nixpkgs.lib.nixosSystem {
        inherit specialArgs;

        modules =
          laptop
          ++ commonCfg
          ++ [
            ./tux-ibp-amdgen9-nixos-btw
          ];
      };
    };
}

Once finished, run nix flake check . to verify that the configuration changes are still valid.

Prepare the destination host

SSH into the installation target via ssh user@IP and verify that you have sudo privileges by running sudo whoami.

As a general reminder, it is also advisable to verify the available disk size (e.g. sudo fdisk -l /dev/[...]). If necessary, adjust disko.devices.lvm_vg.volgroup0.lvs.lv_root.size and disko.devices.lvm_vg.volgroup0.lvs.lv_home.size accordingly.

Do the installation

Once everything is ready, simply run ./nix-install.sh and follow the interactive installer.

The installer will prompt you for the full-disk-encryption password.

WARNING: ./nix-install.sh will format the destination host's disk via disko. Make sure you have backed up your machine in case something breaks during the installation.

During the installation, hosts/tux-ibp-amdgen9-nixos-btw/hardware-configuration.nix will be rewritten, based on the detected hardware. Don't forget to commit the updated file!

Enable Secure Boot

The flake has support for Secure Boot via Lanzaboote.

The following steps are derived from Lanzaboote's manual and subsections.

Prerequisites

Secure Boot requires NixOS to be installed in UEFI mode (not legacy BIOS) and systemd-boot to be used as the boot loader.

These prerequisites can be checked via bootctl status:

$ bootctl status
System:
      Firmware: UEFI 2.40 (American Megatrends 5.11)
 Firmware Arch: x64
   Secure Boot: disabled (disabled)
  TPM2 Support: yes
  Measured UKI: no
  Boot into FW: supported

Current Boot Loader:
       Product: systemd-boot 260.5
...

In the bootctl output, the firmware needs to be UEFI and the current boot loader needs to be systemd-boot.

System preparation

First, create the keys, which will be enrolled:

# Unless already present, install sbctl. Note that `sudo` won't see packages
# installed into your own shell's `PATH`, so generate the keys through the
# same `nix-shell` invocation instead of a separate `sudo sbctl ...` call:
sudo nix-shell -p sbctl --run "sbctl create-keys"

Then, enable Secure Boot for the host in question.

diff --git a/hosts/dell-xps9360-nixos-btw/default.nix b/hosts/dell-xps9360-nixos-btw/default.nix
index a90a902..1b72913 100644
--- a/hosts/dell-xps9360-nixos-btw/default.nix
+++ b/hosts/dell-xps9360-nixos-btw/default.nix
@@ -30,6 +29,8 @@

     ai.claude-code.enable = true;

+    boot.secureboot.enable = true;
+
     virtualisation = {
       docker.enable = true;
       podman.enable = true;

Then, rebuild the system with nixos-rebuild switch:

nixos-rebuild switch --flake . --sudo

Finally, verify that your machine is ready to have Secure Boot activated:

$ sudo sbctl verify
Verifying file database and EFI images in /boot...
✓ /boot/EFI/BOOT/BOOTX64.EFI is signed
✓ /boot/EFI/Linux/nixos-generation-34-2jmnpsirjequvi2dbljik3xtbnqztk7m2gyaac43z3ypsx2vwyaa.efi is signed
✓ /boot/EFI/Linux/nixos-generation-35-xyg7hzxdcrrife23cnk4fyiwemy2lfzbsg6grdct47zgfxwz666a.efi is signed
✓ /boot/EFI/Linux/nixos-generation-36-nitlhcuad5svld25r62myqwpaapjptysjm35ahcn5d2talpgwwsq.efi is signed
✓ /boot/EFI/Linux/nixos-generation-37-tch4qkd3ohb5ibbwn6mismuk42l6hcea7h2vtm3ngna34iy5z5ua.efi is signed
✓ /boot/EFI/Linux/nixos-generation-38-2wt3sto427436gacwsye5t3dscu6vmuk7wkqg4wvfg5wm4by732a.efi is signed
✓ /boot/EFI/Linux/nixos-generation-39-f2ul6j7fdirt34nfufdeof2hf53srwyygnmpydjkpgebxkppdcha.efi is signed
✗ /boot/EFI/nixos/kernel-7.3-vuo5a7ruui4lqe3pwwbusyfxitkpukuv2bpxdrk2bf4u4lcgf4pa.efi is not signed
✗ /boot/EFI/nixos/kernel-7.3.3-hrbpymjqaigqn4prjafojemdr6xnhcrh5su7mapqjjzlz33vidbq.efi is not signed
✗ /boot/EFI/nixos/kernel-7.3.5-pwtmghyal4oh3esr3cgbsztittf732hswwzvapi7am2x2itbzumq.efi is not signed
✗ /boot/EFI/nixos/kernel-7.3.6-rb7lvtbwetvcsqhgnusau7u3n4vewcy52n7uoa7dzxexq2vcbnha.efi is not signed
✓ /boot/EFI/systemd/systemd-bootx64.efi is signed

It is expected that the files starting with kernel- are not signed. Only proceed with the Secure Boot activation if the check above passes!

Activate Secure Boot

Enable Secure Boot by booting into the machine's BIOS menu. Typically, this involves pressing F2, F8, F10 or F12 during the early boot process, such as the initial splash screen.

Essentially, it comes down to the following 3 items:

  • enable the Secure Boot option
  • enter Setup Mode
  • if necessary, delete PK, KEK and DB keys. DO NOT(!) delete the DBX keys. This represents the "Forbidden Signature Database".

The exact steps to enter Setup Mode vary significantly by vendor. On some ThinkPads, you select "Reset to Setup Mode" explicitly; on Framework laptops, you delete each PK/KEK/DB entry individually (never "Erase all Secure Boot Settings"); on Microsoft Surface devices, simply disabling Secure Boot already puts the firmware into Setup Mode.

See Lanzaboote's vendor-specific instructions for steps matching your hardware.

Once enabled and booted back into the system, enroll the keys:

$ sudo sbctl enroll-keys --microsoft
Enrolling keys to EFI variables...
With vendor keys from microsoft...✓
Enrolled keys to the EFI variables!

Since --microsoft was used, double-check afterwards that the Secure Boot Forbidden Signature Database (dbx) isn't empty, e.g. by checking the file size of /sys/firmware/efi/efivars/dbx-*. An empty dbx weakens protection against revoked, Microsoft-signed bootkits.

Reboot once more and verify that Secure Boot is active:

$ bootctl status
System:
      Firmware: UEFI 2.40 (American Megatrends 5.11)
 Firmware Arch: x64
   Secure Boot: enabled (user)
  TPM2 Support: yes
  Measured UKI: yes
  Boot into FW: supported

Current Boot Loader:
       Product: systemd-boot 260.5
...

FAQ

The section below addresses the most frequently asked questions.

Offline build

By default, nixos-rebuild will fail unless an internet connection is present. This is due to the fact that even minor changes, such as Home Manager configuration changes, will by default attempt to search for already cached builds on cache.nixos.org and nix-community.cachix.org (see system/nix/store.nix).

In case an offline build is necessary, it is required to manually override substituters and trusted-public-keys with empty values:

nixos-rebuild switch --flake . --sudo --option substituters "" --option trusted-public-keys ""

Of course, this won't work unless missing artifacts are already present in the local nix store.

Default disk layout

The disk formatting is achieved via disko.1 As a sensible default, the disk layout is defined as follows (see ./hosts/common/disko.nix):

In short, there are 2 main partitions:

  • 1st partition is the EFI boot partition (1GB in size; FAT32 formatted; mounted at /boot)
  • 2nd partition consumes the entire remaining disk space and is encrypted via LUKS2

The encrypted partition uses LVM with a volume group, called volgroup0. The VG has 2 logical volumes:

  • lv_home, mounted at /home (ext4; consuming 33% of the volume group by default)
  • lv_root, mounted at / (ext4; consuming 33% of the volume group by default)

If you wish to change the predefined 33 % VG disk size consumption, override disko.devices.lvm_vg.volgroup0.lvs.lv_root.size and disko.devices.lvm_vg.volgroup0.lvs.lv_home.size, respectively.

Footnotes

  1. https://github.com/nix-community/disko ↩ ↩2

  2. https://github.com/mic92/sops-nix ↩

  3. https://nix-community.github.io/nixos-anywhere ↩

  4. https://age-encryption.org/ ↩

Releases

Used by

Contributors

Languages