Skip to content

theobori/nixos-configuration

Repository files navigation

❄️ My NixOS Configuration

check pages

built with nix

This repository contains all the Nix declarations I use to build my systems.

Table of Contents

  1. Getting Started
  2. Features
  3. Customization
  4. Resources

Getting Started

Before diving in, ensure that you have Nix installed on your system. If not, you can download and install it from the official Nix website or from the Determinate Systems installer.

Clone this repository to your local machine

git clone https://github.com/theobori/nixos-configuration.git
cd nixos-configuration

# linux
sudo nixos-rebuild switch --flake .

 # with direnv
flake switch

Deploy on a remote machine

Feel free to use my minimal bootable disk image x86_64-install-iso/minimal. The aim is to load this bootable iso on a target machine to have a usable OpenSSH server to deploy our NixOS configuration.

You can build it with the following command.

nix build .#install-isoConfigurations.minimal

Once built, you'll find an iso file in the iso folder of the build result. Below, part of the result of the tree result command shows us that we have built an image for a x86_64-linux system.

result/
├── iso
│   └── nixos-24.11.20241028.bb50fc7-x86_64-linux.iso
...

Once loaded on the target machine, you can use a deployment tool such as nixos-anywhere to deploy NixOS over SSH.

Here's an example.

nix run github:nix-community/nixos-anywhere -- --generate-hardware-config nixos-generate-config systems/x86_64-linux/vm/hardware-configuration.nix nixos@<destination> --flake .#<system-name>

Features

Here's an overview of what my Nix configuration offers:

  • External Dependency Integrations:

    • Access the Nix User Repository (NUR) for additional packages and enhancements.
  • Home Manager: Manage your dotfiles, home environment, and user-specific configurations with Home Manager.

  • DevShell Support: The flake provides a development shell (devShell) to support maintaining this flake. You can use the devShell for convenient development and maintenance of your Nix environment.

  • CI with Cachix: The configuration includes continuous integration (CI) that pushes built artifacts to Cachix. This ensures efficient builds and reduces the need to build dependencies on your local machine.

  • Utilize sops-nix: Secret management with sops-nix for secure and encrypted handling of sensitive information.

  • Theming with stylix: Management of system and application colorscheme, fonts and wallpaper with stylix.

  • Declarative disk partitioning: Use disko to declare your disk and format it using the Nix language.

Customization

My Nix configuration, based on the SnowfallOrg lib structure, provides a flexible and organized approach to managing your Nix environment. Here's how it works:

  • Custom Library: An optional custom library in the lib/ directory contains a Nix function called with inputs, snowfall-inputs, and lib. The function should return an attribute set to merge with lib.

  • Modular Directory Structure: You can create any (nestable) directory structure within lib/, packages/, modules/, overlays/, systems/, and homes/. Each directory should contain a Nix function that returns an attribute set to merge with the corresponding section.

  • Package Overlays: The packages/ directory includes an optional set of packages to export. Each package is instantiated with callPackage, and the files should contain functions that take an attribute set of packages and the required lib to return a derivation.

  • Modules for Configuration: In the modules/ directory, you can define NixOS modules for various platforms, such as nixos, darwin, and home. This modular approach simplifies system configuration management.

  • Custom Overlays: The overlays/ directory is for optional custom overlays. Each overlay file should contain a function that takes three arguments: an attribute set of your flake's inputs and a channels attribute containing all available channels, the final set of pkgs, and the previous set of pkgs. This allows you to customize package sets effectively.

  • System Configurations: The systems/ directory organizes system configurations based on architecture and format. You can create configurations for different architectures and formats, such as x86_64-linux, aarch64-darwin, and more.

  • Home Configurations: Similar to system configurations, the homes/ directory organizes home configurations based on architecture and format. This is especially useful if you want to manage home environments with Nix.

This structured approach to Nix configuration makes it easier to manage and customize your Nix environment while maintaining flexibility and modularity.

Screenshots

My NixOS KDE Plasma 6 environment looks like this.

sddm home launcher neofetch

Resources

Other configurations from where I learned and copied: