nh(1)

πŸ“¦ version 4.4.2, in nixos 26.05, nixpkgs unstable

πŸ’– NAME πŸ’–

nh β€” Yet Another Nix Helper β€” and yes bestie, this is the nh(1) manual page πŸ’…βœ¨


✨ SYNOPSIS ✨

nh [-v|--verbose]... [-q|--quiet]... [-e|--elevation-strategy]
       [-h|--help] [-V|--version] <subcommands>

πŸ¦‹ DESCRIPTION πŸ¦‹

Yet Another Nix Helper β€” that’s literally the description, and honestly? Iconic minimalism. No cap. πŸŽ€


πŸ’… OPTIONS πŸ’…

Okay so the options section also opens with Yet Another Nix Helper, and then it gives you this usage line:

Usage: nh [OPTIONS] <COMMAND>

Here’s the global option vibe check πŸ‘‘:

  • -v, --verbose β€” Increase logging verbosity. [default: 0]
  • -q, --quiet β€” Decrease logging verbosity. [default: 0]
  • -e, --elevation-strategy β€” Choose the privilege elevation strategy. It can be a path to an elevation program (e.g., /usr/bin/sudo), or one of: 'none' (no elevation), 'passwordless' (use elevation without password prompt for remote hosts with NOPASSWD configured), or 'auto' (automatically detect available elevation programs in order: doas, sudo, run0, pkexec). [env: NH_ELEVATION_STRATEGY]
  • -h, --help β€” Print help (see a summary with '-h').
  • -V, --version β€” Print version.

πŸ“ SUBCOMMAND πŸ“

This one is the NixOS functionality bestie πŸ’œ. It implements functionality mostly around but not exclusive to nixos-rebuild β€” iykyk.

Usage: os [OPTIONS] <COMMAND>

The os subcommand has these options:

  • -v, --verbose β€” Increase logging verbosity. [default: 0]
  • -q, --quiet β€” Decrease logging verbosity. [default: 0]
  • -e, --elevation-strategy β€” Choose the privilege elevation strategy. It can be a path to an elevation program (e.g., /usr/bin/sudo), or one of: 'none' (no elevation), 'passwordless' (use elevation without password prompt for remote hosts with NOPASSWD configured), or 'auto' (automatically detect available elevation programs in order: doas, sudo, run0, pkexec). [env: NH_ELEVATION_STRATEGY]
  • -h, --help β€” Print help (see a summary with '-h').

🌈 SUBCOMMAND: switch 🌈

Build and activate the new configuration, and make it the boot default. Main character energy fr fr πŸ‘‘πŸ”₯

Usage: switch [OPTIONS] [INSTALLABLE] [-- <EXTRA_ARGS>...]
  • -n, --dry β€” Only print actions, without performing them. [default: false]
  • -a, --ask β€” Ask for confirmation. [default: false]

🧚 Which installable to use 🧚

