Giter Club home page Giter Club logo

dotfiles's Introduction

Desktop

Version License Size NixOS

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.tk. You can follow along with my NixOS Desktop Series

GNOME Desktop

XFCE Desktop

Features

Built with Nix

  • Self-Contained
  • Device-Agnostic
  • Convenient and Automated
  • Hermetically Reproducible
  • Declarative and Derivational
  • Atomic, Generational and Immutable
  • Configures Multiple Users and Devices

Notable Features

  • Multiple Shell Configurations
  • Support for Multiple Desktop Environments
  • Cutting Edge Software - PipeWire, Wayland, ...!
  • Interactive repl to explore Syntax and Configuration
  • Automatically Builds and Deploys my Website
  • Authentication Credentials Management using the sops Module and gnupg Keys
  • Comprehensive User Configuration using the tightly integrated home-manager Module, with Support for Configuring Shared User Configuration, Global Conditionals and User-Specific Configuration
  • Support for Multiple Programming Language Development shells integrated with direnv and lorri
  • Ephemeral, Opt-In File System State using the impermanence Module and ZFS
  • Auto-Magic using flake-utils-plus Helper Functions
  • Automatic packages Updates using update.sh
  • Install Media and Device Images using nixos-generators Image Generation Modules
  • Automatic Deployment using the deploy-rs Tool
  • Advanced Configuration Checks using pre-commit-hooks.nix
  • Support for source Filters with nix-filter and gitignore.nix
  • Wrapped wine Applications 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 GNOME Terminal, xfce4 Terminal
Browser Firefox
Desktop Environments GNOME, XFCE

Structure

Overview of File Hierarchy

Outputs
$ nix flake show
github:maydayv7/dotfiles
├───apps
│   └───x86_64-linux
│       ├───default: app
│       └───nixos: app
├───channels: package repositories
├───checks
│   └───x86_64-linux
│       ├───Device-gnome: derivation 'nixos-rebuild'
│       ├───Device-xfce: derivation 'nixos-rebuild'
│       ├───activate: derivation 'deploy-rs-check-activate'
│       ├───commit: derivation 'pre-commit-run'
│       └───schema: derivation 'jsonschema-deploy-system'
├───deploy: automatc deployments
├───devShells
│   └───x86_64-linux
│       ├───cc: development environment 'C'
│       ├───commit: development environment 'nix-shell'
│       ├───default: development environment 'devShell'
│       ├───format: development environment 'Formatter'
│       ├───go: development environment 'Go'
│       ├───java: development environment 'Java'
│       ├───lisp: development environment 'Lisp'
│       ├───lua: development environment 'Lua'
│       ├───python: development environment 'Python'
│       ├───rust: development environment 'Rust'
│       ├───video: development environment 'Video'
│       └───website: development environment 'Website'
├───files: 'dotfiles' and program configuration
├───formatter
│   └───x86_64-linux: package 'treefmt-0.4.1'
├───installMedia: device install media
├───legacyPackages
│   └───x86_64-linux: omitted (use '--legacy' to show)
├───lib: utility library functions
├───nixosConfigurations
│   ├───Futura: NixOS configuration
│   └───Vortex: NixOS configuration
├───nixosModule: NixOS module
├───nixosModules
│   ├───apps: NixOS module
│   ├───base: NixOS module
│   ├───gui: NixOS module
│   ├───hardware: NixOS module
│   ├───nix: NixOS module
│   ├───secrets: NixOS module
│   ├───shell: NixOS module
│   └───user: NixOS module
├───overlays
│   ├───discord: Nixpkgs overlay
│   ├───gnome-terminal: Nixpkgs overlay
│   ├───google-chrome: Nixpkgs overlay
│   └───miscellaneous: Nixpkgs overlay
├───packages
│   └───x86_64-linux
│       ├───adw-gtk3: package 'adw-gtk3-v4.2'
│       ├───dotfiles: package 'Dotfiles-v12.0'
│       ├───fonts: package 'fonts-7'
│       ├───nixos: package 'nixos'
│       └───website: package 'website-stable'
├───templates
│   ├───default: template: Simple, Minimal NixOS Configuration
│   └───extensive: template: My Complete, Extensive NixOS Configuration
└───vmConfigurations
    └───Windows: Virtual Machine
  • checks: custom configuration checks
  • channels: configured system package repositories
