Table of Contents
- Introduction
- Getting Started
- Minimal Installation Process
- Nix-Flake: Beginning of a Journey
- Doom Emacs
- Congratulations!
🎉 - Special Thanks
- Useful Links
Introduction
A hamerspace containing a declarative NixOS environment consisting of many hand-crafted configurations, ranging from: Kitty, Alacritty, Doom-Emacs, Zathura to many other applications which can be found in the ./home
directory.
WARNING: this repository, like other dotfile/configuration repositories, is subjected to change. Thus the reader ought to read through the commit history before blindly cloning, fetching or updating the necessary files required to power up their NixOS environment.
In this README I will attempt to explain how to replicate my NixOS setup or achieve similar feats. If you find this guide not as useful as it was designed to be, do submit an issue requesting a change for the specific sections you found to be confusing. Or submit a push request (PR) to this repository and hopefully we can produce better results together!
Throughout my Nix journey I’ve came across two interesting projects and among those projects are Nix-Flakes and Home-Manager, which will be introduced later in this README. These projects have been setup in such manner that allows its users to carefully tune their system environments to their liking!
One should note that this project is still in its early stages, henceforth one should familiarize themselves with the risks that comes with the usage of such experimental features.
Getting Started
Partitioning & Formatting
Here I advice you to follow to carefully written guide by the lovely NixOS members about partitions, how to setup your partitions & later format them to their desired file-systems.
WARNING
The following guide is written with nixos-gnome-21.05.1205.b72bde7c4a1-x86_64-linux.iso
in mind, meaning that the attempt to install your Nix-Flake system from the LiveUSB won’t work. You should instead proceed with a minimal NixOS installation and later attempt to upgrade to your Nix-Flake system!
Nix-Channels
Setup your environment ot use the bleeding edge repository of NixOS and also add Home-Manager to your nix-channels:
sudo nix-channel --add https://nixos.org/channels/nixos-unstable nixos
sudo nix-channel --update
Minimal Installation Process
In
nixos-gnome-21.05.1205.b72bde7c4a1-x86_64-linux.iso
it’s unfortunately not possible to setup your flake based system without having Nix fail the installation process. Thus the user ought to install a minimal setup and later switch to their flake-based system after rebooting their minimal setup.
Mount & Create Required Dirs
sudo mount /dev/disk/by-label/nixos /mnt
sudo mkdir -p /mnt/boot
sudo mount /dev/disk/by-label/boot /mnt/boot
To prevent future crashes throughout the installation process, enable your newly created swap partition:
sudo swapon /dev/sdX
Prepare System Environment for Nix-Flake
Don’t forget to append the following lines of code to your configuration.nix
:
nix.package = pkgs.nixUnstable;
nix.extraOptions = ''
experimental-features = nix-command flakes
'';
Nix-Flake: Beginning of a Journey
The reader should keep in mind that this guide documents how to replicate my personal setup and thus the reader ought to know that
modules/nixos/default.nix
have been specifically modified to use my system passwords. To change the hashed passwords, replace theusers.hashedPassword
with thehashedPassword
generated throughmkpasswd -m sha-512
.
Snowflake
&& ln -s
Nix-Files To Correct Dir
Git Clone git clone
your desired repository and because this guide is written with my personal flake repository in mind:
git clone https://github.com/Icy-Thought/Snowflake.git
Backup the contents of your current /etc/nixos
directory, you’ll need your auto-generated hardware-configuration.nix
file to later input in modules/hardware
.
I prefer to keep my configurations inside my git repository for easier management, but you are free to do whatever you deem saner in the following installation process:
cd Snowflake
sudo ln -s flake.nix /etc/nixos
sudo ln -s flake.lock /etc/nixos
Replacing Necessary Configuration Entries
hosts
Dir
Create Your Create a directory inside the hosts
with the name of the desired hostname for that device; let’s call this directory X
.
mkdir -p hosts/X
Now create a default.nix
file inside that folder and for the sake of speeding the process up, I suggest you copy over my thinkpad-e595/default.nix
to your directory (X
) and later customize it to your liking.
cd hosts && cp thinkpad-e595/default.nix X
Hardware-Configuration.nix
Place your newly generated hardware-configuration.nix
inside your hosts/X
and make sure to import your hardware-configuration.nix
in the default.nix
file of your device folder.
import = [ ./hardware-configuration.nix ];
Nautilus
& Dolphin
Hide Your File-System From By default, Nautilus & Dolphin does not hide system partitions from mounted devices category. Since this has not been the experience I have been accustomed to, I have chosen to hide those partitions from the mounted devices category of those file managers. I have also added several kernel parameters and other specific configurations for my setup in this repository, which you can find in my default.nix
file.
What you are required to edit is:
fileSystems
entries indefault.nix
.- The specific parts which you wish to exclude from your setup, such as: kernel parameters, modules to disable, packages to be installed among other configurations.
fileSystems."/boot" = {
device = "/dev/disk/by-label/boot";
fsType = "vfat";
options = [ "x-gvfs-hide" ]; # For hiding boot partition entry in Nautilus.
};
Installing Nix-Flake System
After completing your setup, there remains one command to be executed (device = folder name of your device placed inside hosts
, which in this case is X
:
sudo nixos-rebuild switch --flake '/etc/nixos#X --impure
reboot
Doom Emacs
If you have replicated my setup, you need to do nothing but git clone
doom-emacs repository and enable the emacs
module in your X/default.nix
:
modules.desktop.txtEditor.emacs.enable = true;
To proceed with the installation of doom-emacs on your newly installed/configured nix-flake system:
git clone --depth 1 https://github.com/hlissner/doom-emacs ~/.emacs.d
~/.emacs.d/bin/doom install
🎉
Congratulations! You have successful installed your/my personally hand-crafted/replicated Nix-Flake environment. I hope it suits your needs, if not then you are always welcome to propose changes or fork the project and customize the repository to your heart’s content!
Useful Links
- NixOS Manual: A manual for the newcomer to read and understand different parts of the NixOS distribution.
- Home-Manager: Helps you manage your
~/home
related configurations. - Nix Pills: A series written to familiarize the user with the Nix programming language.
- Nixpkgs Unstable: A manual which introduces the Nix-language to people unfamiliar with the wonders of this language.
- Nix Flake MVP: A written Nix guide by edolstra.
- A Tour of Nix: a beautifully crafted introduction into the Nix programming language.
Special Thanks
- hlissner/dotfiles: NixOS Flake structure! (inspiration)
- IvanMalison/dotfiles: XMonad + Taffybar!
- ayamir/nvimdots: Neovim Inspiration!