Skip to content

Nix Command Flags

Control the exact flags Panix passes to nix build, nix copy, nixos-install, and nix profile add.

CategoryFieldsBehavior
Default flagsexperimental_features, build_default_flags, copy_default_flags, nixos_install_default_flags, profile_add_default_flagsReplace the built-in base flags when set. Leave unset for built-in defaults, set to [] to clear them.
Extra flagsextra_flags (applies to nix build and nix copy only), build_flags, copy_flags, nixos_install_flagsAppend after the default flags. Accumulate through inheritance.

The final command is assembled as default flags + extra flags.

Used when the matching *_default_flags field is unset:

FieldBuilt-in default
experimental_features["--extra-experimental-features", "nix-command flakes"]
build_default_flags["--no-link", "--print-out-paths", "--keep-going"]
copy_default_flags["--no-check-sigs"]
nixos_install_default_flags["--no-root-passwd", "--no-channel-copy"]
profile_add_default_flags[] (none)
fleet:
nix:
# Default flags REPLACE the built-in base flags
build_default_flags: ["--no-link", "--print-out-paths"] # overrides build defaults
copy_default_flags: [] # clears copy defaults
# Extra flags APPEND after the default flags
extra_flags: ["--option", "sandbox", "false"] # build and copy
build_flags: ["--max-jobs", "8"] # nix build only
flakes:
my-flake:
installables:
nixosConfigurations:
webserver:
nix:
copy_flags: ["--compress"] # nix copy only
machines:
web-01:

The effective nix build flags are: ["--no-link", "--print-out-paths"] (defaults) + ["--option", "sandbox", "false"] + ["--max-jobs", "8"] (extra, accumulated).

The same pattern applies to non-nix commands:

  • rsync_default_flags (fleet/flake/installable/machine), default ["-rcPEx", "--mkpath"]
  • curl_default_flags (under bootstrap.kexec and bootstrap.nix), default ["--fail", "-#", "-L", "-C", "-"]

The rsync_default_flags defaults assume a modern rsync: --mkpath requires rsync 3.2.3 or newer on both ends (see Requirements).

Enable out_links to leave a GC-rooted symlink per built installable, so closures survive garbage collection:

Terminal window
panix build --out-links

or:

flags:
out_links: true
out_links_dir: .panix # default

Each outlink is <out_links_dir>/<flake>/<output_type>/<name>, following the installable xpath:

Terminal window
$ tree .panix
.panix
└── mainFlake
├── homeConfigurations
│ └── test-home -> /nix/store/...-home-manager-generation
└── nixosConfigurations
└── test-vm -> /nix/store/...-nixos-system-nixos-26.11

Bootstrapped installables also get a <name>-disko outlink for their disko script, so it cannot collide with the closure outlink.

With outlinks enabled, the Build phase drops --no-link from the built-in build defaults and passes --out-link <path> instead, keeping --print-out-paths so later phases still receive the store path. nix build creates the symlink (including parent directories) and registers it as an indirect GC root under /nix/var/nix/gcroots/auto/.

A literal --no-link in user-configured default flags is dropped, since it would contradict the outlink request; one in extra flags is never touched, and nix evaluates repeated flags last-wins, so it still disables outlink creation.

To release a built closure, remove its outlink and garbage-collect:

Terminal window
rm -rf .panix
nix store gc
  • Extra flags accumulate through inheritance (fleet, flake, installable): slices are appended, not replaced.
  • Default flags use override semantics: a child value is kept as-is; an unset (nil) field inherits the parent’s value.
  • Env vars merge through inheritance: parent entries are inherited, child keys override parent keys with the same name.

Some nix settings are only available via environment variables, with no CLI flag or nix.conf equivalent (e.g. NIX_USER_CONF_FILES, NIX_CONF_DIR):

FieldScopeBehavior
envAll nix commandsGlobal env applied to build, copy, nixos-install, and profile add
build_envnix build onlyMerged on top of env, specific keys override global
copy_envnix copy onlyMerged on top of env
nixos_install_envnixos-install onlyMerged on top of env
profile_add_envnix profile add onlyMerged on top of env
fleet:
nix:
env:
NIX_USER_CONF_FILES: /etc/nix/deploy-nix.conf
NIX_CONF_DIR: /etc/nix
flakes:
my-flake:
installables:
nixosConfigurations:
webserver:
nix:
env:
NIX_STORE_DIR: /mnt/nix/store
build_env:
NIX_DAEMON_SOCKET_PATH: /tmp/alt-nix-daemon.sock