# Flake Outputs In `flake.nix`, the `outputs` section defines the different outputs that a flake can produce during its build process. A flake can have multiple outputs simultaneously, which can include but are not limited to the following: - Nix packages: These are named `apps..`, `packages..`, or `legacyPackages..`. You can build a specific package using the command `nix build .#`. - Nix helper functions: These are named `lib.` and serve as libraries for other flakes to use. - Nix development environments: These are named `devShells` and provide isolated development environments. They can be accessed using the command `nix develop`. - NixOS configurations: These are named `nixosConfiguration` and represent specific NixOS system configurations. You can activate a configuration using the command `nixos-rebuild switch --flake .#`. - Nix templates: These are named `templates` and can be used as a starting point for creating new projects. You can generate a project using the command `nix flake init --template `. - Other user-defined outputs: These outputs can be defined by the user and may be used by other Nix-related tools. Here's an example excerpt from the NixOS Wiki that demonstrates the structure of the `outputs` section: ```nix { inputs = { # ...... }; outputs = { self, ... }@inputs: { # Executed by `nix flake check` checks.""."" = derivation; # Executed by `nix build .#` packages.""."" = derivation; # Executed by `nix build .` packages."".default = derivation; # Executed by `nix run .#` apps.""."" = { type = "app"; program = ""; }; # Executed by `nix run . -- ` apps."".default = { type = "app"; program = "..."; }; # Formatter (alejandra, nixfmt or nixpkgs-fmt) formatter."" = derivation; # Used for nixpkgs packages, also accessible via `nix build .#` legacyPackages.""."" = derivation; # Overlay, consumed by other flakes overlays."" = final: prev: { }; # Default overlay overlays.default = {}; # Nixos module, consumed by other flakes nixosModules."" = { config }: { options = {}; config = {}; }; # Default module nixosModules.default = {}; # Used with `nixos-rebuild --flake .#` # nixosConfigurations."".config.system.build.toplevel must be a derivation nixosConfigurations."" = {}; # Used by `nix develop .#` devShells.""."" = derivation; # Used by `nix develop` devShells."".default = derivation; # Hydra build jobs hydraJobs.""."" = derivation; # Used by `nix flake init -t #` templates."" = { path = ""; description = "template description goes here?"; }; # Used by `nix flake init -t ` templates.default = { path = ""; description = ""; }; }; } ```