
NixOS Series 4: "Stateless" Operating System
List of NixOS Series Posts:NixOS Series 1: Why I fell in loveNixOS Series 2: Basic Config, Nix Flake & Batch DeployRecommended: NixOS & Nix Flakes - A Guide for Beginners by Ryan YinNixOS Series 3: Software Packaging 101NixOS Series 4: "Stateless" Operating SystemChangelog:2023-02-18: Fix config not applied to the root user, in the "Move Temp Directory of Nix Daemon" section.One of the most famous features of NixOS is that most software configurations on the system are generated and managed exclusively by a Nix-language config file. Even if such software modifies its config file while running, the config file will still be overwritten on the next Nix config switch or the next reboot.For example, if you run ls -alh /etc on a computer running NixOS,...

NixOS Series 3: Software Packaging 101
List of NixOS Series Posts:NixOS Series 1: Why I fell in loveNixOS Series 2: Basic Config, Nix Flake & Batch DeployRecommended: NixOS & Nix Flakes - A Guide for Beginners by Ryan YinNixOS Series 3: Software Packaging 101NixOS Series 4: "Stateless" Operating SystemOne characteristic of NixOS is that all binary applications and libraries are stored in /nix/store directory and managed by Nix package manager. This means that NixOS doesn't conform to the FHS standard of Linux, and there's not even a dynamic library loader like ld-linux-x86-64.so.2 in /lib or /lib64, let alone other shared libraries like libc.so. Therefore, unless the program is statically linked, binaries compiled for other Linux distros will not run on NixOS at all.Therefore,...

NixOS Series 2: Basic Config, Nix Flake & Batch Deploy
List of NixOS Series Posts:NixOS Series 1: Why I fell in loveNixOS Series 2: Basic Config, Nix Flake & Batch DeployRecommended: NixOS & Nix Flakes - A Guide for Beginners by Ryan YinNixOS Series 3: Software Packaging 101NixOS Series 4: "Stateless" Operating SystemThis is the second post in my NixOS series and mainly focuses on:Basic format of NixOS config files and how to edit themFlake functionality of Nix package managerDeploy-RS deployment toolThis post assumes that you've installed NixOS with NixOS's official installation manual.Changelog2023-05-10: Add a recommended post: NixOS & Nix Flakes - A Guide for Beginners by Ryan Yin.2021-12-18: NixOS 21.11 still doesn't come with Flake functionality by default. Relevant information is updated....

NixOS Series 1: Why I fell in love
List of NixOS Series Posts:NixOS Series 1: Why I fell in loveNixOS Series 2: Basic Config, Nix Flake & Batch DeployRecommended: NixOS & Nix Flakes - A Guide for Beginners by Ryan YinNixOS Series 3: Software Packaging 101NixOS Series 4: "Stateless" Operating SystemRight now, I'm gradually migrating my servers from Devuan Linux to NixOS. NixOS is a Linux distribution centered on a set of Nix configuration files located in /etc/nixos, which is used to install and configure the whole operating system. Because this configuration set defines ALL config files and packages on the system, as long as you use the same config files, you will absolutely get the same operating system every time you reinstall. Nix configuration language is also Turing complete,...