dotfiles
dotfiles copied to clipboard
My PC Dotfiles & Website
This repository contains the configuration and dotfiles for my continuously evolving multi-PC setup (using Nix). All the devices I own, controlled by code. It also builds and deploys my website to maydayv7.my.to. You can follow along with my NixOS Desktop Series
Features
- Device-Agnostic
- Convenient and Automated
- Hermetically Reproducible
- Declarative and Derivational
- Atomic, Generational and Immutable
Notable Features
- Supports multiple users and devices
- Configuration for multiple Desktop Environments
- Incorporates PipeWire, Wayland, ...!
- Automatically builds and deploys my Website
- Authentication Credentials Management using the
sopsModule andgnupgKeys - Comprehensive User Configuration using the tightly integrated
home-managermodule, with support for configuring shared user configuration, global conditionals and user-specific configuration - Ephemeral, Opt-In File System State using the
impermanencemodule and ZFS - Support for Secure Boot using
lanzaboote - Support for Multiple Programming Language Development
shellsintegrated withdirenvandlorri - Automatic
packagesUpdates usingupdate.sh - Install Media and Device Images using
nixos-generatorsimage generation modules - Syntax Formatting using
treefmtandtreefmt-nix - Support for
sourcefilters withnix-filter - Support for Base16 color theming using
stylix - Support for declaratively installing Flatpak applications using
nix-flatpak - Wrapped
wineApplications using Emmanuel's Wrapper - Support for Android Virtualisation using Waydroid
- Declaratively Configured Windows VM using the WFVM module
Programs
| Type | Programs |
|---|---|
| Editors | nano, VS Code |
| Shells | bash, zsh |
| Terminal | Blackbox, xfce4 Terminal |
| Browser | Firefox |
| Desktop Environments | GNOME, XFCE, Pantheon |
| Compositors | Hyprland, Picom |
Structure
Overview of File Hierarchy
Outputs
$ nix flake show
github:maydayv7/dotfiles
├───apps
│ └───x86_64-linux
│ ├───default: app
│ ├───install: app
│ └───nixos: app
├───checks
│ └───x86_64-linux
│ ├───Device-gnome: derivation 'nixos-rebuild'
│ ├───Device-xfce: derivation 'nixos-rebuild'
│ └───treefmt: derivation 'treefmt-check'
├───devShells
│ └───x86_64-linux
│ ├───cc: development environment 'C'
│ ├───default: development environment 'devShell'
│ ├───format: development environment 'Formatter'
│ ├───java: development environment 'Java'
│ ├───lua: development environment 'Lua'
│ ├───python: development environment 'Python'
│ ├───rust: development environment 'Rust'
│ ├───sql: development environment 'SQL'
│ ├───video: development environment 'Video'
│ └───website: development environment 'Website'
├───files: 'dotfiles' and program configuration
├───formatter
│ └───x86_64-linux: package 'treefmt'
├───installMedia: device install media
├───legacyPackages
│ └───x86_64-linux: omitted (use '--legacy' to show)
├───lib: utility library functions
├───nixosConfigurations
│ ├───futura: NixOS configuration
│ └───vortex: NixOS configuration
├───overlays
├───packages
│ └───x86_64-linux
│ ├───install: package 'install'
│ └───nixos: package 'nixos'
├───templates
│ └───default: template: My NixOS Configuration
└───vmConfigurations
└───Windows: Virtual Machine
┌── flake.nix
├── flake.lock
├── files
├── site
├── devices
│ ├── systems.nix
│ └── vm
├── users
│ └── passwords
├── secrets
├── shells
├── checks
├── lib
│ ├── build.nix
│ ├── map.nix
│ └── pack.nix
├── scripts
│ ├── install.nix
│ └── nixos.nix
├── packages
│ └── overlays
└── modules
├── configuration.nix
├── apps
├── base
├── gui
├── hardware
├── nix
├── shell
└── user
-
flake.nix: toplevel configuration file and repository version control
flake-partsis used for modularization -
files:dotfilesand program configuration -
site: personal website generated usingzola -
devices: system configuration for various devices -
systems.nix: list of supported system architectures -
vm: declarative configuration to build multiple virtual machines -
users: individual user-specific configuration -
secrets: authentication credentials management usingsops-nix -
shells: sand-boxed shells for development purposes -
checks: configuration checks and continuous integration -
lib: custom functions designed for conveniently defining configuration -
scripts: useful system management scripts -
packages: locally built custom packages -
overlays: overrides for pre-built packages -
modules: custom configuration modules for additional functionality -
configuration.nix: builds system configuration
Installation
Already Installed
In case you want to use my configuration as-is for a fresh NixOS install, you can try the following steps:
Note: You can run nix develop in the repository to install all required dependencies
-
Prepare
/etc/nixos:sudo mkdir /etc/nixos sudo chown $USER /etc/nixos && sudo chmod ugo+rw /etc/nixos cd /etc/nixos -
Clone this repository (and preferably initialize it using
git):nix flake init -t github:maydayv7/dotfiles git init -
Install
gnupgand generate a GPG Key for yourself (if you don't already have one), and include it in thesecrets.yamlfile (usinggpg --list-keys). You can use the following commands to generate the GPG key (Ultimate trust and w/o passphrase is preferred):
Replace USER , EMAIL and COMMENT
Save the keysgpg --full-generate-key 1 4096 0 y USER EMAIL COMMENT O gpg --output public.pgp --armor --export USER@EMAIL gpg --output private.pgp --armor --export-secret-key USER@EMAILpublic.gpgandprivate.gpgin a secure location -
Import all required GPG Keys into a convenient location (like
/etc/gpg) usinggpg --homedir DIR importand specify it atconfig.sops.gnupg.home(Required for decryption ofsecretson boot, can also be on an external drive) -
Make new
secretsandpasswordsin the desired directories by appending the paths tosecrets.yamland then using the following command (Thenixosscript can be used to simplify the process):
Replace PATH with the path to thesecretsops --config /path/to/secrets.yaml -i PATH -
Add device-specific configuration by creating a new file in
devices(bear in mind that the name of the file must be same as theHOSTNAMEof your device), and if required, hardware configuration using thehardware.modulesoption. Do keep in mind that the filesystems must be appropriately created and labeled as defined here. -
Finally, run
nixos-rebuild switch --flake /etc/nixos#HOSTNAME(asroot) to switch to the configuration!
Minimal Configuration
The lib.build.device function can be used to generate the full configuration minimally
Read this for definition information
Example flake.nix:
{
description = "Minimal NixOS Configuration";
## System Repositories ##
inputs = {
## Package Repositories ##
# NixOS Package Repository
nixpkgs.follows = "dotfiles/nixpkgs";
## Configuration Modules ##
# My PC Dotfiles
dotfiles.url = "github:maydayv7/dotfiles";
};
## System Configuration ##
outputs = inputs: let
lib = with inputs; nixpkgs.lib // dotfiles.lib;
in {
nixosConfigurations.host = lib.build.device {
name = "HOST_NAME";
system = "x86_64-linux";
imports = [
# Generate using 'nixos-generate-config'
./hardware-configuration.nix
# Passwords
{
users.extraUsers = {
root.hashedPassword = "HASHED_PASSWORD";
recovery.initialHashedPassword = "HASHED_PASSWORD";
};
}
];
timezone = "Continent/City";
locale = "US";
kernel = "zen";
kernelModules = ["nvme"];
gui = {};
hardware = {
boot = "efi";
cores = 4;
filesystem = "simple";
modules = [ /* Imported from 'nixos-hardware' */];
};
# Default User
user = {
name = "nixos";
description = "Default User";
minimal = true;
password = "HASHED_PASSWORD"; # Generate using 'mkpasswd -m sha-512'
};
};
};
}
From Scratch
Download the latest NixOS .iso from the Releases page and burn it to a USB using a flashing utility such as Etcher
[!IMPORTANT] These instructions are mainly intended for personal use. In order to directly use the configuration, you must first create a clone of this repository and follow steps 2 to 6 from the first section, and preferably create your own install media
Additional Install Media
If Nix is already installed on your system, you may run the following command to build the Install Media:
Replace VARIANT with the name of Install Media to create
nix build github:maydayv7/dotfiles#installMedia.VARIANT.config.system.build.isoImage
You can also download the NixOS .iso from here and run the install script using the following command:
nix build github:maydayv7/dotfiles#install
sudo ./result/bin/os-install
If you want to create an .iso image of the entire system, run the following command:
Replace DEVICE with the name of Device to build
nix build github:maydayv7/dotfiles#nixosConfigurations.DEVICE.config.formats.iso
Partition Scheme
Note that the install script automatically creates and labels all the required partitions, so it is recommended that only the partition table on the disk be created and have enough free space
| Name | Label | Format | Size (minimum) |
|---|---|---|---|
| BOOT Partition | ESP | vfat | 500M |
| ROOT Partition | System | ZFS | 25G |
| SWAP Area | swap | swap | 4G |
| DATA Partition | Files | ZFS | 10G |
[!NOTE] For the
advancedfilesystem scheme only
Procedure
To install the OS, just boot the Live USB and run sudo os-install
If the image doesn't boot, try disabling the secure boot and RAID options from BIOS
After the reboot, run nixos setup to finish the install
In case you are using the advanced filesystem scheme, you may need to set the boot flag zfs_force=1 on first boot
Build It Yourself
If you really want to get dirty with Nix and decide to invest oodles of your time into building your own configuration, this repository can be used as inspiration. You can check out the list of links below to resourceful Nix documentation/tutorials/projects that may be helpful in your endeavour
Welcome to the Nix Community! ;)
Notes
Caution
I am pretty new to Nix, and my configuration is still WIP and uses Nix Flakes, an experimental feature (Important: Nix >= 2.19)
It is not recommended to use NixOS if you are a beginner just starting out, without acquaintance with either the command-line or functional programming languages, since the learning curve is steep, debugging issues is difficult, documentation is shallow, and the effort required/time spent isn't worth the hassle for a novice/casual user
Requirements
May change according to available hardware
- UEFI Compatible System
- Intel CPU + iGPU
See this for additional hardware information
Build
While rebuilding system with Flakes, make sure that any file with unstaged changes will not be included. Use git add . in cases where the git tree is dirty
Branches
There are two branches, stable and develop (when required). The stable branch consists of configuration that builds without failure, and the develop branch is a bleeding-edge testbed
Cache
The system build cache is publicly hosted using Cachix at maydayv7-dotfiles, and can be used while building the system to prevent rebuilding from scratch
Continuous Integration
This repository makes use of GitHub Actions in order to automatically check the configuration syntax on every commit (using and statix) and format it (using treefmt), update the inputs every week, build the configuration and upload the build cache to Cachix as well as publish the Install Media .iso to a draft Release upon creation of a tag (You can also find GitLab CI/CD configuration in .gitlab). A git hook is used to check the commit message to adhere to the Conventional Commits specification
Variables
ACCESS_TOKEN: Personal Access Token (To create one - GitHub, GitLab)CACHIX_TOKEN: Cachix Authentication Token
Home Manager
The home-manager module is used in tandem with the system configuration in order to define user-specific configuration. The config.user.homeConfig option has been declared in modules/user/default.nix independent of the original module, from which the final configuration is built, in order to prevent infinite recursion while configuring multiple users per system. The system config can be accessed using the sys parameter in home-manager modules
Links
Theming
- Neofetch: Snazzy CLI System Information Tool
- Powerlevel10K Theme: ZSH Theme for the fancy-looking prompt with immense customization capabilities
- Arc Theme: Flat GTK theme with transparent elements for various desktop shells, window managers and applications
- Bibata Cursor: Compact and material designed cursor set
- DNOME Discord Theme: Discord Theme inspired by Adwaita, designed to integrate Discord with GNOME
- Nordic Discord Theme: Discord Theme using the Nord color palette
- Firefox GNOME Theme: GNOME Theme for the Mozilla Firefox Browser, used for better desktop integration
- Firefox Elementary Theme: Elementary OS Theme for the Mozilla Firefox Browser, used for better desktop integration
- VS Code Adwaita Theme: Integrates Visual Studio Code with GNOME Desktop
- VS Code Arc Theme: Port of the Arc Dark GTK Theme for Visual Studio Code
- VS Code Elementary Theme: Integrates Visual Studio Code with Pantheon Desktop
- KvLibadwaita Kvantum Theme: Integrates QT Apps with GNOME Desktop
- Arc KDE Theme: Port of the Arc GTK Theme for Plasma Desktop
- ULauncher Adwaita Theme: ULauncher Theme based on GNOME Desktop's Adwaita Dark Theme
- ULauncher Arc Theme: An Arc Dark Theme for ULauncher
- ULauncher Elementary Theme: ULauncher Themes for Elementary OS
- Catppuccin Theme: A community-driven Pastel Theme consisting of 4 soothing warm Flavors with 26 eye-candy Colors each
Important Links
See: A Curated List of the Best Resources in the Nix Community
- Official Documentation
- NixOS Manual
- Nix Pills
- NixOS Discourse
- NixOS Package Search
nixpkgsPackage Repository- NUR Nix User Repository
- NixOS Hardware Modules
- Home Manager Options
Other Sources
- Tweag Article introducing Flakes
- Serokell's Blog on Flakes
- Jordan Isaac's Blog for porting configuration to Flakes
- Jon Ringer's Videos on General NixOS Tooling and Hackery
- Justin's Notes on using Nix
- Lan Tian's Series of Blog Posts on NixOS
- Christine's Blog Posts addressing NixOS Security
- Graham and Elis' Blog Posts on Ephemeral Partition Schemes
Other Configurations
Here are some repositories that I may have shamelessly rummaged through for building my dotfiles:
Thanks a lot! ;)
- Example Configuration
- User Configurations -
You can navigate to the READMEs present in the various directories to know more about them
Changelog
v17
- Re-expose
lib.build.device - Add Hyprland Configuration
- Refactor GNOME
dconf - Overhaul XFCE Configuration
- Use ULauncher
- Use the Picom Compositor
- Add Pantheon Desktop Configuration
- Add VS Code Extensions Repository
- Fix Android Virtualisation
- Support running AppImages
- Add multiple
guiModules - Refactor and add
hardware.cpu - Add
sqlShell - Actually persist
~/.local/share/Trash
v15
- Use the
flake-partsFlakes framework - Improve Syntax Formatting with
treefmt-nixand droppre-commit-hooks - Support declarative Flatpak application install
- Update Nix to version 2.19
- Enable Security & Hardening settings by default
- Add Boot Recovery Settings
- Support Secure Boot using
lanzaboote - Allow patching Default Package Channel
- Show package delta using
nvd - Upgrade to GNOME 45
- Update Extensions
- Fix Emoji Support
- Drop
.templates - Multiple Refactors
- Separate
gamesandlaptopmodule - Separate
installScript - Stop exposing
nixosModules - Fix
user.homeConfig
- Separate
v13
- Follow NixOS Unstable
- Improve
nix-index - Move out proprietary files
- Refactor Secrets
- Drop
deploy-rsSupport - Remove
inputspatching Support - Fix first boot installation
- Add conditional to
lib.map.files - Add
gui.{wallpaper,wayland}
23.05 (v12)
- Upgrade to NixOS v23.05 (Stoat)!
- Drop
cod,nix-linter,gedit,touchegg,vscode-serverandmutter-rounded - Support Android Virtualisation using Waydroid
- Drop
compatLibraries - Refactor GNOME Experience
- Improve XFCE Configuration and Handling
- Improve Automatic Package Update Script
- Enable ZFS encryption
- Support Network Printing
22.11 (v11)
- Upgrade to NixOS v22.05 (Quokka)!
- Add
lib.map.array - Improve
nixosScript - Add
gui.fonts.usershare - General Maintenance Updates
- Use
treefmtfor Formatting Code
22.04 (v10)
- Deprecate
git-cryptUsage - Improve Installation Experience
- Begin Work on Blog
- Stabilize with multiple Bug-Fixes
Archive
v7.0
- Create Website using Zola
- Refine Compatibility Libraries
- Refine Scripts
- Use
nix-shellShebangs - Add
lib.build.script
- Use
- Support Visual Studio Code Editor
- Use
alejandrafor formatting code
v5.0
- Improve
channelsUsage - Support
sourceFilters - Refine
gitConfiguration - Use
wineApplication Wrapper - Use System Independent
library - Add Support for Ephemeral
/home - Add Configuration for XFCE Desktop
- Bifurcate
usersand Refine User Configuration - Support Automatic
packagesUpdates usingupdate.sh - Add Support for Automatic Deployments using
deploy-rs - Add Developer
shellsfor Multiple Programming Languages integrated withlorri
v4.5
- Use Calendar Versioning
- Use
nixConfig - Support Auto-Upgrade
- Support Multiple Users per Device
- Improve Security and Harden System
- Use PipeWire (with low-latency) for audio
- Use
nixos-generatorsfor Image Generation
v4.0
-
Use
nixConfig -
Bifurcate
devices- Refactor
lib.build.systemintobuild.isoandbuild.device
- Refactor
-
Improve
libHandling -
Improve Module Imports
-
Improve and Bifurcate
docs -
Handle
scriptsas packages -
Improve configuration
checks -
Achieve
systemIndependence -
Add
.editorconfigandnanorc -
Refactor
sopsEncrypted Secrets -
Stabilise and document
templates -
Fix
devshells,replandscripts -
Fix Module Imports and
inputsPatching -
Improve Mime Types Handling with
lib.xdg -
Use
advancedEphemeral Root File System Layout with ZFS -
Use
flake-compat,nix-gamingandnix-wayland -
Improve Code Consistency, reduce Complexity and fix Syntactic and Semantic Errors
- Use
pre-commit-hooksto improve configurationchecks - Use
nixfmtfor formatting code - Use
nix-linterto check stylistic errors
- Use
v3.0
- Upgrade to NixOS v21.11 (Porcupine)!
- Improve Package Declaration
- Add Support for Instant Nix REPL
- Add Support for patching
inputs - Improve usage of Developer Shells
- Import Modules using
nixosModules - Use
home-manageras a Module - Merge Device and User Configuration
- Move all program configuration and dotfiles to
files - Use
sops-nixatsecretsfor managing authentication credentials - Automatically map
modules,packages,overlays,shellsandinputs
v2.3
- Add
docsdirectory - Fix
.isoBoot and Install Errors - Improve Scripts with error-checking
- Add
direnvsupport atshells - Add Support for Nix Developer Shells at
shells - Use
secretsas aninputrather than as asubmodule - Improve CI with automatic
flake.lockupdate and dependency-checking - Bifurcate Flake
outputs(asconfiguration.nix),scriptsandoverlays
v2.1
- Simplify Installation
- Add
installScript - Add Support for creating Install Media
- Add overhauled
setupScript - Automatically build
.isoand publish release using CI
- Add
- Fix Home Activation
v2.0
- Add BTRFS (opt-in state) Configuration
- Improve Ephemeral Root Support with impermanence
- Improve Installation Experience
- Improve Home Activation
- Bifurcate Modules and Roles
- Reduce CI Time
- Add the Office role
v1.0
- Add Cachix Support
- Add Nix Shell Support
- Increase Readability
- Improve Package Management
- Under the hood CI changes
v0.7
- Improve Secrets Management using Private Submodule at
secrets - Overhaul Package Overrides
- Use
final: prev:instead ofself: super: - Add support for NUR
- Split System Scripts and import as overlay
- Refactor Package Overrides into
packages
- Use
- Add archived
dotfilesand revitalize existing ones - Improve Modulated Imports
- Improve Fonts Management
- Update README and
scripts
v0.5
- Added Support for Nix Flakes
- Added Custom Libraries for Device and User Management
- Created System Management Script
- Updated README and
installScript - Add full support for Multi-Device Configuration
- Use Better Repository Management
v0.1
- Added basic NixOS system configuration using GNOME and GTK+
- Added hardware support for 2 devices
- Added
setupscript - Added
home-managersupport and user dotfiles - Added Modulated Configuration
- Added Support for Nix User Repository
- Added Repository Pinning
- Added Essential Package Overlays
- Added Basic Password Management
- Added README
Known Limitations
- It is a hard requirement to clone the repository to
/etc/nixosin order to use it as intended - Home Configuration can't be decoupled from System
- Lack of automatic script checking
- Currently using a workaround for CI due to NixOS/nix#3978
- Wine Applications have to be manually updated
Last Updated: March 2024
If you like this project, consider leaving a star





