Nix implementation for my Linux laptops, desktops, and homelab servers. Adapted from Misterio77's standard starter config with inspiration from EmergentMind's youtube tutorials, 8bitbuddhism, and many others.
List of common terms and their definitions (click to expand)
- Nix Language: a domain-specific, declarative, pure, functional, lazy-evaluated, dynamically typed, language
- Nix values: data types that are immutable, can be whole expressions themselves, are only computed when needed, and type-error detected at evaluation
- Nix Expressions: Nix lang code (functions) that describes how to build packages or configure systems
- Derivations: the backend build task; specifies all inputs, dependencies, and build steps of an expression
- Nix Packages Collection (Nixpkgs): a large repository of Nix expressions
- Nix Store: complex abstractions of immutable file system data (software packages, dependencies, etc.)
- Nix Package Manager: a command-line toolset, with an atomic update model, that:
- evaluates expressions into derivations
- builds packages from derivations
- manages the Nix Store (handles dependencies, ensures reproducibility), where packages are kept
- NixOS: Linux distro that has a system configuration entirely built with Nix
Implimented features and what they do (click to expand)
Contains
- Cachix: cache service of prebuilt binaries; speeds installs, avoids compilations
- Flakes: a schema for writing, referencing, and sharing Nix expressions
- consists of a filesystem tree with a flake.nix file in root directory; specifies:
- metadata about the flake
- inputs (expressions, pkg repos, other flakes) which are taken as dependencies
- outputs (pkg defs, dev-envs, NixOS configs, modules, etc.) are whatever the flake produces; ultimately given as Nix values, evaluated by the Nix package manager
- updates Nix package manager's CLI with the new/experimental commands
- version-pinning of pkgs and dependencies via flake.lock file (increases reproducibity)
- consists of a filesystem tree with a flake.nix file in root directory; specifies:
- Home Manager: home-directory management module; installs user programs, pkgs, and config files, sets env-variables, dotfiles, and any other arbitrary file
- Modules: to customize options, settings, and functionality in config
- segregation of system and user level modules, encapsulated by role or function
- Overlays: custom modifications, extensions, and patches of Nixpkgs
- Shells: clean, reproducible, and isolated environments
- Single source of truth: remote nixlab repo is where all systems:
- auto-push their updated flakes,
- auto-pull any hourly changes, and
- rebuild/evaluate from nightly
Aspirational
- Declarative virtualization systems
- Scripting for initial hardware configuration (disko)
- Support for various WMs and desktop environments (KDE, XFCE, and Sway)
- Custom packages and services
- Secret management system
- Impermanent system; declaratively built on boot and connected to storage drives for data persistence
Instalation directions and update commands (click to expand)
- Installation:
- Install NixOS with appropriate labelled partitions (boot, root, swap, home, shelf)
- Mount and setup local repo in new home partition:
- firstly,
nix-shell -p git wget curl
, - then (in the partition)
mkdir -p /temhr
, - finally
cd /temhr && git clone https://github.com/temhr/nixlab.git
- firstly,
- First rebuild:
sudo nixos-rebuild boot --flake github:temhr/nixlab#[HOSTNAME] --extra-experimental-features "nix-command flakes" && sudo reboot
- Updating systems imperatively:
- Flakes:
$ nix flake update --flake /home/temhr/nixlab
- NixOS:
$ sudo nixos-rebuild switch --flake /home/temhr/nixlab
- Cachix:
$ sudo cachix use [package_name]
- Shells:
$ nix develop /home/temhr/nixlab#<shell-name>
- Flakes:
- bin: various shell scripts
- cachix: prebuilt cached binaries to pull
- hardware: machine level configurations and devices
- common: machine-agnostic settings and options
- global: universal to all machines
- optional: machine selection required
- common: machine-agnostic settings and options
- home: user level configurations (home manager) and files
- common: user-agnostic settings and options
- files: various user related files and scripts
- global: universal to all users
- optional: user selection required
- temhr: user-specfic preferences
- common: user-agnostic settings and options
- hosts: system level configurations and files
- common: host-agnostic programs, services, users, etc.
- files: various host related scripts
- global: universal to all hosts
- optional: host selection required
- common: host-agnostic programs, services, users, etc.
- lib: templates and other helper nix-code
- modules: encapsulated packages and persistent applications
- home-manager: user-relevant modules
- nixos: system-relevant modules
- overlays: custom overrides and extensions
- default: repository switching via flags (pkgs.unstable, pkgs.stable)
- pkgs: custom written packages
- empty
- shells: temporary, isolated, shell environments
- flake.nix: entry point
- flake.lock: version pinner