From 46b66d8508324c9f93140da7b59e834af48832ce Mon Sep 17 00:00:00 2001 From: kawaiipunk Date: Wed, 27 May 2026 22:49:43 +0100 Subject: [PATCH] Added comments to flake --- flake.nix | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/flake.nix b/flake.nix index 8ba7c17..3970ddc 100644 --- a/flake.nix +++ b/flake.nix @@ -1,24 +1,45 @@ { + # Human-readable description of what this flake produces description = "Minimal NixOS Docker Swarm server"; + # Inputs — external dependencies that this flake depends on + # Each input is fetched and locked in flake.lock for reproducibility inputs = { + # The NixOS package collection, pinned to the 25.05 release branch + # This is the source of all packages and NixOS modules used in configuration.nix nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.05"; }; + # Outputs — what this flake produces (NixOS configs, formatter, etc.) + # self = this flake's source tree, nixpkgs = the input defined above + # @inputs captures all inputs for passing to modules via specialArgs outputs = { self, nixpkgs, ... }@inputs: { + # NixOS system configuration named "server" + # Referenced with --flake .#server in nixos-rebuild commands nixosConfigurations.server = nixpkgs.lib.nixosSystem { + # Target architecture — change to aarch64-linux for ARM servers system = "x86_64-linux"; + # Pass all flake inputs into modules so they can access them via `inputs` arg specialArgs = { inherit inputs; }; + # List of NixOS module files that make up the system configuration modules = [ + # Main system configuration (packages, services, firewall, etc.) ./configuration.nix + # Inline module for flake-specific Nix settings { + # Enable experimental Nix features required for flakes and nix command nix.settings.experimental-features = [ "nix-command" "flakes" ]; + # Register this flake's nixpkgs input as the system-wide nixpkgs registry + # This lets you run `nix run nixpkgs#htop` without needing channels nix.registry.nixpkgs.flake = nixpkgs; + # Point legacy Nix tools (nix-build, nix-shell) at this flake's nixpkgs + # Eliminates the need for /nix/var/nix/profiles/per-user/root/channels nix.nixPath = [ "nixpkgs=flake:nixpkgs" ]; } ]; }; + # Formatter for `nix fmt` — auto-formats .nix files using the official RFC 166 style formatter.x86_64-linux = nixpkgs.legacyPackages.x86_64-linux.nixfmt-rfc-style; }; }