• Stars
    star
    162
  • Rank 225,006 (Top 5 %)
  • Language
    Nix
  • License
    GNU Affero Genera...
  • Created about 3 years ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A repository which contains my current Nix (flake-based) setup!

Snowflake

Stars Issues Size

Table of Contents

Desktop Preview

XMonad

XMonad

Neovim

Neovim

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, similar to other dotfile/configuration repositories, is subjected to change.

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. (Both projects 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

NixOS Installer

As of 22.05 the NixOS ISO comes equipped with a well-developed installer that reduces the "complexity" of installing NixOS on your device! Therefore manual intervention should not be required for a minimal installation.

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

Clone Snowflake and Link Files To Correct Path

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 place it inside its specified hosts/deviceX (where deviceX is the name of your device folder.

Replacing Necessary Configuration Entries

Snowflake Directory

Warning As of now, my snowflake directory is expected to be placed inside ~/git/icy-thought/. And for your configuration to work properly you are expected to place the directory in that exact location!

Modify snowflake.dir to point to the location where you are keeping the snowflake repository:

dir = mkOpt path (findFirst pathExists (toString ../.) [
"${config.user.home}/git/icy-thought/snowflake"
"/etc/snowflake"
]);

Remove wgConnect Directory

Note Files contained within the wgConnect directory are intended for my personal usage.

Command :

rm -rf ./modules/networking/wgConnect

If you choose to retain that directory, make sure to remove the files contained within that directory and replace it with your personal WireGuard config files.

Warning Failing to do so will result in nixos-rebuild failure because of the encrypted files!

Create Your Hosts Directory

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.

Note 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.

(Example): ThinkPad-E595 defined as a valid system environment.

import = [ ./hardware-configuration.nix ];

Hide Your FileSystem From Nautilus & Dolphin

Note By default, Nautilus & Dolphin does not hide system partitions from mounted devices category.

I have chosen to hide those partitions from the mounted devices category of the mentioned file managers. I have also added several kernel parameters and other device-specific configurations for my setup in this repository. (check hosts/deviceX)

What you are required to edit is:

  1. fileSystems entries in default.nix.
  2. 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.

(Example): hiding /boot from Nautilus mounted devices.

fileSystems."/boot" = {
  device = "/dev/disk/by-label/BOOT";
  fsType = "vfat";
  options = [ "x-gvfs-hide" ]; # For hiding boot partition entry in Nautilus.
};

Make sure to replace /dev/disk/by-uuid/xyz (or partuuid) with /dev/disk/by-label/X, where X follows the label you have choosen to name your partitions with during your partition setup.

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:

nixos-rebuild switch --use-remote-sudo --flake .#conf-name --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.editors.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