Wallpaper by Mikael Gustafsson.
- Computer settings are now more modular and located in a more sensible place.
- Micro's included files are shorter.
configuration.nixhas gained some comments.- Other minor changes for modularity and cleanliness.
- Removed
(build failure)comments on packages that, in fact, do build properly. I was still using an old manual tagging system when packages failed back then, and had forgotten to remove them. - The shared
config.user.namestring is now checked for characters and length. I hope I did that correctly. - Updated the README's screenshot.
- The computers (hosts) are now automatically selected by their
networking.hostNamename when rebuilding the system. The hostname and the file path where the device's/etc/nixos/computers/<your-pc>/settings.nixresides in must match.
For example, the hostname of my Ryzen 7-based computer isr7-pc, and itssettings.nixmodule resides in/etc/nixos/computers/r7-pc/settings.nix.
You can treat it like a flake's--hostoption, except without flakes, and automatic.
- Overhauled the MiDiPLUS SmartPAD macropad script.
- Since said script now starts as a systemd service, its startup command in Niri has been removed.
- Updated some Noctalia settings.
- Right-clicking on the power button now shows power profile options when available.
- Overhauled the power actions in Noctalia.
- Power actions are no longer enabled by default without a prefix in the program launcher (accidental reboots begone).
- Added
corefontsandvista-fontsfor additional compatibility when reading and editing documents from Windows computers.
- Transitionned from Noctalia Shell 4.X to Noctalia 5.X, as it is now considered stable. This is an upgrade in certain ways, downgrades in others, but it is snappier and lighterweight across the board. There may be some minor missing configurations; They will be added here gradually when discovered.
- Fixed duplicate
pkgs.lib.getBinin./programs/system-info.nix. - Btop has higher privileges to have access to more hardware sensors without the need to run it with
run0. - Switched from GDM to the Noctalia Greeter.
- Theming now has its own
configmodule to more easily share theming configuration across modules. - Switched to the Zen Kernel, left the option for the latest too just in case.
- Other little changes here and there.
This configuration is entirely NixOS, more specifically, based on the nixos-unstable-small channel. It makes no use of Nix Flakes, Home Manager, or Flatpaks. I have nothing against them, I simply find the idea of a "pure" NixOS configuration rather attractive. This may make some things harder or not possible, but it is (so far) fine with me.
The Display Manager is the Noctalia Greeter. It replaces GDM, and feels like a more natural and logical choice here.
Niri is the Wayland compositor used. It supports more hardware than Hyprland does (which is what I used to use), runs faster on my systems, and the scrollable-tilling model is too good to live without.
https://github.com/YaLTeR/niri
I also use the Oniri program, to automatically maximize a window when it is the only one present on a workspace.
https://github.com/Antiz96/oniri
Noctalia Shell is the desktop shell. It has done an excellent job at replacing every little other components, scripts, and programs I used to use to replicate a fraction of its functionalities.
https://github.com/noctalia-dev/noctalia-shell
This entire desktop experience is crafted by and for myself only. It will likely not fit most other people's needs and desires. However, you may feel free to take inspiration from this configuration; I have uploaded it publicly for this reason as well.
With this out of the way, we can now proceed to the installation instructions. These are the steps I take to install this NixOS configuration onto my devices; They may not be exactly what you want out of such a configuration, so, feel free to adapt them to your needs.
It is assumed, for these installations instructions, that you:
- Are familiar with Linux
- Are familiar with NixOS, or have at least used it once
- Are comfortable working within the command-line
- Are currently using a Linux distribution
- Have a stable power source and networking
- Have your device's firmware set up to boot and install NixOS properly
- Have read and acknowledge untested hardware and use-cases at the bottom of this README
Since this configuration is based on NixOS unstable (small), it is highly recommended to download the latest NixOS unstable ISO image.
I use my own graphical ISO; It is not ready for public use yet, but I might upload it here if it ever becomes ready.
The NixOS ISO is too big to fit on a CD or smaller. As such, a DVD or any removable and bootable storage medium with above 4 GB of storage space is necessary. I will be using a USB flash drive here and the instructions will assume as much, and it is also assumed that the current environment is already Linux-based.
To stay as dependency-free as possible, I will use dd to flash the downloaded ISO file to the flash drive, but you may use any other utility. Graphically, I like Fedora's Media Writer, or Linux Mint's mintstick utility.
First, we need to identify which drive we want to write the ISO file onto. We can do so with lsblk:
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
sda 8:112 1 28,7G 0 disk
└─sda1 8:113 1 28,7G 0 part
zram0 253:0 0 31,3G 0 disk [SWAP]
nvme0n1 259:0 0 931,5G 0 disk
├─nvme0n1p1 259:1 0 1G 0 part /boot
├─nvme0n1p2 259:2 0 10G 0 part
│ └─swap 254:0 0 10G 0 crypt [SWAP]
└─nvme0n1p3 259:3 0 920,5G 0 part
└─root 254:1 0 920,5G 0 crypt /home
/nix/store
/nix
/
Here, sda is the ~30 GB USB flash drive I want to use. All data on it will be erased once the ISO writing process begins.
We can now write the ISO file to the USB flash drive, with the following command with superuser privileges:
dd bs=4M if=latest-nixos-graphical-x86_64-linux.iso of=/dev/sda conv=fsync oflag=direct status=progress
Notes:
- Replace
latest-nixos-graphical-x86_64-linux.isowith the appropriate path and file name - Replace
/dev/sdawith the appropriate device to write the ISO file to
Insert the installation medium into the target computer, and start it. If your computer does not automatically boot to the installation medium, or do not know which key to press to open the boot menu, refer to your BIOS' settings and your motherboard manufacturer's documentation.
Once you have booted, make sure to configure your keyboard layout and networking if necessary. The default NixOS ISO lets you configure the key map in the TTY with the loadkeys command as a privileged user, and you can connect to a network using nmtui. Graphical environments come with their own utilities for this.
In my installation, I typically use an encrypted, single-drive setup, on an EFI system. You can easily adapt the following steps for a multi-drive setup and a BIOS-only system, though I will not document BIOS installations here until I can install NixOS on a BIOS-only system that is not as slow as my ThinkPad L510…
As before, command-line utilities will be used for maximum compatibility and minimum dependencies, but a lot of these steps can be done using graphical tools.
- Enter a shell as root with
sudo -i. - List the current storage devices with
lsblk, and identify the one you want to use.
In the case of this example, I will select/dev/sda, which is an empty 1 TB hard disk drive. Obviously, any data on it will be lost in the next few steps.
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
sda 8:0 0 931,6G 0 disk
sdb 8:112 1 28,7G 0 disk
└─sdb1 8:113 1 28,7G 0 part
- Open the desired storage device with fdisk.
fdisk /dev/sdaYou should see an output similar to this:
Welcome to fdisk (util-linux <version>).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Command (m for help):
- Create a GPT partition table by typing
gthen pressingEnter. - Create a boot partition by typing
n. - When asked about the partition number, type
1then pressEnter. - When asked about the first sector, it should be left unchanged, simply press
Enter. - When asked about the last sector, type
+1Gthen pressEnter. Note that you can change this size to be smaller or bigger, depending on the number of Linux Kernels you plan on keeping, especially if you keep lots of NixOS generations around.
If the drive was not empty at first, fdisk will warn you before continuing. Typeythen pressEnter. - Set the type of the boot partition by typing
tthen pressEnter. - When asked about the partition type, type
1then pressEnter.
- Create a swap partition by typing
n. - When asked about the partition number, it should be
2. - When asked about the first sector, it should be left unchanged.
- When asked about the last sector, type
+8Gthen pressEnter. Note that you can change this size to be smaller or bigger, depending on if you want to be able to hibernate your system, and other things.
If the drive was not empty at first, fdisk will warn you before continuing. Typeythen pressEnter. - Set the type of the swap partition by typing
tthen pressEnter. - When asked about the partition type, type
19then pressEnter.
- Create a root partition by typing
n. - When asked about the first and the last sector, they should be left unchanged.
If the drive was not empty at first, fdisk will warn you before continuing. Type
ythen pressEnter.
Until you execute a write, no changes are made to the disk, and you can safely exit at any time, so do not worry if you made mistakes. But to verify if you indeed did things properly, you can type p then press Enter to see what the final result will look like.
If something is off, you can type q then press Enter, and restart the process from step 3.
If everything is looking good, you can write the changes to disk (this WILL erase all data on it) by typing w then pressing Enter.
I use LUKS disk encryption. If you do not, you may skip the relevant encryption steps and adapt the steps for your setup.
- Set up LUKS encryption for the swap partition.
cryptsetup --verify-passphrase luksFormat --label swap /dev/sda2Replace sda2 with the swap partition you previously created.
2. Set up LUKS encryption for the root partition.
You may use the same password as the swap partition for convenience and faster boot.
cryptsetup --verify-passphrase luksFormat --label root /dev/sda3Replace sda3 with the root partition you previously created.
3. (Optional) Create backup headers to store somewhere safe.
This is useful in case they ever get corrupted, somehow. Keep them in a safe, external storage device after creating them.
cryptsetup luksHeaderBackup /dev/sda2 -header-backup-file luks-header-backup-swap.bin
cryptsetup luksHeaderBackup /dev/sda3 -header-backup-file luks-header-backup-root.bin- Open the encrypted partitions.
If you use an SSD, add the
--allow-discardscommand-line argument aftercryptsetup open.
cryptsetup open /dev/sda2 swap
cryptsetup open /dev/sda3 root- Format the swap volume.
mkswap -L Swap /dev/mapper/swap- Format the storage volume. I use Btrfs, but you may use whichever filesystem makes you feel superior. If you do not use Btrfs, skip or change the steps related to Btrfs subvolumes and options.
mkfs.btrfs -L Storage /dev/mapper/root- Format the boot partition.
mkfs.fat -F 32 -n BOOT /dev/sda1Replace sda1 with the boot partition you previously created.
- Turn the swap on.
swapon /dev/mapper/swap- Mount the root volume.
mount -v -t btrfs /dev/mapper/root /mnt- Create the Btrfs subvolumes.
Here, they will be
@(root),@home, and@nix.
btrfs subvolume create /mnt/@
btrfs subvolume create /mnt/@home
btrfs subvolume create /mnt/@nix- Unmount the root volume.
umount -v /mnt- Mount the root volume with the proper Btrfs subvolume. Additionally, I enable zstd compression.
mount -v -o subvol=@,compress=zstd:3 /dev/mapper/root /mnt- Create the mount points for the boot, home, and nix volumes.
mkdir -v /mnt/boot
mkdir -v /mnt/home
mkdir -v /mnt/nix- Mount the home and nix Btrfs subvolumes.
Additionally, I enable zstd compression, and enable
noatimefor the nix subvolume to avoid unnecessary writes.
mount -v -o subvol=@home,compress=zstd:3 /dev/mapper/root /mnt/home
mount -v -o subvol=@nix,compress=zstd:3,noatime /dev/mapper/root /mnt/nix- Mount the boot partition.
mount -v -o umask=077 /dev/sda1 /mnt/bootNow that the storage device is set up, we can now set up the NixOS configuration and install the final system.
- Generate the default NixOS configuration and automatically-generated hardware configuration file.
nixos-generate-config --root /mnt- Temporarily move the hardware configuration file
rsync -ah --progress /mnt/etc/nixos/hardware-configuration.nix ~/- Remove the default
configuration.nixmodule, since it will not be used.
rm -v /mnt/etc/nixos/configuration.nix- Clone this repository to
/mnt/etc/nixos/.
git clone https://github.com/Atemo-C/NixOS-configuration /mnt/etc/nixos/- Move the hardware configuration file to
/mnt/etc/nixos/computers/your-comutper-name. Replaceyour-computer-namewith the name of your computer.
mkdir -v /mnt/etc/nixos/computers/your-computer-name
rsync -ah --progress ~/hardware-configuration.nix /mnt/etc/nixos/computers/your-computer-name/- Get the UUID of your swap partition.
We will write it to
/mnt/etc/nixos/computers/your-computer-name/settings.nix; It will be at the bottom of the module.
blkid /dev/sda2 >> /mnt/etc/nixos/computers/your-computer-name/settings.nixThe root partition should be configured automatically, which is why only the step for the swap partition remains. However, you might want to also do this with the root partition, if you want to set up additional options, such as discarding for SSDs.
7. Open this module with your preferred text editor.
In this live environment, you can install the text editor of your choice with nix-env -iA nixos.your-text-editor-here.
your-editor-here /mnt/etc/nixos/computers/your-computer-name/settings.nix- In it, the UUIDs for the encrypted swap partition is located on the bottom of the file.
We need to add them to
boot.initrd.luks.devicessince NixOS does not automatically add it, and set up other settings, such as:
- Discard for SSDs using
boot.initrd.luks.devices.<name>.allowDiscards = true;; - Your computer's host name;
- The keyboard layout configuration;
- Filesystem-specific options (Btrfs compression, etc);
- Import modules that you may want to use on certain devices but not others (e.g. host virtualization, gaming, etc);
- Any other device-specific configuration that you may want. In this example, I will be configuring my main computer. If you need any help or inspiration, please have a look at the existing hardware configuration files in this repository, to see how certain things are done.
{ ... }: {
imports = [
# The main system configuration.
# Not importing it results in, well, no system.
../../configuration.nix
# The automatically-generated hardware configuration file.
# Not importing it results in, again, no system.
./hardware-configuration.nix
# Display configuration.
./display.nix
# Input devices and keyboard layout.
./input.nix
# Storage configuration.
./storage.nix
# GPU configuration and utilities.
./gpu.nix
# Virtualisation software.
../../virtualisation/virt-manager.nix
];
# Whether the installation process is allowed to modify EFI boot variables.
# Once installed and working, if after an update, it fails to "install" again,
# it should be safe to turn this option off, even if it is not ideal.
# We love firmware bugs.
boot.loader.efi.canTouchEfiVariables = true;
# Name of the computer over the network.
# For this NixOS configuration, it must be lower-case.
networking.hostName = "r7-pc";
nix.settings = {
# Limit the amount of cores used when building NixOS.
# This is done to give some responsiveness and RAM back,
# allowing the use of the system relatively normally when building.
cores = 14;
# Limit the number of maximum jobs running when building NixOS.
# This is mostly so that the output is neater, and I like to see
# programs compile one by one cleanly as well.
# Not optimal for faster rebuilds.
max-jobs = 1;
};
# Whether to enable fwupd, a DBus service allowing applications to update firmware.
services.fwupd.enable = true;
# Whether to enable Modem Mangaer, to handle cellular data.
systemd.services.ModemManager.enable = false;
}As you can see, the device's settings.nix module can also import other modules. This modularity allows for cleaner and more reusable parts across the systems, and more personalisations without having a single huge settings.nix file.
- Add the following lines to your
configuration.nixin theimportslist, making sure other devices are commented out with#:
./computers/your-computer-name/hardware-configuration.nix
./computers/your-computer-name/settings.nix- Modify the rest of the NixOS configuration to fit your needs. This includes things such as:
- The user's name and title;
- Enabling proprietary drivers for Turing and above NVIDIA GPUs;
- Localization settings, spell checking, timezone;
- Various other settings, programs, etc.
- Read all the following steps carefully before running the commands!
Install NixOS with the following command. You can add the
--no-root-passwordoption if you wish to not be able to log into therootaccount directly.
nixos-install -I nixos-config=/etc/nixos/computers/<your-computer>/settings.nix- Replace
your-computerwith the computer name you have selected. - Make sure your device's
networking.hostNameis the same as the name of the directory your computer'ssettings.nixresides in.
- Once NixOS is installed, set your user's password.
nixos-enter --root /mnt
passwd your-user-here
exit- You can now safely power off the system, remove the installation medium, and boot into the full NixOS installation.
- Single user;
- Personal computing;
- x86_64 desktop and laptops;
- The default user shell is the FISH shell;
- This entire configuration is for me, it may not work well for you.
- Accessibility features
- Touchscreen support
- Remote desktop through RDP or other
- Computers with:
- A non-x86_64 CPU architecture (not tested)
- Hybrid GPU setup (e.g. NVIDIA PRIME) (not tested)
- NVIDIA GPUs (I no longer have an NVIDIA GPU to test things with, so what is in this configuration is a best-effort attempt at making things work)
- Less than 4 GIB of RAM (Swap may be heavily used with less than 8 when building the system, or doing other Nix things… If you have very little RAM, I hope on your soul that you at least have a capable SSD to let the swapping happen; Otherwise, may Xenia the Linux Fox have mercy on your soul)
- Less than 64 GIB of storage (some Nix storage optimizations are already enabled).
Help is available in:
- The configuration.nix(5) man page
- The on-device manual by running
nixos-help - The online manual at https://nixos.org/manual/nixos/unstable/index.html
- The NixOS Wiki at https://wiki.nixos.org
- The Nix.dev documentation for the nix ecosystem at https://nix.dev
A searchable list of available packages can be found here:
• https://search.nixos.org/packages?channel=unstable
A searchable list of available options can be found here:
• https://search.nixos.org/options?channel=unstable
