nh(1)
π 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/storepath.
Now back to the switch option buffet π:
--no-nomβ Don't usenix-output-monitorfor 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 theflake.lockfile entirely. [default:false]--no-update-lock-fileβ Do not update theflake.lockfile. [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 fromnixosConfigurations. 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 callingnhas 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/storepath--no-nomβ don't usenix-output-monitorfor 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 theflake.lockfile entirely.[default: false]β full reset, no crumbs.--no-update-lock-fileβ do not update theflake.lockfile.[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-registriesinstead. 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 fromnixosConfigurations. 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 forswitchandbootcommands.[default: false]
Extra arguments passed tonix buildβ yeah, you can pass those after the-- <EXTRA_ARGS>...in the usage line. Slay.
-R,--bypass-root-checkβ don't panic if callingnhas 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 withNOPASSWDconfigured), or'auto'(automatically detect available elevation programs in order:doas,sudo,run0,pkexec). Env:[env: NH_ELEVATION_STRATEGY]β yes,-eshows 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/storepath ποΈ
π₯ THE REST OF THE FLAGS π₯
--no-nomβ don't usenix-output-monitorfor 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 tostdout. 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 theflake.lockfile entirely. scorched earth, periodt π₯[default: false]
--no-update-lock-fileβ do not update theflake.lockfile.[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-registriesinstead, 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 fromnixosConfigurations.- 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 π«‘
- 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
-s,--specialisationβ explicitly select some specialisation.-S,--no-specialisationβ ignore specialisations.[default: false]
--install-bootloaderβ install the bootloader for theswitchandbootcommands.[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 callingnhas 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 withNOPASSWDconfigured'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/storepath ποΈ
--no-nomβ don't usenix-output-monitorfor 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 theflake.lockfile entirely[default: false]--no-update-lock-fileβ do not update theflake.lockfile[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-registriesinstead[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 fromnixosConfigurations
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 theswitchandbootcommands[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 callingnhas 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/storepath ποΈ
-H,--hostnameβ when using a flake installable, select this hostname fromnixosConfigurations-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 callingnhas 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/storepath. straight to the source, iykyk π
π₯ the actual flags
--no-nomβ don't usenix-output-monitorfor 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 theflake.lockfile entirely.[default: false]--no-update-lock-fileβ do not update theflake.lockfile.[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-registriesinstead.[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 fromnixosConfigurations.
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 forswitchandbootcommands.[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 callingnhas 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/storepath β
π Heads up:-eshows up again way down the page for--elevation-strategy. Not me fixing it β I'm just the messenger, fr fr.
--no-nomβ don't usenix-output-monitorfor 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 theflake.lockfile entirely[default: false]--no-update-lock-fileβ do not update theflake.lockfile[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 fromnixosConfigurations
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 forswitchandbootcommands[default: false]- Extra arguments passed to
nix buildβ you drop these after--in the usage line π -R,--bypass-root-checkβ don't panic if callingnhas 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=]
- [env:
-f,--file <FILE> [ATTRPATH]β path to a file, with an optional attribute path π- [env:
NH_FILE=] - [env:
NH_ATTRP=]
- [env:
-e,--expr <EXPR> [ATTRPATH]β a Nix expression, with an optional attribute path β¨[PATH]β a path or a symlink pointing at a/nix/storepath π
--no-nomβ don't usenix-output-monitorfor 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 theflake.lockfile entirely, from scratch, no leftovers [default:false]--no-update-lock-fileβ does not update theflake.lockfile [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 flakehomeConfigurationsattribute, likeusername@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]
- [env:
--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=]
- [env:
-f,--file <FILE> [ATTRPATH]β path to a file, with an optional attribute path π- [env:
NH_FILE=] - [env:
NH_ATTRP=]
- [env:
-e,--expr <EXPR> [ATTRPATH]β a Nix expression, with an optional attribute path β¨[PATH]β a path or a symlink pointing at a/nix/storepath π
--no-nomβ don't usenix-output-monitorfor 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 theflake.lockfile entirely [default:false]--no-update-lock-fileβ does not update theflake.lockfile [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 flakehomeConfigurationsattribute, likeusername@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]
- [env:
--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/storepath
Then the actual flags, no cap:
-c,--configurationβ the name of the flakehomeConfigurationsattribute, likeusername@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 withNOPASSWDconfigured), 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 withNOPASSWDset 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/storepath--no-nomβ don't usenix-output-monitorfor 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 theflake.lockfile from scratch[default: false]--no-update-lock-fileβ don't update theflake.lockfile[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-registriesinstead, 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 ofdarwinConfigurationsπ
Extra arguments get passed along to nix build.
-R,--bypass-root-checkβ don't panic ifnhis 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 withNOPASSWDconfigured), 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=]
- [env:
-f,--file <FILE> [ATTRPATH]β path to a file, with an optional attribute path.- [env:
NH_FILE=] - [env:
NH_ATTRP=]
- [env:
-e,--expr <EXPR> [ATTRPATH]β a Nix expression, with an optional attribute path.[PATH]β a path or symlink to a/nix/storepath
--no-nomβ please don't usenix-output-monitorfor 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 theflake.lockfile entirely [default:false]--no-update-lock-fileβ do not update theflake.lockfile [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-registriesinstead 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 fromdarwinConfigurations
Extra arguments passed to nix build β those go after the --, bestie π«Ά
-R,--bypass-root-checkβ don't panic if callingnhas root- [env:
NH_BYPASS_ROOT_CHECK] - [default:
false]
- [env:
--show-activation-logsβ show activation logs- [env:
NH_SHOW_ACTIVATION_LOGS] - [default:
false]
- [env:
--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 withNOPASSWDconfigured), or'auto'(automatically detect available elevation programs in order:doas,sudo,run0,pkexec) - [env:
NH_ELEVATION_STRATEGY]
- Can be a path to an elevation program (e.g.,
-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=]
- [env:
-f,--file <FILE> [ATTRPATH]β path to a file, with an optional attribute path.- [env:
NH_FILE=] - [env:
NH_ATTRP=]
- [env:
-e,--expr <EXPR> [ATTRPATH]β a Nix expression, with an optional attribute path.[PATH]β a path or symlink to a/nix/storepath
-H,--hostnameβ when using a flake installable, select this hostname fromdarwinConfigurations-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 withNOPASSWDconfigured), or'auto'(automatically detect available elevation programs in order:doas,sudo,run0,pkexec) - [env:
NH_ELEVATION_STRATEGY]
- Can be a path to an elevation program (e.g.,
-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.gnixos-23.11,nixos-unstable, etc)- [env:
NH_SEARCH_CHANNEL] - [default:
nixos-unstable]
- [env:
-P,--platformsβ show supported platforms for each package- [env:
NH_SEARCH_PLATFORM] - [default:
false]
- [env:
--backend-versionβ backend index version to query onsearch.nixos.org. Defaults to the version bundled withnh- [env:
NH_SEARCH_BACKEND_VERSION]
- [env:
--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]
- [env:
-j,--jsonβ output results as JSON- [env:
NH_SEARCH_JSON] - [default:
false]
- [env:
--default-searchβ default search mode used when no subcommand is given. Acceptspackagesoroptions(scope defaults toall)- [env:
NH_DEFAULT_SEARCH] - [default:
packages]
- [env:
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 withNOPASSWDconfigured), or'auto'(automatically detect available elevation programs in order:doas,sudo,run0,pkexec) - [env:
NH_ELEVATION_STRATEGY]
- Can be a path to an elevation program (e.g.,
-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.gnixos-23.11,nixos-unstable, etc)- [env:
NH_SEARCH_CHANNEL] - [default:
nixos-unstable]
- [env:
-P,--platformsβ show supported platforms for each package- [env:
NH_SEARCH_PLATFORM] - [default:
false]
- [env:
--backend-versionβ backend index version to query onsearch.nixos.org. Defaults to the version bundled withnh- [env:
NH_SEARCH_BACKEND_VERSION]
- [env:
--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]
- [env:
<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]
- [env:
-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 withNOPASSWDconfigured), or'auto'(automatically detect available elevation programs in order:doas,sudo,run0,pkexec) - [env:
NH_ELEVATION_STRATEGY]
- Can be a path to an elevation program (e.g.,
-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, likenixos-23.11,nixos-unstable, etc. ReadsNH_SEARCH_CHANNELfrom the env. Default:nixos-unstable.--scopeβ which options scope you're searching:nixpkgs,home-manager,nix-darwin, orall(which is the default, because why choose).--backend-versionβ the backend index version to query on search.nixos.org. Defaults to the version bundled withnh. 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 runnix store --gc. Default:false.--no-gcrootsβ don't clean gcroots. Default:false.--no-direnvβ don't clean direnv gcroots. Default:false.--optimiseβ runnix-store --optimiseafter gc. Default:false.--maxβ pass--maxtonix 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 runnix store --gc. Default:false.--no-gcrootsβ don't clean gcroots. Default:false.--no-direnvβ don't clean direnv gcroots. Default:false.--optimiseβ runnix-store --optimiseafter gc. Default:false.--maxβ pass--maxtonix 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 thehumantimedocs 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 runnix store --gc[default:false]--no-gcrootsβ don't clean gcroots [default:false]--no-direnvβ don't clean direnv gcroots [default:false]--optimiseβ runnix-store --optimiseafter gc, slay π [default:false]--maxβ pass--maxthrough tonix 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 withNOPASSWDconfigured), 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 yourflake.nix, used by NH when running flake-based commands. Historically it was calledFLAKE; NH will migrateFLAKEintoNH_FLAKEif it's present π¦NH_OS_FLAKEβ command-specific flake reference fornh oscommands. It takes precedence overNH_FLAKEπNH_HOME_FLAKEβ command-specific flake reference fornh homecommands. Takes precedence overNH_FLAKEtoo πNH_DARWIN_FLAKEβ command-specific flake reference fornh darwincommands. Also takes precedence overNH_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 beforeNH_FLAKEπNH_ATTRPβ Nix attribute path for an expression specified withNH_FILE. For example,nixosConfigurations.<hostname>π₯NH_SUDO_ASKPASSβ path to a program used asSUDO_ASKPASSwhen 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 logsNH_LOGβ sets the tracing/log filter for NH, usingtracing_subscriberformat (e.g.,nh=trace) βNH_NOMβ control whethernix-output-monitor(nom) is enabled for build processes. Equivalent of--no-nomπNH_REMOTE_CLEANUPβ whether to clean up remote processes on interrupt viapkill. It's opt-in because the behavior is fragile β οΈNH_SSHOPTSβ SSH options for remote operations. Takes precedence overNIX_SSHOPTS, and accepts the same format asNIX_SSHOPTSπNH_SUDOOPTSβ extra arguments inserted into the sudo invocation when NH elevates privileges. Takes precedence overNIX_SUDOOPTSβ‘NIXOS_INSTALL_BOOTLOADERβ forwarded toswitch-to-configuration. If true, it forces bootloader installation. Also available via--install-bootloaderπNIXOS_NO_CHECKβ forwarded toswitch-to-configurationduring activation. It inhibits certain NixOS service checks π§NIX_SSHOPTSβ SSH options passed to Nix commands for remote builds.NH_SSHOPTStakes precedence when both are set πNIX_SUDOOPTSβ extra arguments inserted into the sudo invocation. Supported fornixos-rebuildcompatibility;NH_SUDOOPTStakes 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
- nixos 26.05: nh-unwrapped 4.4.2
- nixpkgs unstable: nh-unwrapped 4.4.2
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms