Skip to content

NixOS

A powerful Linux distribution built on the Nix package manager, enabling reproducible, declarative system configurations.


๐Ÿ”ง ๐Ÿง Key Concepts & Features

๐Ÿ› ๏ธ Declarative Configuration

  • System configuration is described in .nix files.
  • Rebuilding the system ensures consistency across reboots and devices.

๐Ÿ“ฆ Nix Flakes

  • Flakes improve reproducibility and manage multiple configurations.
  • Use a flake reference like:
    sudo nixos-rebuild switch --flake ./nixos/${hostname}
    
  • Replace ${hostname} manually if using templates (e.g., in Hyprland configs).

๐Ÿง  Use Case: Hyprland with ZaneyOS

  • Based on ZaneyOS.
  • Forked and adapted in your own pierreg branch.
  • Integration into flake system allows modular, theme-based configuration.

๐Ÿงช Useful Commands

# Rebuild and apply the configuration from the specified flake:
sudo nixos-rebuild switch --flake ./nixos/#pierreg

๐Ÿ’ป My Experience: Simple (Re)Installation on a New Computer

I recently set up a new machine equipped with a discrete GPU for experimenting with GPU computing. It turned out to be a great opportunity to test how smooth it is to reinstall NixOS from scratch and replicate my existing setup.

โœ… Conclusion

The entire process was surprisingly straightforward. I ended up with an identical environment to my previous systemโ€”complete with all my apps, custom configurations, Neovim setup, Tmux, personalized Hyprland shortcuts, and more.


๐Ÿงญ Steps I Followed (dual boot with Windows)

  1. Used Windows' partition manager to create a blank partition for NixOS

  2. Entered BIOS to:

    • Disable Secure Boot (since it doesnโ€™t recognize NixOS)

    • Set the USB stick with the NixOS installer as the first boot option

  3. Installed NixOS with the GNOME desktop environment following the graphical installer

  4. Opened a terminal and ran: nix-shell -p git vim

  5. Cloned my dotfiles/configuration repository and navigated into it

  6. Generated hardware configuration: nixos-generate-config --show-hardware-config > hosts/pierreg/hardware.nix

  7. Enabled flake support: export NIX_CONFIG="experimental-features = nix-command flakes"

  8. Rebuilt and switched to my full system config: sudo nixos-rebuild switch --flake .#pierreg

๐Ÿ”ง Final Touches

After installation, all I had to do was:

  • Connect my mail account in Thunderbird

  • Add my Git SSH keys

  • Log in to Firefox and sync my GitLab account

  • Re-download my Git repositories


๐ŸŽฎ Bonus: GPU Setup

As part of this install, I also took the time to learn how to configure hybrid GPU management (discrete + integrated), which has been valuable for both gaming and compute workloads.

๐ŸŽ›๏ธ Desktop Environment & Audio

I'm using Hyprland as my Wayland compositor, which gives me a lightweight, dynamic tiling experience with great performance and flexibility.

To manage multiple displays easily, I use wdisplays, a simple GUI tool for configuring screen layouts on Wayland.

For audio, I'm currently using PulseAudio, which integrates well with most desktop apps and provides straightforward volume and device management.


๐Ÿ“ฆ Tool Spotlight: nix-shell -p pdfcpu

๐Ÿ” What is nix-shell?

nix-shell creates a temporary shell environment where specified packages are available without installing them globally.

Perfect for: - Isolated testing - Short-lived tasks - Reproducible scripting

๐Ÿงฐ What does -p pdfcpu do?

The -p flag means โ€œprovide this package.โ€
This command:

nix-shell -p pdfcpu

...starts a new shell with the pdfcpu tool immediately available.

๐Ÿ“„ What is pdfcpu?

pdfcpu is a fast, open-source CLI tool written in Go for managing PDF files.

Key capabilities: - โœ… Validate PDFs - ๐Ÿ”ง Optimize/compress files - ๐Ÿ” Extract images/pages - โœ‚๏ธ Split/merge - ๐Ÿ–‹๏ธ Add watermarks or stamps

๐ŸŒŸ Why is this Cool?

  • ๐Ÿงผ No clutter: No need to install or clean up later.
  • ๐Ÿ” Reproducible: Exact tool/version every time.
  • ๐Ÿงช Safe testing: Temporary environment avoids polluting your system.
  • โš™๏ธ Automation-friendly: Great for scripts and CI/CD.
  • ๐Ÿ’ก Portable: Easy to share your environment setup.

๐Ÿš€ Example Usage

After running:

nix-shell -p pdfcpu

You can use:

pdfcpu validate input.pdf
pdfcpu optimize input.pdf output.pdf
pdfcpu extract -mode=images input.pdf ./images/

๐Ÿง  Notes & Tips

  • Always make sure to pin versions in your flake for true reproducibility.
  • Use direnv to automatically enter nix-shell environments in project directories.

๐Ÿ“š Resources