Illustration

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 DeployNixOS Series 3: Software Packaging 101One 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, to use a program not packaged in Nixpkgs yet on NixOS, the best way is to package it yourself by writing a packaging script in Nix,...
Illustration

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 DeployNixOS Series 3: Software Packaging 101This 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.Changelog2021-12-18: NixOS 21.11 still doesn't come with Flake functionality by default. Relevant information is updated.Basic configDuring NixOS's installation process, the nixos-generate-config tool should have generated an initial config file for you under /etc/nixos, with two files configuration.nix and hardware-configuration.nix. Ignore hardware-configuration....
Illustration

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 DeployNixOS Series 3: Software Packaging 101Right 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, so you will be able to generate config files with Nix, no matter how complicated that software is....