Skip to content

scarisey/nixos-dotfiles

Repository files navigation

NixOS and dotfiles

Overview

This is a flake-based NixOS configuration repository that manages both system-level (NixOS) and user-level (Home Manager) configurations. It supports multiple machines and includes custom modules, packages, and overlays.

Key Features

  • Flake-based configuration - Modern Nix flakes for reproducible builds

  • Multi-machine support - Separate configurations for hyperion (server) and titan (workstation)

  • Home Manager integration - User environment management across NixOS and non-NixOS systems

  • Secrets management - Uses SOPS-nix for encrypted secrets

  • Custom packages - Custom derivations in pkgs/ directory

  • Modular architecture - Reusable NixOS and Home Manager modules

  • Binary caches - Pre-configured Cachix caches for faster builds

  • Multiple desktop environments - Support for GNOME, KDE, i3/Xfce

Repository Structure

.
├── flake.nix              # Main flake configuration
├── flake.lock             # Lock file for flake inputs
├── nixos/                 # NixOS system configurations
│   ├── common.nix         # Common NixOS settings
│   ├── hyperion/          # Server configuration
│   └── titan/             # Workstation configuration
├── home-manager/          # Home Manager configurations
│   └── sylvain/           # User configurations
│       └── x86_64-linux/  # Per-host user configs
├── modules/               # Custom modules
│   ├── nixos/             # NixOS modules (boot, cloud, docker, etc.)
│   └── home-manager/      # Home Manager modules (dev tools, shell, etc.)
├── pkgs/                  # Custom package derivations
├── overlays/              # Nixpkgs overlays
├── lib/                   # Helper functions for flake
├── templates/             # Nix templates (devshell, etc.)
├── shell.nix              # Development shell
└── nixpkgs.nix            # Nixpkgs configuration

Quick Start

Prerequisites

  • NixOS installed or Nix package manager on another Linux distribution

  • Git installed

  • (Optional) GitHub Personal Access Token for private repository access

Fresh NixOS Installation

# Enter a shell with git available
nix-shell -p git

# Clone the repository
git clone https://github.com/scarisey/nixos-dotfiles.git
cd nixos-dotfiles

# Activate flakes feature
nix-shell

# Enable trusted users for binary caches (replace 'sylvain' with your username)
echo "trusted-users = root sylvain" | sudo tee -a /etc/nix/nix.conf && sudo pkill nix-daemon

# Build and activate NixOS configuration (replace 'hostname' with your machine name)
sudo nixos-rebuild switch --flake .#hostname

# Build and activate Home Manager configuration
nix run . -- switch --flake .
# OR if home-manager is already in PATH:
home-manager switch --flake .

Non-NixOS Systems

For Home Manager on other Linux distributions:

# Clone and enter the repository
git clone https://github.com/scarisey/nixos-dotfiles.git
cd nixos-dotfiles
nix-shell

# Build Home Manager configuration
home-manager switch --flake .

To set zsh as the default shell:

echo "$HOME/.nix-profile/bin/zsh" | sudo tee -a /etc/shells
chsh -s "$HOME/.nix-profile/bin/zsh"

Forking This Repository

Step 1: Fork and Clone

# Fork on GitHub, then clone your fork
git clone https://github.com/YOURUSERNAME/nixos-dotfiles.git
cd nixos-dotfiles

Step 2: Update Personal Information

Edit flake.nix and update:

  • Private repositories: Change private-vault and private-modules URLs to your own (or remove them) - check this repository as an example.

  • Cachix caches: Update or remove the scarisey-public.cachix.org cache

Edit nixos/common.nix:

  • Username: Replace sylvain with your username (lines 26, 42)

  • Timezone: Update time.timeZone (line 30)

  • Locale: Update i18n.defaultLocale (line 33)

  • Keyboard layout: Update console.keyMap (line 35)

  • SSH keys: Replace with your own SSH public keys (lines 47-50)

Edit home-manager/sylvain/common.nix:

  • Username and home directory: Update to match your system (lines 25-26)

Step 3: Create Your Machine Configuration

For NixOS Systems

# Create a new host configuration directory
mkdir -p nixos/mymachine

# Generate hardware configuration
sudo nixos-generate-config --show-hardware-config > nixos/mymachine/hardware.nix

# Create configuration.nix
cat > nixos/mymachine/configuration.nix << 'EOF'
{ config, pkgs, ... }:
{
  imports = [
    ../common.nix
    ./hardware.nix
  ];

  networking.hostName = "mymachine";

  # Add machine-specific configuration here

  system.stateVersion = "25.05";
}
EOF

For Home Manager Configurations

The repository uses a specific structure: home-manager/USERNAME/SYSTEM/HOSTNAME/home.nix

# Create your user's home configuration
mkdir -p home-manager/youruser/x86_64-linux/mymachine

cat > home-manager/youruser/x86_64-linux/mymachine/home.nix << 'EOF'
{ config, pkgs, ... }:
{
  imports = [
    ../../common.nix
  ];

  # Machine-specific home configuration

  home.stateVersion = "23.05";
}
EOF