┌── configuration.nix
├── flake.nix
├── flake.lock
├── .version
├── .templates
├── files
├── secrets
├── shells
├── site
├── repl.nix
├── users
├── devices
│   └── vm
├── scripts
│   └── nixos.nix
├── packages
│   └── overlays
├── lib
│   ├── compat
│   ├── build.nix
│   ├── map.nix
│   ├── pack.nix
│   └── types.nix
└── modules
    ├── apps
    ├── base
    ├── gui
    ├── hardware
    ├── nix
    ├── shell
    └── user
        └── passwords
  • configuration.nix: main system configuration file
  • flake.nix: repository version control using inputs
  • .version: system state version
  • .templates: custom Flakes configuration templates
  • files: dotfiles and program configuration
  • secrets: authentication credentials management using sops-nix
  • shells: sand-boxed shells for development purposes
  • site: personal website generated using zola
  • repl.nix: interactive shell to explore syntax and configuration
  • users: individual user-specific configuration
  • devices: system configuration for various devices
  • vm: declarative configuration to build multiple virtual machines
  • scripts: useful system management scripts
  • packages: locally built custom packages
  • overlays: overrides for pre-built packages
  • lib: custom functions designed for conveniently defining configuration
  • modules: custom configuration modules for additional functionality

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 or nix-shell ./lib/compat/shell.nix in the repository to install all required dependencies

  1. Prepare /etc/nixos:

    sudo mkdir /etc/nixos
    sudo chown $USER /etc/nixos && sudo chmod ugo+rw /etc/nixos
    cd /etc/nixos
    

  2. Clone this repository (and preferably initialize it using git):

    nix flake init -t github:maydayv7/dotfiles#extensive
    git init
    

  3. Install gnupg and generate a GPG Key for yourself (if you don't already have one), and include it in the .sops.yaml file (using gpg --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

    gpg --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@EMAIL
    
    Save the keys public.gpg and private.gpg in a secure location

  4. Import all required GPG Keys into a convenient location (like /etc/gpg) using gpg --homedir DIR import and specify it at config.sops.gnupg.home (Required for decryption of secrets on boot, can also be on an external drive)

  5. Make new secrets and passwords in the desired directories by appending the paths to .sops.yaml and then using the following command (The nixos script can be used to simplify the process):
    Replace PATH with the path to the secret

    sops --config /path/to/.sops.yaml -i PATH

  6. Add device-specific configuration by creating a new file in devices (bear in mind that the name of the file must be same as the HOSTNAME of your device), and if required, hardware configuration using the hardware.modules option

  7. Finally, run nixos-rebuild switch --flake /etc/nixos#HOSTNAME (as root) to switch to the configuration!

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: In order to directly use the configuration, you must first create a clone of this repository and follow steps 2 to 6 from the above section, and preferably upload it to a hosting platform like GitHub/GitLab

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#nixos
sudo ./result/bin/nixos 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 run github:nix-community/nixos-generators -- -f iso --flake github:maydayv7/dotfiles#DEVICE

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 ext4/BTRFS 25G
SWAP Area swap swap 8G
DATA Partition Files NTFS 10G

Procedure

To install the OS, just boot the Live USB and run sudo nixos install
If the image doesn't boot, try disabling the secure boot and RAID options from BIOS
After the reboot, run nixos setup in the newly installed system to finish setup
In case you are using the advanced filesystem scheme, you may need to set the boot flag zfs_force=1 on first boot

Automatic Deploy

The nixosConfigurations support automatic deployments using deploy-rs

To deploy a Device, simply run the following command:
Replace DEVICE with the name of Device to deploy

nix run github:serokell/deploy -- github:maydayv7/dotfiles#DEVICE
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. For starters, you can run nix flake init -t github:maydayv7/dotfiles in /etc/nixos for a basic Flakes-compatible system configuration. If you have any doubts, feel free to open an issue. 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.7)

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

If you have any doubts or suggestions, feel free to open an issue

Requirements

May change according to available hardware

  • UEFI Compatible System
  • Intel CPU + iGPU

License

All the files and scripts in this repository are licensed under the very permissive MIT License, allowing you to freely use, modify, copy, distribute, sell or give away the software, only requirement being that the license and copyright notice must be provided with it

Branches

There are two branches, stable and develop (when required). The stable branch can be used at any time, and consists of configuration that builds without failure, but the develop branch is a bleeding-edge testbed, and is not recommended to be used. Releases are always made from the stable branch after extensive testing

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

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