Nix accepts various kinds of installables:

  • [FLAKEREF[#ATTRPATH]] β€” Flake reference with an optional attribute path. [env: NH_FLAKE=] [env: NH_OS_FLAKE=] [env: NH_HOME_FLAKE=] [env: NH_DARWIN_FLAKE=]
  • -f, --file <FILE> [ATTRPATH] β€” Path to file with an optional attribute path. [env: NH_FILE=] [env: NH_ATTRP=]
  • -e, --expr <EXPR> [ATTRPATH] β€” Nix expression with an optional attribute path.
  • [PATH] β€” Path or symlink to a /nix/store path.

Now back to the switch option buffet πŸ“:

  • --no-nom β€” Don't use nix-output-monitor for the build process. [default: false]
  • -o, --out-link β€” Path to save the result link, defaults to using a temporary directory.
  • -d, --diff β€” Whether to display a package diff. [default: auto]
  • -j, --max-jobs β€” Number of concurrent jobs Nix should run.
  • --cores β€” Number of cores Nix should utilize.
  • --log-format β€” Logging format used by Nix.
  • -k, --keep-going β€” Continue building despite encountering errors. [default: false]
  • -K, --keep-failed β€” Keep build outputs from failed builds. [default: false]
  • --fallback β€” Attempt to build locally if substituters fail. [default: false]
  • --repair β€” Repair corrupted store paths. [default: false]
  • --builders β€” Explicitly define remote builders.
  • -I, --include β€” Paths to include.
  • -L, --print-build-logs β€” Print build logs directly to stdout. [default: false]
  • -t, --show-trace β€” Display tracebacks on errors. [default: false]
  • --accept-flake-config β€” Accept configuration from flakes. [default: false]
  • --refresh β€” Refresh flakes to the latest revision. [default: false]
  • --impure β€” Allow impure builds. [default: false]
  • --offline β€” Build without internet access. [default: false]
  • --no-net β€” Prohibit network usage. [default: false]
  • --recreate-lock-file β€” Recreate the flake.lock file entirely. [default: false]
  • --no-update-lock-file β€” Do not update the flake.lock file. [default: false]
  • --no-write-lock-file β€” Do not write a lock file. [default: false]
  • --no-use-registries β€” Do not use registries. [default: false]
  • --no-registries β€” Do not use registries (deprecated, use --no-use-registries). [default: false]
  • --commit-lock-file β€” Commit the lock file after updates. [default: false]
  • -Q, --no-build-output β€” Suppress build output. [default: false]
  • --use-substitutes β€” Use substitutes when copying. [default: false]
  • --json β€” Output results in JSON format. [default: false]
  • --option β€” Set a Nix configuration option (may be given multiple times).
  • --override-input β€” Override a specific flake input (may be given multiple times).
  • -u, --update β€” Update all flake inputs. [default: false]
  • -U, --update-input β€” Update the specified flake input(s).
  • -H, --hostname β€” When using a flake installable, select this hostname from nixosConfigurations. When unspecified, defaults to the local hostname for local deployments, and hostname of the target machine for remote deployments (see --target-host).
  • -s, --specialisation β€” Explicitly select some specialisation.
  • -S, --no-specialisation β€” Ignore specialisations. [default: false]
  • --install-bootloader β€” Install bootloader for switch and boot commands. [default: false]

Extra arguments passed to nix build β€” yep, that’s the line, bestie 🫢.

  • -R, --bypass-root-check β€” Don't panic if calling nh as root. [env: NH_BYPASS_ROOT_CHECK] [default: false]
  • --target-host β€” Deploy the built configuration to a different host over SSH.
  • --build-host β€” Build the configuration on a different host over SSH.
  • --no-validate β€” Skip pre-activation system validation checks. [env: NH_NO_VALIDATE] [default: false]
  • --show-activation-logs β€” Show activation logs. [env: NH_SHOW_ACTIVATION_LOGS] [default: false]
  • -v, --verbose β€” Increase logging verbosity. [default: 0]
  • -q, --quiet β€” Decrease logging verbosity. [default: 0]
  • -e, --elevation-strategy β€” Choose the privilege elevation strategy. It can be a path to an elevation program (e.g., /usr/bin/sudo), or one of: 'none' (no elevation), 'passwordless' (use elevation without password prompt for remote hosts with NOPASSWD configured), or 'auto' (automatically detect available elevation programs in order: doas, sudo, run0, pkexec). [env: NH_ELEVATION_STRATEGY]
  • -h, --help β€” Print help (see a summary with '-h').

πŸ› οΈ Build the new configuration and make it the boot default

Okay bestie, this is the glow-up moment: build the new config and make it the boot default. The usage is giving:

boot [OPTIONS] [INSTALLABLE] [-- <EXTRA_ARGS>...]
  • -n, --dry β€” only print actions, without performing them. [default: false] β€” literally just a vibe check, no actual changes πŸ’…
  • -a, --ask β€” ask for confirmation before doing the thing. [default: false] β€” consent is key, periodt 🫢

Which installable to use. Nix accepts various kinds of installables, and yes you have options:

  • [FLAKEREF[#ATTRPATH]] β€” flake reference with an optional attribute path. Env options: [env: NH_FLAKE=], [env: NH_OS_FLAKE=], [env: NH_HOME_FLAKE=], [env: NH_DARWIN_FLAKE=]
  • -f, --file <FILE> [ATTRPATH] β€” path to file with an optional attribute path. Env: [env: NH_FILE=], [env: NH_ATTRP=]
  • -e, --expr <EXPR> [ATTRPATH] β€” Nix expression with an optional attribute path.
  • [PATH] β€” path or symlink to a /nix/store path
  • --no-nom β€” don't use nix-output-monitor for the build process. [default: false] β€” some of us just prefer the raw feed, no cap 😌
  • -o, --out-link β€” path to save the result link, defaults to using a temporary directory.
  • -d, --diff β€” whether to display a package diff. [default: auto] β€” the diff is lowkey iconic, you might wanna see it.
  • -j, --max-jobs β€” number of concurrent jobs Nix should run.
  • --cores β€” number of cores Nix should utilize.
  • --log-format β€” logging format used by Nix.
  • -k, --keep-going β€” continue building despite encountering errors. [default: false] β€” the "we don't stop, we keep going" energy fr fr.
  • -K, --keep-failed β€” keep build outputs from failed builds. [default: false] β€” for the forensic girlies πŸ”
  • --fallback β€” attempt to build locally if substituters fail. [default: false] β€” backup plan activated.
  • --repair β€” repair corrupted store paths. [default: false] β€” store paths getting the spa treatment πŸ’†
  • --builders β€” explicitly define remote builders.
  • -I, --include β€” paths to include.
  • -L, --print-build-logs β€” print build logs directly to stdout. [default: false] β€” no hiding the receipts.
  • -t, --show-trace β€” display tracebacks on errors. [default: false] β€” give me the whole story, not just the error.
  • --accept-flake-config β€” accept configuration from flakes. [default: false]
  • --refresh β€” refresh flakes to the latest revision. [default: false] β€” gotta stay fresh ✨
  • --impure β€” allow impure builds. [default: false] β€” chaotic energy, but make it intentional.
  • --offline β€” build without internet access. [default: false]
  • --no-net β€” prohibit network usage. [default: false]
  • --recreate-lock-file β€” recreate the flake.lock file entirely. [default: false] β€” full reset, no crumbs.
  • --no-update-lock-file β€” do not update the flake.lock file. [default: false]
  • --no-write-lock-file β€” do not write a lock file. [default: false]
  • --no-use-registries β€” do not use registries. [default: false]
  • --no-registries β€” do not use registries. [default: false] β€” ⚠️ deprecated, use --no-use-registries instead. She's retired but still in the chat.
  • --commit-lock-file β€” commit the lock file after updates. [default: false]
  • -Q, --no-build-output β€” suppress build output. [default: false] β€” silence is golden.
  • --use-substitutes β€” use substitutes when copying. [default: false]
  • --json β€” output results in JSON format. [default: false] β€” for the data girlies.
  • --option β€” set a Nix configuration option (may be given multiple times).
  • --override-input β€” override a specific flake input (may be given multiple times).
  • -u, --update β€” update all flake inputs. [default: false]
  • -U, --update-input β€” update the specified flake input(s).
  • -H, --hostname β€” when using a flake installable, select this hostname from nixosConfigurations. When unspecified, defaults to the local hostname for local deployments, and hostname of the target machine for remote deployments (see --target-host). β€” hostname selection is main character energy πŸ‘‘
  • -s, --specialisation β€” explicitly select some specialisation.
  • -S, --no-specialisation β€” ignore specialisations. [default: false]
  • --install-bootloader β€” install bootloader for switch and boot commands. [default: false]
Extra arguments passed to nix build β€” yeah, you can pass those after the -- <EXTRA_ARGS>... in the usage line. Slay.
  • -R, --bypass-root-check β€” don't panic if calling nh as root. Env: [env: NH_BYPASS_ROOT_CHECK], [default: false]
  • --target-host β€” deploy the built configuration to a different host over SSH.
  • --build-host β€” build the configuration on a different host over SSH.
  • --no-validate β€” skip pre-activation system validation checks. Env: [env: NH_NO_VALIDATE], [default: false] β€” sometimes you just gotta skip the vibe check, but be careful bestie.
  • --show-activation-logs β€” show activation logs. Env: [env: NH_SHOW_ACTIVATION_LOGS], [default: false]
  • -v, --verbose β€” increase logging verbosity. [default: 0] β€” more tea, more details.
  • -q, --quiet β€” decrease logging verbosity. [default: 0] β€” shhh, she's resting.
  • -e, --elevation-strategy β€” choose the privilege elevation strategy. Can be a path to an elevation program (e.g., /usr/bin/sudo), or one of: 'none' (no elevation), 'passwordless' (use elevation without password prompt for remote hosts with NOPASSWD configured), or 'auto' (automatically detect available elevation programs in order: doas, sudo, run0, pkexec). Env: [env: NH_ELEVATION_STRATEGY] β€” yes, -e shows up twice in this whole installable/elevation situation; I don't make the rules, I just report them πŸ’€
  • -h, --help β€” print help (see a summary with -h). β€” help is always there for you 🫢

SUBCOMMAND</p> β€” test πŸ’…

build and activate the new config, bestie β€” this is the whole main character moment ✨

Usage: test [OPTIONS] [INSTALLABLE] [-- <EXTRA_ARGS>...]

Like, it builds your new configuration and activates it. Both. Slay.


πŸŽ€ OPTIONS πŸŽ€

  • -n, --dry β€” only print the actions, don't actually do them. window-shopping but for system rebuilds πŸ›οΈ
    • [default: false]
  • -a, --ask β€” ask for confirmation first. consent is iconic 🫢
    • [default: false]

πŸ¦‹ Which installable to use πŸ¦‹

okay so Nix is lowkey flexible about what you hand it β€” it accepts various kinds of installables, and here's the whole menu:

  • [FLAKEREF[#ATTRPATH]] β€” a flake reference, with an optional attribute path tacked on. the classic.
    • [env: NH_FLAKE=]
    • [env: NH_OS_FLAKE=]
    • [env: NH_HOME_FLAKE=]
    • [env: NH_DARWIN_FLAKE=]
  • -f, --file <FILE> [ATTRPATH] β€” path to a file, plus an optional attribute path.
    • [env: NH_FILE=]
    • [env: NH_ATTRP=]
  • -e, --expr <EXPR> [ATTRPATH] β€” a Nix expression, plus an optional attribute path. raw expression energy ✍️
  • [PATH] β€” a path or symlink pointing to a /nix/store path πŸ—‚οΈ

πŸ”₯ THE REST OF THE FLAGS πŸ”₯

  • --no-nom β€” don't use nix-output-monitor for the build process. no nom, no problem 😌
    • [default: false]
  • -o, --out-link β€” path to save the result link. defaults to using a temporary directory β€” very "I'll clean it up later, I promise" of it.
  • -d, --diff β€” whether to display a package diff πŸ‘€
    • [default: auto]
  • -j, --max-jobs β€” number of concurrent jobs Nix should run. go off, parallelism ✨
  • --cores β€” number of cores Nix should utilize πŸ’ͺ
  • --log-format β€” logging format used by Nix.
  • -k, --keep-going β€” keep building even when errors show up. unbothered, moisturized, in her lane 🌸
    • [default: false]
  • -K, --keep-failed β€” keep the build outputs from builds that failed. yes, we're keeping the receipts 🧾
    • [default: false]
  • --fallback β€” try to build locally if the substituters fail.
    • [default: false]
  • --repair β€” repair corrupted store paths 🩹
    • [default: false]
  • --builders β€” explicitly define remote builders. hi besties, build for me 🫢
  • -I, --include β€” paths to include.
  • -L, --print-build-logs β€” print build logs directly to stdout. no hiding πŸ‘€
    • [default: false]
  • -t, --show-trace β€” display tracebacks on errors. the full lore 😭
    • [default: false]
  • --accept-flake-config β€” accept configuration from flakes.
    • [default: false]
  • --refresh β€” refresh flakes to the latest revision. fresh out the oven πŸ“
    • [default: false]
  • --impure β€” allow impure builds. living dangerously, ngl πŸ’€
    • [default: false]
  • --offline β€” build without internet access.
    • [default: false]
  • --no-net β€” prohibit network usage entirely. airplane mode but make it Nix ✈️
    • [default: false]
  • --recreate-lock-file β€” recreate the flake.lock file entirely. scorched earth, periodt πŸ”₯
    • [default: false]
  • --no-update-lock-file β€” do not update the flake.lock file.
    • [default: false]
  • --no-write-lock-file β€” do not write a lock file.
    • [default: false]
  • --no-use-registries β€” do not use registries.
    • [default: false]
  • --no-registries β€” do not use registries. ⚠️ deprecated β€” use --no-use-registries instead, bestie, she's old news.
    • [default: false]
  • --commit-lock-file β€” commit the lock file after updates. git commit but make it flake πŸ“
    • [default: false]
  • -Q, --no-build-output β€” suppress build output. quiet luxury 🀫
    • [default: false]
  • --use-substitutes β€” use substitutes when copying.
    • [default: false]
  • --json β€” output results in JSON format. for the machine besties πŸ–₯️
    • [default: false]
  • --option β€” set a Nix configuration option. may be given multiple times! stack 'em up πŸ₯ž
  • --override-input β€” override a specific flake input. may be given multiple times! also stackable πŸ₯ž
  • -u, --update β€” update all flake inputs. everybody gets a glow-up πŸ’–
    • [default: false]
  • -U, --update-input β€” update the specified flake input(s).
  • -H, --hostname β€” when using a flake installable, select this hostname from nixosConfigurations.
    • When it's unspecified, it defaults to the local hostname for local deployments, and to the hostname of the target machine for remote deployments (see --target-host). she picks for you, king 🫑
  • -s, --specialisation β€” explicitly select some specialisation.
  • -S, --no-specialisation β€” ignore specialisations.
    • [default: false]
  • --install-bootloader β€” install the bootloader for the switch and boot commands.
    • [default: false]

🌈 Extra args 🌈

Extra arguments passed to nix build.

You stick these after the -- in [-- <EXTRA_ARGS>...]. iykyk.


πŸ‘‘ Deployment & activation vibes πŸ‘‘

  • -R, --bypass-root-check β€” don't panic if you're calling nh as root. no cap, she's just chill about it.
    • [env: NH_BYPASS_ROOT_CHECK]
    • [default: false]
  • --target-host β€” deploy the built configuration to a different host over SSH. long-distance relationship, but it works πŸ¦‹
  • --build-host β€” build the configuration on a different host over SSH. someone else does the heavy lifting πŸ’…
  • --no-validate β€” skip the pre-activation system validation checks. bold. risky. valid tbh πŸ™ˆ
    • [env: NH_NO_VALIDATE]
    • [default: false]
  • --show-activation-logs β€” show activation logs.
    • [env: NH_SHOW_ACTIVATION_LOGS]
    • [default: false]
  • -v, --verbose β€” increase logging verbosity. more words, more lore πŸ—£οΈ
    • [default: 0]
  • -q, --quiet β€” decrease logging verbosity. less words, more peace 🀫
    • [default: 0]
  • -e, --elevation-strategy β€” choose the privilege elevation strategy, bestie. this is the important one ✨

It can be a path to an elevation program (e.g. /usr/bin/sudo), or one of these:

  • 'none' β€” no elevation at all
  • 'passwordless' β€” use elevation without a password prompt, for remote hosts with NOPASSWD configured
  • 'auto' β€” automatically detect available elevation programs, in this order: doas, sudo, run0, pkexec

Exactly in that order. no shuffling 🎯

  • [env: NH_ELEVATION_STRATEGY]
  • -h, --help β€” print help (see a summary with -h). our lord and saviour πŸ™

🌸 SUBCOMMAND β€” build 🌸

bestie this is the one that actually builds your shiny new config πŸ’… it's giving main character energy fr fr

Usage:

build [OPTIONS] [INSTALLABLE] [-- <EXTRA_ARGS>...]
  • -n, --dry β€” just print the actions, don't do them. window shopping only πŸ›οΈ [default: false]
  • -a, --ask β€” asks you for confirmation first, because consent is iconic 🫢 [default: false]

πŸ‘‘ which installable to use

Nix is lowkey flexible and accepts a whole bunch of installables, no cap:

  • [FLAKEREF[#ATTRPATH]] β€” a flake reference with an optional attribute path ✨
    • [env: NH_FLAKE=]
    • [env: NH_OS_FLAKE=]
    • [env: NH_HOME_FLAKE=]
    • [env: NH_DARWIN_FLAKE=]
  • -f, --file <FILE> [ATTRPATH] β€” path to a file, with an optional attribute path
    • [env: NH_FILE=]
    • [env: NH_ATTRP=]
  • -e, --expr <EXPR> [ATTRPATH] β€” a Nix expression, with an optional attribute path
  • [PATH] β€” a path or symlink to a /nix/store path πŸ—‚οΈ

  • --no-nom β€” don't use nix-output-monitor for the build process ngl [default: false]
  • -o, --out-link β€” path to save the result link β€” if you skip it, it defaults to using a temporary directory
  • -d, --diff β€” whether to display a package diff πŸ‘€ [default: auto]
  • -j, --max-jobs β€” how many concurrent jobs Nix should run
  • --cores β€” how many cores Nix should utilize
  • --log-format β€” the logging format used by Nix
  • -k, --keep-going β€” keep building even when errors show up, she's resilient πŸ’ͺ [default: false]
  • -K, --keep-failed β€” keep the build outputs from failed builds [default: false]
  • --fallback β€” try to build locally if substituters fail [default: false]
  • --repair β€” repair corrupted store paths [default: false]
  • --builders β€” explicitly define remote builders
  • -I, --include β€” paths to include
  • -L, --print-build-logs β€” print build logs straight to stdout πŸ“œ [default: false]
  • -t, --show-trace β€” display tracebacks on errors [default: false]
  • --accept-flake-config β€” accept configuration from flakes [default: false]
  • --refresh β€” refresh flakes to the latest revision πŸŒ€ [default: false]
  • --impure β€” allow impure builds [default: false]
  • --offline β€” build without internet access 🚫🌐 [default: false]
  • --no-net β€” prohibit network usage [default: false]
  • --recreate-lock-file β€” recreate the flake.lock file entirely [default: false]
  • --no-update-lock-file β€” do not update the flake.lock file [default: false]
  • --no-write-lock-file β€” do not write a lock file [default: false]
  • --no-use-registries β€” do not use registries [default: false]
  • --no-registries β€” do not use registries β€” ⚠️ deprecated, use --no-use-registries instead [default: false]
  • --commit-lock-file β€” commit the lock file after updates [default: false]
  • -Q, --no-build-output β€” suppress build output 🀫 [default: false]
  • --use-substitutes β€” use substitutes when copying [default: false]
  • --json β€” output results in JSON format [default: false]
  • --option β€” set a Nix configuration option (may be given multiple times)
  • --override-input β€” override a specific flake input (may be given multiple times)
  • -u, --update β€” update all flake inputs πŸ”„ [default: false]
  • -U, --update-input β€” update the specified flake input(s)
  • -H, --hostname β€” when you're using a flake installable, select this hostname from nixosConfigurations

when unspecified, it defaults to the local hostname for local deployments, and to the hostname of the target machine for remote deployments (see --target-host) 🏠

  • -s, --specialisation β€” explicitly select some specialisation
  • -S, --no-specialisation β€” ignore specialisations [default: false]
  • --install-bootloader β€” install the bootloader for the switch and boot commands [default: false]

extra arguments passed to nix build β€” anything after the -- gets yeeted straight to nix build ✨

  • -R, --bypass-root-check β€” don't panic if you're calling nh as root 😱 [env: NH_BYPASS_ROOT_CHECK] [default: false]
  • --target-host β€” deploy the built configuration to a different host over SSH πŸš€
  • --build-host β€” build the configuration on a different host over SSH
  • --no-validate β€” skip the pre-activation system validation checks [env: NH_NO_VALIDATE] [default: false]
  • -v, --verbose β€” increase logging verbosity [default: 0]
  • -q, --quiet β€” decrease logging verbosity [default: 0]
  • -e, --elevation-strategy β€” choose the privilege elevation strategy πŸ‘‘

can be a path to an elevation program (e.g. /usr/bin/sudo), or one of: 'none' (no elevation), 'passwordless' (use elevation without a password prompt, for remote hosts with NOPASSWD configured), or 'auto' (automatically detect available elevation programs in order: doas, sudo, run0, pkexec) [env: NH_ELEVATION_STRATEGY]

  • -h, --help β€” print help (see a summary with -h)

🧚 SUBCOMMAND β€” repl 🧚

load the system in a repl, aka get your hands on it and poke around πŸ”

Usage:

repl [OPTIONS] [INSTALLABLE]

πŸŽ€ which installable to use

Nix accepts various kinds of installables, iykyk:

  • [FLAKEREF[#ATTRPATH]] β€” a flake reference with an optional attribute path
    • [env: NH_FLAKE=]
    • [env: NH_OS_FLAKE=]
    • [env: NH_HOME_FLAKE=]
    • [env: NH_DARWIN_FLAKE=]
  • -f, --file <FILE> [ATTRPATH] β€” path to a file, with an optional attribute path
    • [env: NH_FILE=]
    • [env: NH_ATTRP=]
  • -e, --expr <EXPR> [ATTRPATH] β€” a Nix expression, with an optional attribute path
  • [PATH] β€” a path or symlink to a /nix/store path πŸ—‚οΈ

  • -H, --hostname β€” when using a flake installable, select this hostname from nixosConfigurations
  • -v, --verbose β€” increase logging verbosity [default: 0]
  • -q, --quiet β€” decrease logging verbosity [default: 0]
  • -e, --elevation-strategy β€” choose the privilege elevation strategy πŸ‘‘

can be a path to an elevation program (e.g. /usr/bin/sudo), or one of: 'none' (no elevation), 'passwordless' (use elevation without a password prompt, for remote hosts with NOPASSWD configured), or 'auto' (automatically detect available elevation programs in order: doas, sudo, run0, pkexec) [env: NH_ELEVATION_STRATEGY]

  • -h, --help β€” print help (see a summary with -h)

πŸ¦‹ SUBCOMMAND β€” info πŸ¦‹

lists the available generations from a profile path β€” it's literally the receipts of everything you've ever built 🧾✨

Usage:

info [OPTIONS]
  • -P, --profile β€” path to Nix' profiles directory [default: /nix/var/nix/profiles/system]
  • --fields β€” a comma-delimited list of field(s) to display πŸ“‹
  • -v, --verbose β€” increase logging verbosity [default: 0]
  • -q, --quiet β€” decrease logging verbosity [default: 0]
  • -e, --elevation-strategy β€” choose the privilege elevation strategy πŸ‘‘

can be a path to an elevation program (e.g. /usr/bin/sudo), or one of: 'none' (no elevation), 'passwordless' (use elevation without a password prompt, for remote hosts with NOPASSWD configured), or 'auto' (automatically detect available elevation programs in order: doas, sudo, run0, pkexec) [env: NH_ELEVATION_STRATEGY]

  • -h, --help β€” print help (see a summary with -h)

πŸ’œ SUBCOMMAND β€” rollback πŸ’œ

rollback to a previous generation β€” the "oops bestie let's rewind" button βͺ😭

Usage:

rollback [OPTIONS]
  • -n, --dry β€” only print actions, without performing them [default: false]
  • -a, --ask β€” ask for confirmation [default: false]
  • -s, --specialisation β€” explicitly select some specialisation
  • -S, --no-specialisation β€” ignore specialisations [default: false]
  • -t, --to β€” rollback to a specific generation number (defaults to the previous generation) πŸ”’
  • -R, --bypass-root-check β€” don't panic if you're calling nh as root [env: NH_BYPASS_ROOT_CHECK] [default: false]
  • -d, --diff β€” whether to display a package diff [default: auto]
  • -v, --verbose β€” increase logging verbosity [default: 0]
  • -q, --quiet β€” decrease logging verbosity [default: 0]
  • -e, --elevation-strategy β€” choose the privilege elevation strategy πŸ‘‘

can be a path to an elevation program (e.g. /usr/bin/sudo), or one of: 'none' (no elevation), 'passwordless' (use elevation without a password prompt, for remote hosts with NOPASSWD configured), or 'auto' (automatically detect available elevation programs in order: doas, sudo, run0, pkexec) [env: NH_ELEVATION_STRATEGY]

  • -h, --help β€” print help (see a summary with -h)

πŸ’… SUBCOMMAND β€” build-vm: Build a NixOS VM image

okay bestie, this one's the vibe: you want a VM of your NixOS config, and nh is gonna build it for you ✨

Usage: build-vm [OPTIONS] [INSTALLABLE] [-- <EXTRA_ARGS>...]

πŸŽ€ the little options first

  • -n, --dry β€” only print the actions, don't actually do them. window shopping, basically. [default: false]
  • -a, --ask β€” ask for confirmation before doing stuff. consent era 🫢 [default: false]

πŸ¦‹ Which installable to use.

Nix is lowkey flexible about what you hand it β€” it accepts various kinds of installables:

  • [FLAKEREF[#ATTRPATH]] β€” a flake reference with an optional attribute path. the classic. [env: NH_FLAKE=] [env: NH_OS_FLAKE=] [env: NH_HOME_FLAKE=] [env: NH_DARWIN_FLAKE=]
  • -f, --file <FILE> [ATTRPATH] β€” path to file with an optional attribute path. [env: NH_FILE=] [env: NH_ATTRP=]
  • -e, --expr <EXPR> [ATTRPATH] β€” a Nix expression with an optional attribute path.
  • [PATH] β€” path or symlink to a /nix/store path. straight to the source, iykyk πŸ’€

πŸ”₯ the actual flags

  • --no-nom β€” don't use nix-output-monitor for the build process. [default: false]
  • -o, --out-link β€” path to save the result link, defaults to using a temporary directory.
  • -d, --diff β€” whether to display a package diff. [default: auto]
  • -j, --max-jobs β€” number of concurrent jobs Nix should run.
  • --cores β€” number of cores Nix should utilize.
  • --log-format β€” logging format used by Nix.
  • -k, --keep-going β€” continue building despite encountering errors. [default: false]
  • -K, --keep-failed β€” keep build outputs from failed builds. [default: false]
  • --fallback β€” attempt to build locally if substituters fail. [default: false]
  • --repair β€” repair corrupted store paths. [default: false]
  • --builders β€” explicitly define remote builders.
  • -I, --include β€” paths to include.
  • -L, --print-build-logs β€” print build logs directly to stdout. [default: false]
  • -t, --show-trace β€” display tracebacks on errors. [default: false]
  • --accept-flake-config β€” accept configuration from flakes. [default: false]
  • --refresh β€” refresh flakes to the latest revision. [default: false]
  • --impure β€” allow impure builds. [default: false]
  • --offline β€” build without internet access. [default: false]
  • --no-net β€” prohibit network usage. [default: false]
  • --recreate-lock-file β€” recreate the flake.lock file entirely. [default: false]
  • --no-update-lock-file β€” do not update the flake.lock file. [default: false]
  • --no-write-lock-file β€” do not write a lock file. [default: false]
  • --no-use-registries β€” do not use registries. [default: false]
  • --no-registries β€” do not use registries. ⚠️ deprecated, use --no-use-registries instead. [default: false]
  • --commit-lock-file β€” commit the lock file after updates. [default: false]
  • -Q, --no-build-output β€” suppress build output. [default: false]
  • --use-substitutes β€” use substitutes when copying. [default: false]
  • --json β€” output results in JSON format. [default: false]
  • --option β€” set a Nix configuration option (may be given multiple times).
  • --override-input β€” override a specific flake input (may be given multiple times).
  • -u, --update β€” update all flake inputs. [default: false]
  • -U, --update-input β€” update the specified flake input(s).
  • -H, --hostname β€” when using a flake installable, select this hostname from nixosConfigurations.

When unspecified, defaults to the local hostname for local deployments, and hostname of the target machine for remote deployments (see --target-host). 🫢

  • -s, --specialisation β€” explicitly select some specialisation.
  • -S, --no-specialisation β€” ignore specialisations. [default: false]
  • --install-bootloader β€” install bootloader for switch and boot commands. [default: false]

🌸 Extra arguments passed to nix build

that's the -- <EXTRA_ARGS>... part in the usage line β€” anything after -- gets yeeted straight at nix build. iconic.

  • -R, --bypass-root-check β€” don't panic if calling nh as root. [env: NH_BYPASS_ROOT_CHECK] [default: false]
  • --target-host β€” deploy the built configuration to a different host over SSH.
  • --build-host β€” build the configuration on a different host over SSH.
  • --no-validate β€” skip pre-activation system validation checks. [env: NH_NO_VALIDATE] [default: false]
  • -B, --with-bootloader β€” build with bootloader. bootloader is bypassed by default. [default: false]
  • -r, --run β€” run the VM immediately after building. [default: false] πŸƒβ€β™€οΈπŸ’¨
  • -v, --verbose β€” increase logging verbosity. [default: 0]
  • -q, --quiet β€” decrease logging verbosity. [default: 0]
  • -e, --elevation-strategy β€” choose the privilege elevation strategy. [env: NH_ELEVATION_STRATEGY]

can be a path to an elevation program (e.g., /usr/bin/sudo), or one of: 'none' (no elevation), 'passwordless' (use elevation without password prompt for remote hosts with NOPASSWD configured), or 'auto' (automatically detect available elevation programs in order: doas, sudo, run0, pkexec). the main character of privilege escalation tbh πŸ‘‘

  • -h, --help β€” print help (see a summary with '-h').

and yes, bestie, -e shows up twice in this list β€” once for --expr up in the installables, once for --elevation-strategy down here. that's just how the page is written, no cap 🫠

πŸ’… SUBCOMMAND: build-image πŸ’…

Bestie, this one builds you a NixOS disk-image variant. Like, an actual image. For a disk. Iconic behavior honestly ✨

Usage: build-image [OPTIONS] --image-variant <IMAGE_VARIANT>
[INSTALLABLE] [-- <EXTRA_ARGS>...]
  • -n, --dry β€” only prints what it would do, doesn't actually do it 🫢 (think of it as the vibe-check mode) [default: false]
  • -a, --ask β€” asks you for confirmation first, because consent is main character energy [default: false]

🌸 Which installable to use

Nix accepts various kinds of installables, and yes you should pick one:

  • [FLAKEREF[#ATTRPATH]] β€” a flake reference with an optional attribute path ✨
    • [env: NH_FLAKE=]
    • [env: NH_OS_FLAKE=]
    • [env: NH_HOME_FLAKE=]
    • [env: NH_DARWIN_FLAKE=]
  • -f, --file <FILE> [ATTRPATH] β€” path to file with an optional attribute path πŸŽ€
    • [env: NH_FILE=]
    • [env: NH_ATTRP=]
  • -e, --expr <EXPR> [ATTRPATH] β€” a Nix expression with an optional attribute path πŸ¦‹
  • [PATH] β€” a path or symlink to a /nix/store path ⭐
πŸ’€ Heads up: -e shows up again way down the page for --elevation-strategy. Not me fixing it β€” I'm just the messenger, fr fr.
  • --no-nom β€” don't use nix-output-monitor for the build process [default: false]
  • -o, --out-link β€” path to save the result link; it defaults to using a temporary directory 🧚
  • -d, --diff β€” whether to display a package diff [default: auto]
  • -j, --max-jobs β€” number of concurrent jobs Nix should run πŸ”₯
  • --cores β€” number of cores Nix should utilize
  • --log-format β€” logging format used by Nix
  • -k, --keep-going β€” keep building even when it hits errors, stubborn queen behavior [default: false]
  • -K, --keep-failed β€” keep the build outputs from failed builds [default: false]
  • --fallback β€” try building locally if substituters fail [default: false]
  • --repair β€” repair corrupted store paths [default: false]
  • --builders β€” explicitly define remote builders πŸ‘‘
  • -I, --include β€” paths to include
  • -L, --print-build-logs β€” print build logs straight to stdout [default: false]
  • -t, --show-trace β€” display tracebacks on errors [default: false]
  • --accept-flake-config β€” accept configuration from flakes [default: false]
  • --refresh β€” refresh flakes to the latest revision [default: false]
  • --impure β€” allow impure builds (living dangerously, love that) [default: false]
  • --offline β€” build without internet access [default: false]
  • --no-net β€” prohibit network usage [default: false]
  • --recreate-lock-file β€” recreate the flake.lock file entirely [default: false]
  • --no-update-lock-file β€” do not update the flake.lock file [default: false]
  • --no-write-lock-file β€” do not write a lock file [default: false]
  • --no-use-registries β€” do not use registries [default: false]
  • --no-registries β€” do not use registries 🫠 deprecated, use --no-use-registries [default: false]
  • --commit-lock-file β€” commit the lock file after updates [default: false]
  • -Q, --no-build-output β€” suppress build output, shhh 🀫 [default: false]
  • --use-substitutes β€” use substitutes when copying [default: false]
  • --json β€” output results in JSON format [default: false]
  • --option β€” set a Nix configuration option (may be given multiple times) ✨
  • --override-input β€” override a specific flake input (may be given multiple times)
  • -u, --update β€” update all flake inputs [default: false]
  • -U, --update-input β€” update the specified flake input(s)
  • -H, --hostname β€” when using a flake installable, select this hostname from nixosConfigurations

When it's unspecified, it defaults to the local hostname for local deployments, and the hostname of the target machine for remote deployments (see --target-host). 🫢

  • -s, --specialisation β€” explicitly select some specialisation
  • -S, --no-specialisation β€” ignore specialisations [default: false]
  • --install-bootloader β€” install bootloader for switch and boot commands [default: false]
  • Extra arguments passed to nix build β€” you drop these after -- in the usage line πŸ’œ
  • -R, --bypass-root-check β€” don't panic if calling nh as root
    • [env: NH_BYPASS_ROOT_CHECK]
    • [default: false]
  • --target-host β€” deploy the built configuration to a different host over SSH 🌈
  • --build-host β€” build the configuration on a different host over SSH
  • --no-validate β€” skip pre-activation system validation checks πŸ™ˆ
    • [env: NH_NO_VALIDATE]
    • [default: false]
  • --image-variant β€” image variant [required] ⚠️ yeah, this one is not optional, bestie
  • -v, --verbose β€” increase logging verbosity [default: 0]
  • -q, --quiet β€” decrease logging verbosity [default: 0]
  • -e, --elevation-strategy β€” choose the privilege elevation strategy πŸŽ€

Can be a path to an elevation program (e.g., /usr/bin/sudo), or one of: 'none' (no elevation), 'passwordless' (use elevation without password prompt for remote hosts with NOPASSWD configured), or 'auto' (automatically detect available elevation programs in order: doas, sudo, run0, pkexec)

  • [env: NH_ELEVATION_STRATEGY]
  • -h, --help β€” print help (see a summary with -h) ✨

πŸ¦‹ SUBCOMMAND: home πŸ¦‹

Home-manager functionality. Yes, the whole home-manager situation lives here πŸ’–

Usage: home [OPTIONS] <COMMAND>
  • -v, --verbose β€” increase logging verbosity [default: 0]
  • -q, --quiet β€” decrease logging verbosity [default: 0]
  • -e, --elevation-strategy β€” choose the privilege elevation strategy πŸ‘‘

Can be a path to an elevation program (e.g., /usr/bin/sudo), or one of: 'none' (no elevation), 'passwordless' (use elevation without password prompt for remote hosts with NOPASSWD configured), or 'auto' (automatically detect available elevation programs in order: doas, sudo, run0, pkexec)

  • [env: NH_ELEVATION_STRATEGY]
  • -h, --help β€” print help (see a summary with -h) 🫢

✨ SUBCOMMAND ✨

Okay bestie, this one is THE one. This is the subcommand that actually builds and activates your home-manager config. πŸ’… Literally the main character of the whole home-manager situation.

Usage: switch [OPTIONS] [INSTALLABLE] [-- <EXTRA_ARGS>...]
  • -n, --dry β€” only prints out what it would do, no actual doing 🫢 [default: false]
  • -a, --ask β€” asks you for confirmation before it goes off [default: false]

🌸 Which installable to use.

Nix is kinda flexible about what you hand it, ngl. It accepts various kinds of installables:

  • [FLAKEREF[#ATTRPATH]] β€” a flake reference with an optional attribute path πŸ’–
    • [env: NH_FLAKE=]
    • [env: NH_OS_FLAKE=]
    • [env: NH_HOME_FLAKE=]
    • [env: NH_DARWIN_FLAKE=]
  • -f, --file <FILE> [ATTRPATH] β€” path to a file, with an optional attribute path πŸ“
    • [env: NH_FILE=]
    • [env: NH_ATTRP=]
  • -e, --expr <EXPR> [ATTRPATH] β€” a Nix expression, with an optional attribute path ✨
  • [PATH] β€” a path or a symlink pointing at a /nix/store path πŸŽ€

  • --no-nom β€” don't use nix-output-monitor for the build process, like, at all [default: false]
  • -o, --out-link β€” the path where the result link gets saved; if you don't give one it defaults to using a temporary directory πŸ”—
  • -d, --diff β€” whether to display a package diff [default: auto]
  • -j, --max-jobs β€” how many concurrent jobs Nix should run πŸƒβ€β™€οΈπŸ’¨
  • --cores β€” how many cores Nix should utilize
  • --log-format β€” the logging format used by Nix
  • -k, --keep-going β€” keeps building even when it hits errors, stubborn queen behaviour [default: false]
  • -K, --keep-failed β€” keeps the build outputs from builds that failed [default: false]
  • --fallback β€” tries to build locally if the substituters fail [default: false]
  • --repair β€” repairs corrupted store paths 🩹 [default: false]
  • --builders β€” explicitly define your remote builders
  • -I, --include β€” paths to include
  • -L, --print-build-logs β€” prints build logs straight to stdout πŸ“œ [default: false]
  • -t, --show-trace β€” displays tracebacks when errors happen [default: false]
  • --accept-flake-config β€” accepts configuration from flakes [default: false]
  • --refresh β€” refreshes flakes to the latest revision πŸ”„ [default: false]
  • --impure β€” allows impure builds [default: false]
  • --offline β€” builds with no internet access 🚫🌐 [default: false]
  • --no-net β€” prohibits network usage [default: false]
  • --recreate-lock-file β€” recreates the flake.lock file entirely, from scratch, no leftovers [default: false]
  • --no-update-lock-file β€” does not update the flake.lock file [default: false]
  • --no-write-lock-file β€” does not write a lock file at all [default: false]
  • --no-use-registries β€” does not use registries [default: false]
  • --no-registries β€” does not use registries (deprecated, use --no-use-registries) ⚠️ [default: false]
  • --commit-lock-file β€” commits the lock file after updates [default: false]
  • -Q, --no-build-output β€” suppresses build output 🀫 [default: false]
  • --use-substitutes β€” uses substitutes when copying [default: false]
  • --json β€” outputs results in JSON format [default: false]
  • --option β€” sets a Nix configuration option (may be given multiple times) πŸ”
  • --override-input β€” overrides a specific flake input (may be given multiple times) πŸ”
  • -u, --update β€” updates all flake inputs [default: false]
  • -U, --update-input β€” updates the specified flake input(s)
  • -c, --configuration β€” the name of the flake homeConfigurations attribute, like username@hostname

If you leave it unspecified, it'll try <username>@<hostname> and then <username> πŸ’«

  • -s, --specialisation β€” explicitly selects some specialisation
  • -S, --no-specialisation β€” ignores specialisations [default: false]

πŸ¦‹ Extra arguments passed to nix build

  • -b, --backup-extension β€” moves existing files out of the way by backing them up with this file extension πŸ’Ύ
  • --show-activation-logs β€” shows activation logs
    • [env: NH_SHOW_ACTIVATION_LOGS]
    • [default: false]
  • --build-host β€” builds the configuration on a different host over SSH 🌐
  • -v, --verbose β€” increases logging verbosity [default: 0]
  • -q, --quiet β€” decreases logging verbosity [default: 0]
  • -e, --elevation-strategy β€” chooses the privilege elevation strategy πŸ‘‘

Can be a path to an elevation program (e.g., /usr/bin/sudo), or one of: 'none' (no elevation), 'passwordless' (use elevation without a password prompt, for remote hosts with NOPASSWD configured), or 'auto' (automatically detect available elevation programs in order: doas, sudo, run0, pkexec)

  • [env: NH_ELEVATION_STRATEGY]
  • -h, --help β€” prints help (see a summary with '-h') πŸ’–

✨ SUBCOMMAND ✨

And this one is the lowkey sibling β€” it just builds a home-manager configuration. Doesn't activate it. No cap. πŸŽ€

Usage: build [OPTIONS] [INSTALLABLE] [-- <EXTRA_ARGS>...]
  • -n, --dry β€” only prints actions, without performing them [default: false]
  • -a, --ask β€” asks for confirmation [default: false]

🌸 Which installable to use.

Same deal as before β€” Nix accepts various kinds of installables:

  • [FLAKEREF[#ATTRPATH]] β€” a flake reference with an optional attribute path πŸ’–
    • [env: NH_FLAKE=]
    • [env: NH_OS_FLAKE=]
    • [env: NH_HOME_FLAKE=]
    • [env: NH_DARWIN_FLAKE=]
  • -f, --file <FILE> [ATTRPATH] β€” path to a file, with an optional attribute path πŸ“
    • [env: NH_FILE=]
    • [env: NH_ATTRP=]
  • -e, --expr <EXPR> [ATTRPATH] β€” a Nix expression, with an optional attribute path ✨
  • [PATH] β€” a path or a symlink pointing at a /nix/store path πŸŽ€

  • --no-nom β€” don't use nix-output-monitor for the build process [default: false]
  • -o, --out-link β€” the path where the result link gets saved; defaults to using a temporary directory πŸ”—
  • -d, --diff β€” whether to display a package diff [default: auto]
  • -j, --max-jobs β€” the number of concurrent jobs Nix should run πŸƒβ€β™€οΈπŸ’¨
  • --cores β€” the number of cores Nix should utilize
  • --log-format β€” the logging format used by Nix
  • -k, --keep-going β€” continues building despite encountering errors [default: false]
  • -K, --keep-failed β€” keeps build outputs from failed builds [default: false]
  • --fallback β€” attempts to build locally if substituters fail [default: false]
  • --repair β€” repairs corrupted store paths 🩹 [default: false]
  • --builders β€” explicitly define remote builders
  • -I, --include β€” paths to include
  • -L, --print-build-logs β€” prints build logs directly to stdout πŸ“œ [default: false]
  • -t, --show-trace β€” displays tracebacks on errors [default: false]
  • --accept-flake-config β€” accepts configuration from flakes [default: false]
  • --refresh β€” refreshes flakes to the latest revision πŸ”„ [default: false]
  • --impure β€” allows impure builds [default: false]
  • --offline β€” builds without internet access 🚫🌐 [default: false]
  • --no-net β€” prohibits network usage [default: false]
  • --recreate-lock-file β€” recreates the flake.lock file entirely [default: false]
  • --no-update-lock-file β€” does not update the flake.lock file [default: false]
  • --no-write-lock-file β€” does not write a lock file [default: false]
  • --no-use-registries β€” does not use registries [default: false]
  • --no-registries β€” does not use registries (deprecated, use --no-use-registries) ⚠️ [default: false]
  • --commit-lock-file β€” commits the lock file after updates [default: false]
  • -Q, --no-build-output β€” suppresses build output 🀫 [default: false]
  • --use-substitutes β€” uses substitutes when copying [default: false]
  • --json β€” outputs results in JSON format [default: false]
  • --option β€” sets a Nix configuration option (may be given multiple times) πŸ”
  • --override-input β€” overrides a specific flake input (may be given multiple times) πŸ”
  • -u, --update β€” updates all flake inputs [default: false]
  • -U, --update-input β€” updates the specified flake input(s)
  • -c, --configuration β€” the name of the flake homeConfigurations attribute, like username@hostname

If it's unspecified, it'll try <username>@<hostname> and then <username> πŸ’«

  • -s, --specialisation β€” explicitly selects some specialisation
  • -S, --no-specialisation β€” ignores specialisations [default: false]

πŸ¦‹ Extra arguments passed to nix build

  • -b, --backup-extension β€” moves existing files by backing up with this file extension πŸ’Ύ
  • --show-activation-logs β€” shows activation logs
    • [env: NH_SHOW_ACTIVATION_LOGS]
    • [default: false]
  • --build-host β€” builds the configuration on a different host over SSH 🌐
  • -v, --verbose β€” increases logging verbosity [default: 0]
  • -q, --quiet β€” decreases logging verbosity [default: 0]
  • -e, --elevation-strategy β€” chooses the privilege elevation strategy πŸ‘‘

Can be a path to an elevation program (e.g., /usr/bin/sudo), or one of: 'none' (no elevation), 'passwordless' (use elevation without a password prompt, for remote hosts with NOPASSWD configured), or 'auto' (automatically detect available elevation programs in order: doas, sudo, run0, pkexec)

  • [env: NH_ELEVATION_STRATEGY]
  • -h, --help β€” prints help (see a summary with '-h') πŸ’–

πŸ’… SUBCOMMAND πŸ’…

okay bestie, this one's the REPL one β€” you load a home-manager config into a Nix REPL and poke at it live. it's giving "science experiment but make it cute" πŸ§ͺ✨

Load a home-manager configuration in a Nix REPL

Usage: repl [OPTIONS] [INSTALLABLE] [-- <EXTRA_ARGS>...]

🌸 Which installable to use 🌸

Nix is chill like that β€” it accepts a bunch of different kinds of installables:

  • [FLAKEREF[#ATTRPATH]] β€” a flake reference, with an optional attribute path tacked on. env vibes: [env: NH_FLAKE=], [env: NH_OS_FLAKE=], [env: NH_HOME_FLAKE=], [env: NH_DARWIN_FLAKE=]
  • -f, --file <FILE> [ATTRPATH] β€” a path to a file, plus optional attribute path. env: [env: NH_FILE=], [env: NH_ATTRP=]
  • -e, --expr <EXPR> [ATTRPATH] β€” a Nix expression, with an optional attribute path
  • [PATH] β€” a path (or symlink) to a /nix/store path

Then the actual flags, no cap:

  • -c, --configuration β€” the name of the flake homeConfigurations attribute, like username@hostname. If you don't specify it, it's gonna try <username>@<hostname> and then <username> 🫢

Extra arguments get passed straight to nix repl.

  • -v, --verbose β€” turn the logging up πŸ“ˆ [default: 0]
  • -q, --quiet β€” turn the logging down 🀫 [default: 0]
  • -e, --elevation-strategy β€” pick your privilege elevation strategy. It can be a path to an elevation program (like /usr/bin/sudo), or one of: 'none' (no elevation at all), 'passwordless' (elevate without a password prompt β€” for remote hosts with NOPASSWD configured), or 'auto' (auto-detect whichever elevation programs are available, checking in this order: doas, sudo, run0, pkexec) πŸ”₯ [env: NH_ELEVATION_STRATEGY]
  • -h, --help β€” print help (or use the summary version with -h) πŸ’–

πŸ’œ SUBCOMMAND πŸ’œ

the mac girlies' section β€” Nix-darwin functionality. mostly darwin-rebuild stuff, but not exclusively, iykyk 🍎

Nix-darwin functionality

It implements functionality mostly around β€” but not exclusive to β€” darwin-rebuild.

Usage: darwin [OPTIONS] <COMMAND>
  • -v, --verbose β€” crank the logging verbosity up ⬆️ [default: 0]
  • -q, --quiet β€” dial the logging verbosity down ⬇️ [default: 0]
  • -e, --elevation-strategy β€” choose the privilege elevation strategy, bestie. Either a path to an elevation program (e.g. /usr/bin/sudo), or one of: 'none' (no elevation), 'passwordless' (elevation without a password prompt, for remote hosts with NOPASSWD set up), or 'auto' (automatically detect available elevation programs, in order: doas, sudo, run0, pkexec) πŸ‘‘ [env: NH_ELEVATION_STRATEGY]
  • -h, --help β€” print help (see a summary with -h) ✨

πŸ¦‹ SUBCOMMAND πŸ¦‹

THE main character move: build and activate a nix-darwin configuration. this is the one you came for πŸ’…

Build and activate a nix-darwin configuration

Usage: switch [OPTIONS] [INSTALLABLE] [-- <EXTRA_ARGS>...]
  • -n, --dry β€” only print the actions, don't actually do them. look ma, no hands πŸ™ˆ [default: false]
  • -a, --ask β€” ask for confirmation first [default: false]

πŸŽ€ Which installable to use πŸŽ€

Nix accepts various kinds of installables (yes, same menu as before, she's consistent):

  • [FLAKEREF[#ATTRPATH]] β€” flake reference with an optional attribute path. [env: NH_FLAKE=], [env: NH_OS_FLAKE=], [env: NH_HOME_FLAKE=], [env: NH_DARWIN_FLAKE=]
  • -f, --file <FILE> [ATTRPATH] β€” path to a file with an optional attribute path. [env: NH_FILE=], [env: NH_ATTRP=]
  • -e, --expr <EXPR> [ATTRPATH] β€” a Nix expression with an optional attribute path
  • [PATH] β€” path or symlink to a /nix/store path
  • --no-nom β€” don't use nix-output-monitor for the build process 🚫 [default: false]
  • -o, --out-link β€” path to save the result link; defaults to using a temporary directory
  • -d, --diff β€” whether to show a package diff [default: auto]
  • -j, --max-jobs β€” how many concurrent jobs Nix should run
  • --cores β€” how many cores Nix should use
  • --log-format β€” the logging format Nix uses
  • -k, --keep-going β€” keep building even when errors show up (iconic perseverance behavior) [default: false]
  • -K, --keep-failed β€” keep the build outputs from failed builds [default: false]
  • --fallback β€” try to build locally if the substituters fail [default: false]
  • --repair β€” repair corrupted store paths [default: false]
  • --builders β€” explicitly define remote builders
  • -I, --include β€” paths to include
  • -L, --print-build-logs β€” print build logs straight to stdout [default: false]
  • -t, --show-trace β€” display tracebacks on errors [default: false]
  • --accept-flake-config β€” accept configuration from flakes [default: false]
  • --refresh β€” refresh flakes to the latest revision [default: false]
  • --impure β€” allow impure builds (living dangerously, love that for you) [default: false]
  • --offline β€” build with no internet access [default: false]
  • --no-net β€” prohibit network usage entirely [default: false]
  • --recreate-lock-file β€” recreate the flake.lock file from scratch [default: false]
  • --no-update-lock-file β€” don't update the flake.lock file [default: false]
  • --no-write-lock-file β€” don't write a lock file at all [default: false]
  • --no-use-registries β€” don't use registries [default: false]
  • --no-registries β€” don't use registries (deprecated, use --no-use-registries instead, she's old news) [default: false]
  • --commit-lock-file β€” commit the lock file after updates [default: false]
  • -Q, --no-build-output β€” suppress build output [default: false]
  • --use-substitutes β€” use substitutes when copying [default: false]
  • --json β€” output results in JSON format [default: false]
  • --option β€” set a Nix configuration option (you can pass this multiple times)
  • --override-input β€” override a specific flake input (also repeatable)
  • -u, --update β€” update all flake inputs [default: false]
  • -U, --update-input β€” update the specified flake input(s)
  • -H, --hostname β€” when you're using a flake installable, pick this hostname out of darwinConfigurations 🏠

Extra arguments get passed along to nix build.

  • -R, --bypass-root-check β€” don't panic if nh is being called as root 🫢 [env: NH_BYPASS_ROOT_CHECK] [default: false]
  • --show-activation-logs β€” show the activation logs [env: NH_SHOW_ACTIVATION_LOGS] [default: false]
  • --build-host β€” build the configuration on a different host over SSH 🌐
  • -v, --verbose β€” increase logging verbosity [default: 0]
  • -q, --quiet β€” decrease logging verbosity [default: 0]
  • -e, --elevation-strategy β€” pick the privilege elevation strategy. Either a path to an elevation program (e.g. /usr/bin/sudo), or one of: 'none' (no elevation), 'passwordless' (elevate without a password prompt, for remote hosts with NOPASSWD configured), or 'auto' (auto-detect available elevation programs in order: doas, sudo, run0, pkexec) ⭐ [env: NH_ELEVATION_STRATEGY]
  • -h, --help β€” print help (see a summary with -h) 🌈

SUBCOMMAND

Build a nix-darwin configuration 🍎✨

Usage: build [OPTIONS] [INSTALLABLE] [-- <EXTRA_ARGS>...]
  • -n, --dry β€” only prints what it would do, doesn't actually do any of it. window shopping bestie πŸ’… [default: false]
  • -a, --ask β€” makes it ask you for confirmation first [default: false]

πŸŽ€ Which installable to use

Nix is, like, famously chill about what you hand it β€” it accepts various kinds of installables:

  • [FLAKEREF[#ATTRPATH]] β€” a flake reference with an optional attribute path.
    • [env: NH_FLAKE=]
    • [env: NH_OS_FLAKE=]
    • [env: NH_HOME_FLAKE=]
    • [env: NH_DARWIN_FLAKE=]
  • -f, --file <FILE> [ATTRPATH] β€” path to a file, with an optional attribute path.
    • [env: NH_FILE=]
    • [env: NH_ATTRP=]
  • -e, --expr <EXPR> [ATTRPATH] β€” a Nix expression, with an optional attribute path.
  • [PATH] β€” a path or symlink to a /nix/store path

  • --no-nom β€” please don't use nix-output-monitor for the build process, thanks [default: false]
  • -o, --out-link β€” path to save the result link; if you don't give one it defaults to using a temporary directory
  • -d, --diff β€” whether to display a package diff [default: auto]
  • -j, --max-jobs β€” number of concurrent jobs Nix should run
  • --cores β€” number of cores Nix should utilize
  • --log-format β€” logging format used by Nix
  • -k, --keep-going β€” keep building even when you hit errors, no thoughts just vibes [default: false]
  • -K, --keep-failed β€” keep the build outputs from failed builds [default: false]
  • --fallback β€” attempt to build locally if substituters fail [default: false]
  • --repair β€” repair corrupted store paths [default: false]
  • --builders β€” explicitly define remote builders
  • -I, --include β€” paths to include
  • -L, --print-build-logs β€” print build logs directly to stdout [default: false]
  • -t, --show-trace β€” display tracebacks on errors [default: false]
  • --accept-flake-config β€” accept configuration from flakes [default: false]
  • --refresh β€” refresh flakes to the latest revision [default: false]
  • --impure β€” allow impure builds πŸ‘€ [default: false]
  • --offline β€” build without internet access [default: false]
  • --no-net β€” prohibit network usage [default: false]
  • --recreate-lock-file β€” recreate the flake.lock file entirely [default: false]
  • --no-update-lock-file β€” do not update the flake.lock file [default: false]
  • --no-write-lock-file β€” do not write a lock file [default: false]
  • --no-use-registries β€” do not use registries [default: false]
  • --no-registries β€” do not use registries (deprecated, use --no-use-registries instead bestie) [default: false]
  • --commit-lock-file β€” commit the lock file after updates [default: false]
  • -Q, --no-build-output β€” suppress build output [default: false]
  • --use-substitutes β€” use substitutes when copying [default: false]
  • --json β€” output results in JSON format [default: false]
  • --option β€” set a Nix configuration option (may be given multiple times)
  • --override-input β€” override a specific flake input (may be given multiple times)
  • -u, --update β€” update all flake inputs [default: false]
  • -U, --update-input β€” update the specified flake input(s)
  • -H, --hostname β€” when using a flake installable, select this hostname from darwinConfigurations

Extra arguments passed to nix build β€” those go after the --, bestie 🫢

  • -R, --bypass-root-check β€” don't panic if calling nh as root
    • [env: NH_BYPASS_ROOT_CHECK]
    • [default: false]
  • --show-activation-logs β€” show activation logs
    • [env: NH_SHOW_ACTIVATION_LOGS]
    • [default: false]
  • --build-host β€” build the configuration on a different host over SSH 🌈
  • -v, --verbose β€” increase logging verbosity [default: 0]
  • -q, --quiet β€” decrease logging verbosity [default: 0]
  • -e, --elevation-strategy β€” choose the privilege elevation strategy.
    • Can be a path to an elevation program (e.g., /usr/bin/sudo), or one of: 'none' (no elevation), 'passwordless' (use elevation without password prompt for remote hosts with NOPASSWD configured), or 'auto' (automatically detect available elevation programs in order: doas, sudo, run0, pkexec)
    • [env: NH_ELEVATION_STRATEGY]
  • -h, --help β€” print help (see a summary with -h)

SUBCOMMAND

Load a nix-darwin configuration in a Nix REPL πŸ§šβ€β™€οΈπŸ’œ

Usage: repl [OPTIONS] [INSTALLABLE]

🌸 Which installable to use

Nix accepts various kinds of installables:

  • [FLAKEREF[#ATTRPATH]] β€” a flake reference with an optional attribute path.
    • [env: NH_FLAKE=]
    • [env: NH_OS_FLAKE=]
    • [env: NH_HOME_FLAKE=]
    • [env: NH_DARWIN_FLAKE=]
  • -f, --file <FILE> [ATTRPATH] β€” path to a file, with an optional attribute path.
    • [env: NH_FILE=]
    • [env: NH_ATTRP=]
  • -e, --expr <EXPR> [ATTRPATH] β€” a Nix expression, with an optional attribute path.
  • [PATH] β€” a path or symlink to a /nix/store path

  • -H, --hostname β€” when using a flake installable, select this hostname from darwinConfigurations
  • -v, --verbose β€” increase logging verbosity [default: 0]
  • -q, --quiet β€” decrease logging verbosity [default: 0]
  • -e, --elevation-strategy β€” choose the privilege elevation strategy.
    • Can be a path to an elevation program (e.g., /usr/bin/sudo), or one of: 'none' (no elevation), 'passwordless' (use elevation without password prompt for remote hosts with NOPASSWD configured), or 'auto' (automatically detect available elevation programs in order: doas, sudo, run0, pkexec)
    • [env: NH_ELEVATION_STRATEGY]
  • -h, --help β€” print help (see a summary with -h)

SUBCOMMAND

Searches packages or NixOS/home-manager options via search.nixos.org, or a local SPAM database πŸ”ŽπŸ¦‹

Usage: search [OPTIONS] [QUERY]... [COMMAND]
  • -l, --limit β€” number of search results to display [default: 30]
  • -c, --channel β€” name of the channel to query (e.g nixos-23.11, nixos-unstable, etc)
    • [env: NH_SEARCH_CHANNEL]
    • [default: nixos-unstable]
  • -P, --platforms β€” show supported platforms for each package
    • [env: NH_SEARCH_PLATFORM]
    • [default: false]
  • --backend-version β€” backend index version to query on search.nixos.org. Defaults to the version bundled with nh
    • [env: NH_SEARCH_BACKEND_VERSION]
  • --backend-version-fallbacks β€” number of newer index versions to try when the requested version is outdated (missing on the backend)
    • [env: NH_SEARCH_BACKEND_FALLBACKS]
    • [default: 1]
  • -j, --json β€” output results as JSON
    • [env: NH_SEARCH_JSON]
    • [default: false]
  • --default-search β€” default search mode used when no subcommand is given. Accepts packages or options (scope defaults to all)
    • [env: NH_DEFAULT_SEARCH]
    • [default: packages]

Query shorthand: equivalent to nh search packages <query> or nh search options <query> depending on --default-search β€” so you can literally just type your query and go ✨

  • -v, --verbose β€” increase logging verbosity [default: 0]
  • -q, --quiet β€” decrease logging verbosity [default: 0]
  • -e, --elevation-strategy β€” choose the privilege elevation strategy.
    • Can be a path to an elevation program (e.g., /usr/bin/sudo), or one of: 'none' (no elevation), 'passwordless' (use elevation without password prompt for remote hosts with NOPASSWD configured), or 'auto' (automatically detect available elevation programs in order: doas, sudo, run0, pkexec)
    • [env: NH_ELEVATION_STRATEGY]
  • -h, --help β€” print help (see a summary with -h)

SUBCOMMAND

Search packages via search.nixos.org πŸ“¦πŸ’–

Usage: packages [OPTIONS] <QUERY>...
  • -l, --limit β€” number of search results to display [default: 30]
  • -c, --channel β€” name of the channel to query (e.g nixos-23.11, nixos-unstable, etc)
    • [env: NH_SEARCH_CHANNEL]
    • [default: nixos-unstable]
  • -P, --platforms β€” show supported platforms for each package
    • [env: NH_SEARCH_PLATFORM]
    • [default: false]
  • --backend-version β€” backend index version to query on search.nixos.org. Defaults to the version bundled with nh
    • [env: NH_SEARCH_BACKEND_VERSION]
  • --backend-version-fallbacks β€” number of newer index versions to try when the requested version is outdated (missing on the backend)
    • [env: NH_SEARCH_BACKEND_FALLBACKS]
    • [default: 1]

<QUERY>... β€” name of the package to search. [required] β€” yeah you actually have to tell it something bestie 😭

  • -j, --json β€” output results as JSON
    • [env: NH_SEARCH_JSON]
    • [default: false]
  • -v, --verbose β€” increase logging verbosity [default: 0]
  • -q, --quiet β€” decrease logging verbosity [default: 0]
  • -e, --elevation-strategy β€” choose the privilege elevation strategy.
    • Can be a path to an elevation program (e.g., /usr/bin/sudo), or one of: 'none' (no elevation), 'passwordless' (use elevation without password prompt for remote hosts with NOPASSWD configured), or 'auto' (automatically detect available elevation programs in order: doas, sudo, run0, pkexec)
    • [env: NH_ELEVATION_STRATEGY]
  • -h, --help β€” print help (see a summary with -h)

🌸 SUBCOMMAND πŸ’…

✨ options β€” Search NixOS/home-manager options via search.nixos.org

Okay bestie, this is the one where you go "wait, what does that option even do" and nh just knows. It hits search.nixos.org for you. Iconic behavior honestly.

Usage: options [OPTIONS] <QUERY>...
  • -l, --limit β€” how many search results to show you. Default: 30. (Thirty is a lot, but we're nosy.)
  • -c, --channel β€” the name of the channel to query, like nixos-23.11, nixos-unstable, etc. Reads NH_SEARCH_CHANNEL from the env. Default: nixos-unstable.
  • --scope β€” which options scope you're searching: nixpkgs, home-manager, nix-darwin, or all (which is the default, because why choose).
  • --backend-version β€” the backend index version to query on search.nixos.org. Defaults to the version bundled with nh. Env: NH_SEARCH_BACKEND_VERSION.
  • --backend-version-fallbacks β€” how many newer index versions to try when the version you asked for is outdated (i.e. missing on the backend). Env: NH_SEARCH_BACKEND_FALLBACKS. Default: 1.
  • *QUERY*… (positional, required) β€” name of the option to search. Yeah, it's required, don't @ me.
  • -j, --json β€” output results as JSON. Env: NH_SEARCH_JSON. Default: false.
  • -v, --verbose β€” increase logging verbosity. Default: 0.
  • -q, --quiet β€” decrease logging verbosity. Default: 0.
  • -e, --elevation-strategy β€” choose the privilege elevation strategy. Env: NH_ELEVATION_STRATEGY.

It can be a path to an elevation program (e.g. /usr/bin/sudo), or one of: none (no elevation at all), passwordless (use elevation without a password prompt β€” for remote hosts with NOPASSWD configured), or auto (automatically detect available elevation programs in this order: doas, sudo, run0, pkexec).

  • -h, --help β€” print help (see a summary with -h).

πŸ¦‹ SUBCOMMAND πŸ’–

✨ offline β€” Search local SPAM database(s) without network access

Airplane mode queen energy ✈️ β€” this searches your local SPAM database(s), zero network required. No wifi, no problem.

Usage: offline [OPTIONS] --db <PATH> <QUERY>...
  • -l, --limit β€” number of search results to display. Default: 30.
  • -D, --db β€” path to a SPAM database file. Specify it multiple times to search across several databases. Env: NH_OFFLINE_DB. Required β€” no db, no search, sorry babe.
  • *QUERY*… (positional, required) β€” name of the package or option to search.
  • -j, --json β€” output results as JSON. Env: NH_SEARCH_JSON. Default: false.
  • -v, --verbose β€” increase logging verbosity. Default: 0.
  • -q, --quiet β€” decrease logging verbosity. Default: 0.
  • -e, --elevation-strategy β€” choose the privilege elevation strategy. Env: NH_ELEVATION_STRATEGY.

Can be a path to an elevation program (e.g. /usr/bin/sudo), or one of: none (no elevation), passwordless (use elevation without password prompt for remote hosts with NOPASSWD configured), or auto (automatically detect available elevation programs in order: doas, sudo, run0, pkexec).

  • -h, --help β€” print help (see a summary with -h).

πŸŽ€ SUBCOMMAND 🌈

✨ prs β€” Search Nixpkgs pull requests and branch reachability

Stalking PRs but make it cute πŸ•΅οΈβ€β™€οΈ β€” this searches Nixpkgs pull requests and branch reachability.

Usage: prs [OPTIONS] <QUERY>...
  • -d, --days β€” search GitHub results updated in the last n days (default: 15).
  • *QUERY*… (positional, required) β€” pull request search query.
  • -j, --json β€” output results as JSON. Env: NH_SEARCH_JSON. Default: false.
  • -v, --verbose β€” increase logging verbosity. Default: 0.
  • -q, --quiet β€” decrease logging verbosity. Default: 0.
  • -e, --elevation-strategy β€” choose the privilege elevation strategy. Env: NH_ELEVATION_STRATEGY.

Can be a path to an elevation program (e.g. /usr/bin/sudo), or one of: none (no elevation), passwordless (use elevation without password prompt for remote hosts with NOPASSWD configured), or auto (automatically detect available elevation programs in order: doas, sudo, run0, pkexec).

  • -h, --help β€” print help (see a summary with -h).

πŸ“ SUBCOMMAND πŸ’œ

✨ issues β€” Search Nixpkgs issues, excluding pull requests

Same vibe as prs but for issues only β€” PRs are literally filtered out, we said not those.

Usage: issues [OPTIONS] <QUERY>...
  • -d, --days β€” search GitHub results updated in the last n days (default: 15).
  • *QUERY*… (positional, required) β€” issue search query.
  • -j, --json β€” output results as JSON. Env: NH_SEARCH_JSON. Default: false.
  • -v, --verbose β€” increase logging verbosity. Default: 0.
  • -q, --quiet β€” decrease logging verbosity. Default: 0.
  • -e, --elevation-strategy β€” choose the privilege elevation strategy. Env: NH_ELEVATION_STRATEGY.

Can be a path to an elevation program (e.g. /usr/bin/sudo), or one of: none (no elevation), passwordless (use elevation without password prompt for remote hosts with NOPASSWD configured), or auto (automatically detect available elevation programs in order: doas, sudo, run0, pkexec).

  • -h, --help β€” print help (see a summary with -h).

🧚 SUBCOMMAND ⭐

✨ clean β€” Enhanced nix cleanup

The glow-up version of nix cleanup ✨ It's a command with subcommands, so it needs its own <COMMAND> β€” you can't just yell clean into the void.

Usage: clean [OPTIONS] <COMMAND>
  • -v, --verbose β€” increase logging verbosity. Default: 0.
  • -q, --quiet β€” decrease logging verbosity. Default: 0.
  • -e, --elevation-strategy β€” choose the privilege elevation strategy. Env: NH_ELEVATION_STRATEGY.

Can be a path to an elevation program (e.g. /usr/bin/sudo), or one of: none (no elevation), passwordless (use elevation without password prompt for remote hosts with NOPASSWD configured), or auto (automatically detect available elevation programs in order: doas, sudo, run0, pkexec).

  • -h, --help β€” print help (see a summary with -h).

❄️ SUBCOMMAND πŸ’€

✨ all β€” Clean all profiles

Everything. All of it. All the profiles πŸ”₯ Same option list as user below, so don't be confused when it looks familiar.

Usage: all [OPTIONS]
  • -k, --keep β€” at least keep this number of generations. Default: 1.
  • -K, --keep-since β€” at least keep gcroots and generations in this time range since now. Default: 0h.

See the documentation of humantime for possible formats: <https://docs.rs/humantime/latest/humantime/fn.parse_duration.html>

  • -n, --dry β€” only print actions, without performing them. Default: false.
  • -a, --ask β€” ask for confirmation. Default: false.
  • --no-gc β€” don't run nix store --gc. Default: false.
  • --no-gcroots β€” don't clean gcroots. Default: false.
  • --no-direnv β€” don't clean direnv gcroots. Default: false.
  • --optimise β€” run nix-store --optimise after gc. Default: false.
  • --max β€” pass --max to nix store gc.
  • --keep-one β€” keep at least one gcroot per direnv project. Default: false.
  • -x, --cross-filesystems β€” cross filesystem boundaries when scanning gcroots. Default: false.
  • -v, --verbose β€” increase logging verbosity. Default: 0.
  • -q, --quiet β€” decrease logging verbosity. Default: 0.
  • -e, --elevation-strategy β€” choose the privilege elevation strategy. Env: NH_ELEVATION_STRATEGY.

Can be a path to an elevation program (e.g. /usr/bin/sudo), or one of: none (no elevation), passwordless (use elevation without password prompt for remote hosts with NOPASSWD configured), or auto (automatically detect available elevation programs in order: doas, sudo, run0, pkexec).

  • -h, --help β€” print help (see a summary with -h).

🌸 SUBCOMMAND 🫢

✨ user β€” Clean the current user's profiles

Just your profiles, main character that you are πŸ‘‘ Not root's, not anybody else's β€” yours.

Usage: user [OPTIONS]
  • -k, --keep β€” at least keep this number of generations. Default: 1.
  • -K, --keep-since β€” at least keep gcroots and generations in this time range since now. Default: 0h.

See the documentation of humantime for possible formats: <https://docs.rs/humantime/latest/humantime/fn.parse_duration.html>

  • -n, --dry β€” only print actions, without performing them. Default: false.
  • -a, --ask β€” ask for confirmation. Default: false.
  • --no-gc β€” don't run nix store --gc. Default: false.
  • --no-gcroots β€” don't clean gcroots. Default: false.
  • --no-direnv β€” don't clean direnv gcroots. Default: false.
  • --optimise β€” run nix-store --optimise after gc. Default: false.
  • --max β€” pass --max to nix store gc.
  • --keep-one β€” keep at least one gcroot per direnv project. Default: false.
  • -x, --cross-filesystems β€” cross filesystem boundaries when scanning gcroots. Default: false.
  • -v, --verbose β€” increase logging verbosity. Default: 0.
  • -q, --quiet β€” decrease logging verbosity. Default: 0.
  • -e, --elevation-strategy β€” choose the privilege elevation strategy. Env: NH_ELEVATION_STRATEGY.

Can be a path to an elevation program (e.g. /usr/bin/sudo), or one of: none (no elevation), passwordless (use elevation without password prompt for remote hosts with NOPASSWD configured), or auto (automatically detect available elevation programs in order: doas, sudo, run0, pkexec).

  • -h, --help β€” print help (see a summary with -h).

🧹 Clean a specific profile

profile [OPTIONS] <PROFILE>

Alright bestie, this one cleans exactly one profile and nothing else β€” you point at it and it goes to work ✨

  • -k, --keep β€” at least keep this number of generations πŸ’– [default: 1]
  • -K, --keep-since β€” at least keep gcroots and generations in this time range since now. Check the humantime docs for the possible formats: <https://docs.rs/humantime/latest/humantime/fn.parse_duration.html> ⏳ [default: 0h]
  • -n, --dry β€” only print the actions, don't actually perform them (a little look-but-don't-touch moment πŸ‘€) [default: false]
  • -a, --ask β€” ask you for confirmation first, very considerate of it 🫢 [default: false]
  • --no-gc β€” don't run nix store --gc [default: false]
  • --no-gcroots β€” don't clean gcroots [default: false]
  • --no-direnv β€” don't clean direnv gcroots [default: false]
  • --optimise β€” run nix-store --optimise after gc, slay πŸ’… [default: false]
  • --max β€” pass --max through to nix store gc
  • --keep-one β€” keep at least one gcroot per direnv project [default: false]
  • -x, --cross-filesystems β€” cross filesystem boundaries when scanning gcroots [default: false]
  • <PROFILE> β€” which profile to clean β€” this one is required, no skipping it πŸŽ€
  • -v, --verbose β€” increase logging verbosity [default: 0]
  • -q, --quiet β€” decrease logging verbosity [default: 0]
  • -e, --elevation-strategy β€” choose the privilege elevation strategy. It can be a path to an elevation program (like /usr/bin/sudo), or one of: 'none' (no elevation), 'passwordless' (use elevation with no password prompt, for remote hosts with NOPASSWD configured), or 'auto' (automatically detect available elevation programs, in this order: doas, sudo, run0, pkexec) πŸ‘‘ [env: NH_ELEVATION_STRATEGY]
  • -h, --help β€” print help (see a summary with -h) πŸ™ˆ

🚦 EXIT STATUS

  • 0 β€” successful program execution, we love a happy ending πŸ’–
  • 1 β€” unsuccessful program execution 😭
  • 101 β€” the program panicked πŸ’€

🌱 ENVIRONMENT

  • NH_NO_CHECKS β€” when set (any non-empty value), it skips startup checks like Nix version and experimental feature validation. Super useful for generating completions or running in constrained build environments ✨
  • NH_FLAKE β€” your preferred path/reference to a directory containing your flake.nix, used by NH when running flake-based commands. Historically it was called FLAKE; NH will migrate FLAKE into NH_FLAKE if it's present πŸ¦‹
  • NH_OS_FLAKE β€” command-specific flake reference for nh os commands. It takes precedence over NH_FLAKE πŸ‘‘
  • NH_HOME_FLAKE β€” command-specific flake reference for nh home commands. Takes precedence over NH_FLAKE too πŸ’…
  • NH_DARWIN_FLAKE β€” command-specific flake reference for nh darwin commands. Also takes precedence over NH_FLAKE πŸ“
  • NH_FILE β€” preferred path to a directory/file containing a Nix expression. It gets chosen after the os/home/darwin-specific env vars, but before NH_FLAKE πŸŽ€
  • NH_ATTRP β€” Nix attribute path for an expression specified with NH_FILE. For example, nixosConfigurations.<hostname> πŸ”₯
  • NH_SUDO_ASKPASS β€” path to a program used as SUDO_ASKPASS when NH self-elevates with sudo 🧚
  • NH_PRESERVE_ENV β€” controls whether environment variables marked for preservation get passed to elevated commands. Set it to "0" to disable, "1" to force. If it's unset, it defaults to enabled 🌸
  • NH_SHOW_ACTIVATION_LOGS β€” controls whether activation output is displayed. By default activation output is hidden πŸ‘€ β€” set it to "1" and you get the full logs
  • NH_LOG β€” sets the tracing/log filter for NH, using tracing_subscriber format (e.g., nh=trace) ⭐
  • NH_NOM β€” control whether nix-output-monitor (nom) is enabled for build processes. Equivalent of --no-nom 🌈
  • NH_REMOTE_CLEANUP β€” whether to clean up remote processes on interrupt via pkill. It's opt-in because the behavior is fragile ⚠️
  • NH_SSHOPTS β€” SSH options for remote operations. Takes precedence over NIX_SSHOPTS, and accepts the same format as NIX_SSHOPTS πŸ”
  • NH_SUDOOPTS β€” extra arguments inserted into the sudo invocation when NH elevates privileges. Takes precedence over NIX_SUDOOPTS ⚑
  • NIXOS_INSTALL_BOOTLOADER β€” forwarded to switch-to-configuration. If true, it forces bootloader installation. Also available via --install-bootloader πŸ‘Ÿ
  • NIXOS_NO_CHECK β€” forwarded to switch-to-configuration during activation. It inhibits certain NixOS service checks 🚧
  • NIX_SSHOPTS β€” SSH options passed to Nix commands for remote builds. NH_SSHOPTS takes precedence when both are set 🌐
  • NIX_SUDOOPTS β€” extra arguments inserted into the sudo invocation. Supported for nixos-rebuild compatibility; NH_SUDOOPTS takes precedence πŸ’œ
  • NIX_CONFIG β€” Nix configuration options passed to all Nix commands πŸ› οΈ
  • NIX_REMOTE β€” remote store configuration for Nix operations πŸ“¦
  • NIX_SSL_CERT_FILE β€” SSL certificate file for Nix HTTPS operations πŸ”’
  • NIX_USER_CONF_FILES β€” user configuration files for Nix πŸ“‚

πŸ—‚οΈ FILES

  • /nix/var/nix/profiles/system β€” system profile directory containing system generations 🏠
  • /run/current-system β€” symlink to the currently active system profile ⭐
  • /etc/specialisation β€” NixOS specialisation detection. It contains the active specialisation name πŸŽ€

πŸ’« EXAMPLES

Switch to a new NixOS configuration:

$ nh os switch --hostname myhost --specialisation dev

Rollback to a previous NixOS generation:

$ nh os rollback --to 42

Switch to a home-manager configuration:

$ nh home switch --configuration alice@work

Build a home-manager configuration with backup:

$ nh home build --backup-extension .bak

Switch to a darwin configuration:

$ nh darwin switch --hostname mymac

Search for ripgrep:

$ nh search ripgrep

Show supported platforms for a package:

$ nh search --platforms ripgrep

Clean all but keep 5 generations:

$ nh clean all --keep 5

Clean a specific profile:

$ nh clean profile /nix/var/nix/profiles/system

And that's the whole page, bestie β€” you made it to the end πŸŽ‰ You're officially an nh scholar now, no cap. This little masterpiece is the nh manual for nh 4.4.2, so if you ever need to flex your knowledge again, you know exactly where to look πŸ’–βœ¨πŸ‘‘

okay bye, go clean some generations, ily 🫢

πŸ“¦ where this page comes from