# Create common.nix for your user
cat > home-manager/youruser/common.nix << 'EOF'
{ outputs, inputs, config, ... }:
{
  imports = builtins.attrValues outputs.homeManagerModules
    ++ [ inputs.sops-nix.homeManagerModules.sops ];

  nixpkgs.config = {
    allowUnfree = true;
    allowUnfreePredicate = _: true;
  };

  programs.home-manager.enable = true;
  home.username = "youruser";
  home.homeDirectory = "/home/youruser";

  systemd.user.startServices = "sd-switch";

  home.stateVersion = "23.05";
}
EOF

Step 4: Remove or Adapt Private Modules

If you don’t have private repositories, remove these imports from flake.nix:

# Remove from inputs:
private-vault = { ... };
private-modules = { ... };

And remove references in:

  • nixos/common.nix: Remove inputs.private-modules.nixosModules.privateModules

  • home-manager/sylvain/common.nix: Remove SOPS secrets configuration or adapt to your needs

Step 5: Build and Test

# For NixOS
sudo nixos-rebuild switch --flake .#mymachine

# For Home Manager
home-manager switch --flake .

SOPS Secrets Management

This configuration uses SOPS with age for managing secrets.

Setting Up SOPS

Generate Age Key

mkdir -p ~/.config/sops/age
age-keygen -o ~/.config/sops/age/keys.txt

Keep your public key (starts with age1…​) for the next step.

Create Private Vault Repository

You can follow some of the steps below, or take inspiration from this repository as an example.

# Create a new private repository on GitHub
# Clone it locally
git clone https://github.com/YOURUSERNAME/vault.git
cd vault

# Create .sops.yaml configuration
cat > .sops.yaml << 'EOF'
keys:
  - &user1 age1your_public_key_here
creation_rules:
  - path_regex: secrets.yaml$
    key_groups:
      - age:
          - *user1
EOF

# Create secrets file
sops secrets.yaml

Update Flake to Use Your Vault

In flake.nix, change:

private-vault = {
  url = "github:YOURUSERNAME/vault";
};

Update Secrets

On a machine that can already decrypt:

sops updatekeys secrets.yaml

Accessing Private Repositories

To allow Nix to access private GitHub repositories:

  1. Create a Personal Access Token (PAT) on GitHub with repo scope

  2. Configure Nix:

mkdir -p ~/.config/nix
cat >> ~/.config/nix/nix.conf << EOF
access-tokens = github.com=YOUR_PAT_HERE
EOF

Available Hosts

Current configurations:

  • hyperion: Home server with Docker, Immich, Audiobookshelf, Samba, VPN server, etc.

  • titan: Desktop workstation with KDE/GNOME/i3

Custom Modules

NixOS Modules (modules/nixos/)

  • bootanimation.nix - Plymouth boot animation

  • cloud.nix - Cloud provider settings

  • distrobox.nix - Distrobox container support

  • docker.nix - Docker and container runtime

  • gnome.nix - GNOME desktop environment

  • i3.nix - i3 window manager

  • kde.nix - KDE Plasma desktop

  • network.nix - Network configuration

  • qemu.nix - QEMU/KVM virtualization

  • vpn.nix - VPN client configuration

Home Manager Modules (modules/home-manager/)

  • android.nix - Android development tools

  • autoUpdate.nix - Auto-update configuration

  • devtools.nix - Development tools and IDEs

  • ghostty/ - Ghostty terminal configuration

  • git/ - Git configuration

  • gnome.nix - GNOME user settings

  • gui.nix - GUI applications

  • i3Xfce/ - i3 + Xfce configuration

  • kde/ - KDE user settings

  • myshell.nix - Shell environment (zsh, starship)

  • nvim/ - Neovim configuration

  • quickemu.nix - Quick VM management

  • restic.nix - Restic backup configuration

  • ssh/ - SSH configuration

  • tmux/ - Tmux configuration

  • vim/ - Vim configuration

Custom Packages

Custom packages are defined in pkgs/:

  • adoc - AsciiDoc tools

  • antora - Documentation site generator

  • glab-tools - GitLab CLI tools

  • graalvm-21 - GraalVM JDK

  • msgconvert - Email converter

  • And more…​

Templates

The repository includes templates for common use cases:

  • devshell - Development shell for running non-Nix software

Use with:

nix flake init -t github:scarisey/nixos-dotfiles#devshell

Binary Caches

Pre-configured binary caches for faster builds:

  • ghostty.cachix.org - Ghostty terminal builds

  • nix-community.cachix.org - Community packages

  • scarisey-public.cachix.org - Custom packages

These are automatically configured when you use this flake.

Updating Dependencies

# Update all inputs
nix flake update

# Update specific input
nix flake lock --update-input nixpkgs

# Rebuild after update
sudo nixos-rebuild switch --flake .#hostname
home-manager switch --flake .

Troubleshooting

Build Fails Due to Missing Private Repositories

If you see errors about private-vault or private-modules, you need to either:

  1. Create your own private repositories and update the URLs in flake.nix

  2. Remove the private inputs and all references to them

SOPS Decryption Fails

Ensure:

  • Age key exists at ~/.config/sops/age/keys.txt

  • Your public key is added to .sops.yaml in the vault repository

  • Secrets file has been updated with sops updatekeys secrets.yaml

Trusted User Not Working

After adding trusted users, restart the Nix daemon:

sudo systemctl restart nix-daemon

Contributing

This is a personal dotfiles repository, but feel free to:

  • Open issues for questions

  • Submit PRs for bug fixes

  • Fork and adapt for your own use

License

See LICENSE file for details.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors