Skip to content

Temhr/nixlab

Repository files navigation

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.

Nix Ecosystem Terminology

  • 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:
    1. evaluates expressions into derivations
    2. builds packages from derivations
    3. manages the Nix Store (handles dependencies, ensures reproducibility), where packages are kept
  • NixOS: Linux distro that has a system configuration entirely built with Nix

Nixlab Features

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)
  • 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
  • Single source of truth: repo serves as the reference point where all systems auto-pull from, and push to

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
  • Making possible use of nix related libraries (Snowfall)

Implementations

  • Installation:
    1. Install NixOS with appropriate labelled partitions (boot, root, swap, home)
    2. First rebuild, with: flakes enabled and a proper hostname,
    3. Second rebuild, with sudo nixos-rebuild boot --flake github:temhr/nixlab && 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]

Repository Layout

  • bin: various user files and shell scripts
  • cachix: prebuilt cached binaries to pull
  • home-manager: user level configurations
  • hosts: system level configurations
    • common: host-agnostic configs (applications, programs, services, user-account, etc.)
    • nixace: workstation config.nix file
    • nixbase: stationary config.nix file
    • nixser: server config.nix file
    • nixtop: laptop config.nix file
  • lib: Unused nix-code dump
  • modules: custom configuration settings and options
    • home-manager: user-relevant preferences and extensions
    • nixos: system-relevant modules
  • overlays: custom overrides of nixpkgs
    • default: allows for nixos-unstable repository as pkgs.unstable
  • pkgs: custom written packages
    • empty
  • flake.nix: entry point
  • flake.lock: version pinner

About

NixOS config files

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published