βοΈ Information
NixOS is a unique Linux distribution that employs an advanced package management system called Nix. With Nix, users can install and update software packages in isolated environments, enabling them to securely install multiple versions of software simultaneously.
In NixOS, dotfiles are akin to dotfiles found in other Unix-based operating systems, but they differ in that they use Nix expressions to organize system and application configurations. Nix expressions are configuration files that are written in Nix syntax, which can be used to define, install, and configure software packages, services, and other system components in NixOS.
By utilizing Nix expressions to organize dotfiles, NixOS provides an efficient and reliable way to manage configurations, allowing for easy reproducibility, version control, and consistent setups across multiple machines. Additionally, this approach provides a modular system that enables users to share, reuse, and modify their configurations easily.
For new users, it's important to note that the learning curve for NixOS can be steep, as it requires a different approach to package management and system configuration compared to other Linux distributions. However, with the benefits it offers, many users find it worth the effort to learn.
Typically, NixOS dotfiles consist of a collection of Nix expressions and scripts used to configure the system and applications.
There are several advantages to using NixOS as an operating system:
-
Reproducibility: Every package and dependency in NixOS is installed in an isolated environment, ensuring the right version is installed for the user's needs. Additionally, installations can be easily reproduced on other machines.
-
Consistent configuration: NixOS stores the operating system configuration in a centralized Nix configuration file, ensuring consistent setup on other machines.
-
Rollback: NixOS keeps a copy of every configuration change, making it easy to rollback to the previous configuration if a problem occurs.
-
Modularity: The Nix package manager and flake feature allow users to organize and prepare configurations as reusable packages or modules, making it easy to install new applications or change system configurations.
-
Easy application management: Applications and dependencies are installed in isolated environments, making it easy to install and remove applications without disrupting other system components.
-
Active community: The NixOS community is friendly and active, providing support and solutions for troubleshooting.
In summary, NixOS is a highly modular and consistent operating system that offers users complete control over their system configuration. It's an excellent choice for users who want to ensure reproducibility, consistency, and easy management of their software installations, but it does require a learning curve. However, many users find it worth the effort due to its benefits.
π§ Installation
I highly recommend creating your own configurations based on these dotfiles. Use this repository as a reference to customize your setup according to your preferences and requirements. Please note that these dotfiles were created for my specific hardware configuration, so use them at your own risk.
But anyway⦠let's move on to the installation process!
-
Download iso
# Yoink nixos-unstable wget -O nixos.iso https://channels.nixos.org/nixos-unstable/latest-nixos-minimal-x86_64-linux.iso # Write it to a flash drive cp nixos.iso /dev/sdX
-
Boot into the installer.
-
Switch to root user:
sudo -i
-
Partitioning
We create a 512MB EFI boot partition (
/dev/nvme0n1p1
) and the rest will be our LUKS encrypted physical volume for LVM (/dev/nvme0n1p2
).$ gdisk /dev/nvme0n1
o
(create new empty partition table)n
(add partition, 512M, type ef00 EFI)n
(add partition, remaining space, type 8e00 Linux LVM)w
(write partition table and exit)
Setup the encrypted LUKS partition and open it:
$ cryptsetup luksFormat /dev/nvme0n1p2 $ cryptsetup config /dev/nvme0n1p2 --label cryptroot $ cryptsetup luksOpen /dev/nvme0n1p2 enc
We create two logical volumes, a 24GB swap parition and the rest will be our root filesystem
$ pvcreate /dev/mapper/enc $ vgcreate vg /dev/mapper/enc $ lvcreate -L 24G -n swap vg $ lvcreate -l '100%FREE' -n root vg
Format partitions
$ mkfs.fat -F 32 -n boot /dev/nvme0n1p1 $ mkswap -L swap /dev/vg/swap $ swapon /dev/vg/swap $ mkfs.btrfs -L root /dev/vg/root
Mount partitions
$ mount -t btrfs /dev/vg/root /mnt # Create the subvolumes $ btrfs subvolume create /mnt/root $ btrfs subvolume create /mnt/home $ btrfs subvolume create /mnt/nix $ btrfs subvolume create /mnt/log $ umount /mnt # Mount the directories $ mount -o subvol=root,compress=zstd,noatime,ssd,space_cache=v2 /dev/vg/root /mnt $ mkdir -p /mnt/{home,nix,var/log} $ mount -o subvol=home,compress=zstd,noatime,ssd,space_cache=v2 /dev/vg/root /mnt/home $ mount -o subvol=nix,compress=zstd,noatime,ssd,space_cache=v2 /dev/vg/root /mnt/nix $ mount -o subvol=log,compress=zstd,noatime,ssd,space_cache=v2 /dev/vg/root /mnt/var/log # Mount boot partition $ mkdir /mnt/boot $ mount /dev/nvme0n1p1 /mnt/boot
-
Enable flakes
$ nix-shell -p nixFlakes
-
Install nixos from flake
$ nixos-install --flake 'github:rxyhn/yuki#lenovo'
-
Reboot, login as root, and change the password for your user using passwd
-
Log in as your normal user.
-
Install the home manager configuration
$ home-manager switch --flake 'github:rxyhn/yuki#rxyhn@lenovo'
π‘ Acknowledgements
|
---|
It worked perfectly on my machine, but I can't guarantee it will work on your machine |
Powered by NixOS/Linux x86_64 |
Other dotfiles