nix3-formatter-run(1)

πŸ“¦ version 2.35.3, in fedora 44

πŸ’… nix3-formatter-run(1) β€” the Nix manual, bestie edition ✨

okay so you're reading the manual page for nix3-formatter-run(1) from the Nix general commands manual, and honestly? it's giving glow-up-for-your-code. let's go 🫢

⚠️ Warning β€” this program is experimental and its interface is subject to change. no cap. treat it like a situationship, not a marriage πŸ’€

🌸 Name 🌸

nix formatter run β€” reformat your code in the standard style ✨ (basically it makes your files pretty, but like, correctly pretty, not just vibes)


πŸŽ€ Synopsis πŸŽ€

nix formatter run [option…] args…

πŸ¦‹ Description πŸ¦‹

so nix fmt (which is literally just an alias for nix formatter run, same girl different name πŸ’…) calls the formatter that's specified in the flake. that's it. that's the whole job.

want to send some flags to the formatter itself? use -- and then the flags. that's the doorway πŸšͺ✨

any arguments you pass get forwarded to the formatter too. bestie, typically those are the files you want formatted. like, the whole point.

also!!! the environment variable PRJ_ROOT (according to prj-spec) will be set to the absolute path to the directory containing the closest parent flake.nix relative to the current directory. it goes looking upward for its home πŸ πŸ”


🌈 Example 🌈

want to use the official Nix formatter? say less:

# flake.nix
{
  outputs = { nixpkgs, self }: {
    formatter.x86_64-linux = nixpkgs.legacyPackages.${system}.nixfmt-tree;
  };
}

iconic. periodt. πŸ‘‘


✨ Options ✨

  • --json β€” produce output in JSON format, suitable for consumption by another program. feeding the robots πŸ€–
  • --no-pretty β€” print compact JSON output on a single line, even when the output is a terminal. some commands may print multiple JSON objects on separate lines. see --pretty.
  • --pretty β€” print multi-line, indented JSON output for readability.
    • Default: indent if output is to a terminal.
    • This option is only effective when --json is also specified. (no --json, no party πŸ™ˆ)

πŸ’œ Common evaluation options πŸ’œ

  • --arg name expr β€” pass the value expr as the argument name to Nix functions.
  • --arg-from-file name path β€” pass the contents of file path as the argument name to Nix functions.
  • --arg-from-stdin name β€” pass the contents of stdin as the argument name to Nix functions.
  • --argstr name string β€” pass the string string as the argument name to Nix functions.
  • --debugger β€” start an interactive environment if evaluation fails. it's giving "we'll figure it out together" πŸ«‚
  • --eval-store store-url β€” the URL of the Nix store to use for evaluation, i.e. to store derivations (.drv files) and inputs referenced by them.
  • --impure β€” allow access to mutable paths and repositories. living dangerously, we love that for you πŸ’€βœ¨
  • --include / -I path β€” add path to search path entries used to resolve lookup paths.
    • This option may be given multiple times.
    • Paths added through -I take precedence over the nix-path configuration setting and the NIX_PATH environment variable. she's got seniority πŸ’…
  • --override-flake original-ref resolved-ref β€” override the flake registries, redirecting original-ref to resolved-ref.
  • --commit-lock-file β€” commit changes to the flake's lock file. commitment issues? not today πŸŽ€
  • --inputs-from flake-url β€” use the inputs of the specified flake as registry entries.
  • --no-registries β€” don't allow lookups in the flake registries.
DEPRECATED β€” use --no-use-registries instead. she's retired, let her rest 😭
  • --no-update-lock-file β€” do not allow any updates to the flake's lock file.
  • --no-write-lock-file β€” do not write the flake's newly generated lock file.
  • --output-lock-file flake-lock-path β€” write the given lock file instead of flake.lock within the top-level flake.
  • --override-input input-path flake-url β€” override a specific flake input (e.g. dwarffs/nixpkgs). the input path must not be empty. this implies --no-write-lock-file.
  • --recreate-lock-file β€” recreate the flake's lock file from scratch.
DEPRECATED β€” use nix flake update instead. ok boo, we've moved on 🫢
  • --reference-lock-file flake-lock-path β€” read the given lock file instead of flake.lock within the top-level flake.
  • --update-input input-path β€” update a specific flake input (ignoring its previous entry in the lock file).
DEPRECATED β€” use nix flake update instead. same energy, new era ✨
  • --debug β€” set the logging verbosity level to debug.
  • --log-format format β€” set the format of log output; one of raw, internal-json, bar or bar-with-logs.
  • --print-build-logs / -L β€” print full build logs on standard error.
  • --quiet β€” decrease the logging verbosity level. shhh 🀫
  • --verbose / -v β€” increase the logging verbosity level. tell me EVERYTHING πŸ‘€

🌟 Miscellaneous global options 🌟

  • --help β€” show usage information.
  • --offline β€” disable substituters and consider all previously downloaded files up-to-date.
  • --option name value β€” set the Nix configuration setting name to value (overriding nix.conf).
  • --refresh β€” consider all previously downloaded files out-of-date.
  • --repair β€” during evaluation, rewrite missing or corrupted files in the Nix store. during building, rebuild missing or corrupted store paths. she's a healer 🩹
  • --version β€” show version information.

πŸ’– Options that change the interpretation of installables πŸ’–

  • --expr expr β€” interpret installables as attribute paths relative to the Nix expression expr.
  • --file / -f file β€” interpret installables as attribute paths relative to the Nix expression stored in file. if file is the character -, then a Nix expression is read from standard input. implies --impure.
Note β€” see man nix.conf for overriding configuration settings with command line flags.

and that's the whole page bestie, you ate that 🫢 hope your code comes out ✨immaculate✨. this was nix3-formatter-run(1) from the Nix general commands manual β€” go forth and format, main character πŸ’…πŸ‘‘


πŸ“¦ where this page comes from