File System

The system may be set up using either a simple or advanced filesystem layout. The advanced ZFS encrypted opt-in state filesystem configuration allows for a vastly improved experience, preventing formation of cruft and exerting total control over the device state, by erasing the system at every boot, keeping only what's required

Data Storage

All important, persisted user files are stored at /data. Personal files and media are stored on an NTFS partition mounted to /data/files

Home Manager

The home-manager module is used in tandem with the system configuration in order to define user-specific configuration. The config.user.home 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
  • Dash to Panel: GNOME Shell Extension providing a highly customizable icon taskbar for maximized productivity
  • DNOME Discord Theme: Discord theme inspired by Adwaita, designed to integrate Discord with GNOME
  • Firefox GNOME Theme: GNOME Theme for the Mozilla Firefox Browser, used for better desktop integration
  • VS Code Adwaita Theme: Integrates Visual Studio Code with GNOME Desktop
  • KvLibadwaita Kvantum Theme: Integrates QT Apps with GNOME Desktop

Important Links

See: A Curated List of the Best Resources in the Nix Community

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! ;)


You can navigate to the README's present in the various directories to know more about them

Changelog

23.05 (v12)

  • Upgrade to NixOS v23.05 (Stoat)!
  • Drop cod, nix-linter, gedit, touchegg, vscode-server and mutter-rounded
  • Support Android Virtualisation using Waydroid
  • Drop compat Libraries
  • 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 nixos Script
  • Add gui.fonts.usershare
  • General Maintenance Updates
  • Use treefmt for Formatting Code

22.04 (v10)

  • Deprecate git-crypt Usage
  • 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-shell Shebangs
    • Add lib.build.script
  • Support Visual Studio Code Editor
  • Use alejandra for formatting code

v5.0

  • Improve channels Usage
  • Support source Filters
  • Refine git Configuration
  • Use wine Application Wrapper
  • Use System Independent library
  • Add Support for Ephemeral /home
  • Add Configuration for XFCE Desktop
  • Bifurcate users and Refine User Configuration
  • Support Automatic packages Updates using update.sh
  • Add Support for Automatic Deployments using deploy-rs
  • Add Developer shells for Multiple Programming Languages integrated with lorri

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-generators for Image Generation

v4.0

  • Use nixConfig

  • Bifurcate devices

    • Refactor lib.build.system into build.iso and build.device
  • Improve lib Handling

  • Improve Module Imports

  • Improve and Bifurcate docs

  • Handle scripts as packages

  • Improve configuration checks

  • Achieve system Independence

  • Add .editorconfig and nanorc

  • Refactor sops Encrypted Secrets

  • Stabilise and document templates

  • Fix devshells, repl and scripts

  • Fix Module Imports and inputs Patching

  • Improve Mime Types Handling with lib.xdg

  • Use advanced Ephemeral Root File System Layout with ZFS

  • Use flake-compat, nix-gaming and nix-wayland

  • Improve Code Consistency, reduce Complexity and fix Syntactic and Semantic Errors

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-manager as a Module
  • Merge Device and User Configuration
  • Move all program configuration and dotfiles to files
  • Use sops-nix at secrets for managing authentication credentials
  • Automatically map modules, packages, overlays, shells and inputs

v2.3

  • Add docs directory
  • Fix .iso Boot and Install Errors
  • Improve Scripts with error-checking
  • Add direnv support at shells
  • Add Support for Nix Developer Shells at shells
  • Use secrets as an input rather than as a submodule
  • Improve CI with automatic flake.lock update and dependency-checking
  • Bifurcate Flake outputs (as configuration.nix), scripts and overlays

v2.1

  • Simplify Installation
    • Add install Script
    • Add Support for creating Install Media
    • Add overhauled setup Script
    • Automatically build .iso and publish release using CI
  • 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 of self: super:
    • Add support for NUR
    • Split System Scripts and import as overlay
    • Refactor Package Overrides into packages
  • Add archived dotfiles and 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 install Script
  • 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 setup script
  • Added home-manager support 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/nixos in order to use it as intended
  • Need to completely transition to Wayland

Manually Packaged Apps

  • GNOME Extensions:
    • Fly Pie
  • VS Code Themes and Plugins
  • Discord Plugins
  • Wine Applications

Last Updated: September 2023

If you like this project, consider leaving a star

V 7
[email protected]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.