46 lines
2.1 KiB
Nix
46 lines
2.1 KiB
Nix
{
|
|
# 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;
|
|
};
|
|
}
|