nix3-shell(1)
๐ nix3-shell(1) โ General Commands Manual ๐
okay bestie, so this is the manual page for nix shell from the nix3 command family. pull up a chair, grab a boba, we're doing this ๐
โ ๏ธ Warning โ This program is experimental and its interface is subject to change. fr fr. it's giving "still cooking." do not build your entire life plan on this interface staying exactly the same, no cap. ๐
โจ Name โจ
nix shell โ run a shell in which the specified packages are available ๐
like... it literally hands you a shell with your fave packages already on deck. iconic behavior.
๐ธ Synopsis ๐ธ
nix shell [optionโฆ] installablesโฆ
that's it. that's the whole shape of it. options, then your installables. slay. โจ
๐ฆ Examples ๐ฆ
okay these are the vibes, let's go one by one ๐
- Start a shell providing
youtube-dlfrom thenixpkgsflake:
# nix shell nixpkgs#youtube-dl
# youtube-dl --version
2020.11.01.1
- Start a shell providing GNU Hello from NixOS 20.03:
# nix shell nixpkgs/nixos-20.03#hello
- Run GNU Hello:
# nix shell nixpkgs#hello --command hello --greeting 'Hi everybody!'
Hi everybody!
- Run multiple commands in a shell environment:
# nix shell nixpkgs#gnumake --command sh -c "cd src && make"
- Run GNU Hello in a chroot store:
# nix shell --store ~/my-nix nixpkgs#hello --command hello
- Start a shell providing GNU Hello in a chroot store:
# nix shell --store ~/my-nix nixpkgs#hello nixpkgs#bashInteractive --command bash
๐ Note that it's necessary to specifybashexplicitly because your default shell (e.g./bin/bash) generally will not exist in the chroot.
like, the chroot is a whole different little world, bestie. your normal shell isn't invited. bring your own. ๐ง
๐ Description ๐
nix shell runs a command in an environment in which the $PATH variable provides the specified installables. If no command is specified, it starts the default shell of your user account specified by $SHELL.
so: give it packages โ it gives you a $PATH with those packages โ you either tell it what command to run, or it just drops you into $SHELL like "hey girl, here's your shell, go off." ๐
๐ Options ๐
๐ the main character options
--command,-ccommand args โ Command and arguments to be executed, defaulting to$SHELL--ignore-environment,-iโ Clear the entire environment (except those specified with--keep).--keep,-kname โ Keep the environment variable name.--stdinโ Read installables from the standard input. No default installable applied.--unset,-uname โ Unset the environment variable name.
๐ง Common evaluation options
--argname expr โ Pass the value expr as the argument name to Nix functions.--argstrname string โ Pass the string string as the argument name to Nix functions.--debuggerโ Start an interactive environment if evaluation fails.--eval-storestore-url โ The URL of the Nix store to use for evaluation, i.e. to store derivations (.drvfiles) and inputs referenced by them.--impureโ Allow access to mutable paths and repositories.--include,-Ipath โ Add path to the Nix search path. The Nix search path is initialized from the colon-separatedNIX_PATHenvironment variable, and is used to look up the location of Nix expressions using paths enclosed in angle brackets (i.e.,<nixpkgs>).
For instance, passing
-I /home/eelco/Dev
-I /etc/nixos
will cause Nix to look for paths relative to /home/eelco/Dev and /etc/nixos, in that order. This is equivalent to setting the NIX_PATH environment variable to
/home/eelco/Dev:/etc/nixos
It is also possible to match paths against a prefix. For example, passing
-I nixpkgs=/home/eelco/Dev/nixpkgs-branch
-I /etc/nixos
will cause Nix to search for <nixpkgs/path> in /home/eelco/Dev/nixpkgs-branch/path and /etc/nixos/nixpkgs/path.
If a path in the Nix search path starts with http:// or https://, it is interpreted as the URL of a tarball that will be downloaded and unpacked to a temporary location. The tarball must consist of a single top-level directory. For example, passing
-I nixpkgs=https://github.com/NixOS/nixpkgs/archive/master.tar.gz
tells Nix to download and use the current contents of the master branch in the nixpkgs repository.
The URLs of the tarballs from the official nixos.org channels (see the manual page for nix-channel) can be abbreviated as channel:<channel-name>. For instance, the following two flags are equivalent:
-I nixpkgs=channel:nixos-21.05
-I nixpkgs=https://nixos.org/channels/nixos-21.05/nixexprs.tar.xz
You can also fetch source trees using flake URLs and add them to the search path. For instance,
-I nixpkgs=flake:nixpkgs
specifies that the prefix nixpkgs shall refer to the source tree downloaded from the nixpkgs entry in the flake registry. Similarly,
-I nixpkgs=flake:github:NixOS/nixpkgs/nixos-22.05
makes <nixpkgs> refer to a particular branch of the NixOS/nixpkgs repository on GitHub.
--override-flakeoriginal-ref resolved-ref โ Override the flake registries, redirecting original-ref to resolved-ref.
๐ Common flake-related options
--commit-lock-fileโ Commit changes to the flake's lock file.--inputs-fromflake-url โ Use the inputs of the specified flake as registry entries.--no-registriesโ Don't allow lookups in the flake registries. This option is deprecated; use--no-use-registries.
๐ deprecated alert. she's old news. use --no-use-registries instead, bestie.
--no-update-lock-fileโ Do not allow any updates to the flake's lock file.--no-write-lock-fileโ Do not write the flake's newly generated lock file.--output-lock-fileflake-lock-path โ Write the given lock file instead offlake.lockwithin the top-level flake.--override-inputinput-path flake-url โ Override a specific flake input (e.g.dwarffs/nixpkgs). This implies--no-write-lock-file.--recreate-lock-fileโ Recreate the flake's lock file from scratch.--reference-lock-fileflake-lock-path โ Read the given lock file instead offlake.lockwithin the top-level flake.--update-inputinput-path โ Update a specific flake input (ignoring its previous entry in the lock file).
๐ข Logging-related options
--debugโ Set the logging verbosity level to 'debug'.--log-formatformat โ Set the format of log output; one ofraw,internal-json,barorbar-with-logs.--print-build-logs,-Lโ Print full build logs on standard error.--quietโ Decrease the logging verbosity level.--verbose,-vโ Increase the logging verbosity level.
๐ Miscellaneous global options
--helpโ Show usage information.--offlineโ Disable substituters and consider all previously downloaded files up-to-date.--optionname value โ Set the Nix configuration setting name to value (overridingnix.conf).--refreshโ Consider all previously downloaded files out-of-date.--repairโ During evaluation, rewrite missing or corrupted files in the Nix store. During building, rebuild missing or corrupted store paths.--versionโ Show version information.
๐ฎ Options that change the interpretation of installables
--exprexpr โ Interpret installables as attribute paths relative to the Nix expression expr.--file,-ffile โ Interpret installables as attribute paths relative to the Nix expression stored in file. If file is the character-, then a Nix expression will be read from standard input. Implies--impure.
โ๏ธ Options to override configuration settings
--accept-flake-configโ Enable theaccept-flake-configsetting.--access-tokensvalue โ Set theaccess-tokenssetting.--allow-dirtyโ Enable theallow-dirtysetting.--allow-import-from-derivationโ Enable theallow-import-from-derivationsetting.--allow-new-privilegesโ Enable theallow-new-privilegessetting.--allow-symlinked-storeโ Enable theallow-symlinked-storesetting.--allow-unsafe-native-code-during-evaluationโ Enable theallow-unsafe-native-code-during-evaluationsetting.--allowed-impure-host-depsvalue โ Set theallowed-impure-host-depssetting.--allowed-urisvalue โ Set theallowed-urissetting.--allowed-usersvalue โ Set theallowed-userssetting.--auto-allocate-uidsโ Enable theauto-allocate-uidssetting.--auto-optimise-storeโ Enable theauto-optimise-storesetting.--bash-promptvalue โ Set thebash-promptsetting.--bash-prompt-prefixvalue โ Set thebash-prompt-prefixsetting.--bash-prompt-suffixvalue โ Set thebash-prompt-suffixsetting.--build-hookvalue โ Set thebuild-hooksetting.--build-poll-intervalvalue โ Set thebuild-poll-intervalsetting.--build-users-groupvalue โ Set thebuild-users-groupsetting.--buildersvalue โ Set thebuilderssetting.--builders-use-substitutesโ Enable thebuilders-use-substitutessetting.--commit-lockfile-summaryvalue โ Set thecommit-lockfile-summarysetting.--compress-build-logโ Enable thecompress-build-logsetting.--connect-timeoutvalue โ Set theconnect-timeoutsetting.--coresvalue โ Set thecoressetting.--diff-hookvalue โ Set thediff-hooksetting.--download-attemptsvalue โ Set thedownload-attemptssetting.--download-speedvalue โ Set thedownload-speedsetting.--eval-cacheโ Enable theeval-cachesetting.--experimental-featuresvalue โ Set theexperimental-featuressetting.--extra-access-tokensvalue โ Append to theaccess-tokenssetting.--extra-allowed-impure-host-depsvalue โ Append to theallowed-impure-host-depssetting.--extra-allowed-urisvalue โ Append to theallowed-urissetting.--extra-allowed-usersvalue โ Append to theallowed-userssetting.--extra-build-hookvalue โ Append to thebuild-hooksetting.--extra-experimental-featuresvalue โ Append to theexperimental-featuressetting.--extra-extra-platformsvalue โ Append to theextra-platformssetting.--extra-hashed-mirrorsvalue โ Append to thehashed-mirrorssetting.--extra-ignored-aclsvalue โ Append to theignored-aclssetting.--extra-nix-pathvalue โ Append to thenix-pathsetting.--extra-platformsvalue โ Set theextra-platformssetting.--extra-plugin-filesvalue โ Append to theplugin-filessetting.--extra-sandbox-pathsvalue โ Append to thesandbox-pathssetting.--extra-secret-key-filesvalue โ Append to thesecret-key-filessetting.--extra-substitutersvalue โ Append to thesubstituterssetting.--extra-system-featuresvalue โ Append to thesystem-featuressetting.--extra-trusted-public-keysvalue
and that's where part 1 wraps, bestie โ there's more coming, don't you dare close the tab ๐โจ
--extra-trusted-public-keysvalue โ append to thetrusted-public-keyssetting ๐ add a key to the trust list without yeeting the old ones.--extra-trusted-substitutersvalue โ append to thetrusted-substituterssetting, same energy, different list.--extra-trusted-usersvalue โ append to thetrusted-userssetting ๐ more trusted besties, no overwriting.--fallbackโ enable thefallbacksetting.--filter-syscallsโ enable thefilter-syscallssetting.--flake-registryvalue โ set theflake-registrysetting.--fsync-metadataโ enable thefsync-metadatasetting.--gc-reserved-spacevalue โ set thegc-reserved-spacesetting.--hashed-mirrorsvalue โ set thehashed-mirrorssetting.--http-connectionsvalue โ set thehttp-connectionssetting.--http2โ enable thehttp2setting โจ--id-countvalue โ set theid-countsetting.--ignore-tryโ enable theignore-trysetting.--ignored-aclsvalue โ set theignored-aclssetting.--impersonate-linux-26โ enable theimpersonate-linux-26setting, yes it's really called that, iconic.--keep-build-logโ enable thekeep-build-logsetting.--keep-derivationsโ enable thekeep-derivationssetting.--keep-env-derivationsโ enable thekeep-env-derivationssetting.--keep-failedโ enable thekeep-failedsetting.--keep-goingโ enable thekeep-goingsetting ๐ซถ--keep-outputsโ enable thekeep-outputssetting.--log-linesvalue โ set thelog-linessetting.--max-build-log-sizevalue โ set themax-build-log-sizesetting.--max-freevalue โ set themax-freesetting.--max-jobsvalue โ set themax-jobssetting.--max-silent-timevalue โ set themax-silent-timesetting.--max-substitution-jobsvalue โ set themax-substitution-jobssetting.--min-freevalue โ set themin-freesetting.--min-free-check-intervalvalue โ set themin-free-check-intervalsetting.--nar-buffer-sizevalue โ set thenar-buffer-sizesetting.--narinfo-cache-negative-ttlvalue โ set thenarinfo-cache-negative-ttlsetting.--narinfo-cache-positive-ttlvalue โ set thenarinfo-cache-positive-ttlsetting.--netrc-filevalue โ set thenetrc-filesetting.--nix-pathvalue โ set thenix-pathsetting.--no-accept-flake-configโ disable theaccept-flake-configsetting.--no-allow-dirtyโ disable theallow-dirtysetting.--no-allow-import-from-derivationโ disable theallow-import-from-derivationsetting.--no-allow-new-privilegesโ disable theallow-new-privilegessetting.--no-allow-symlinked-storeโ disable theallow-symlinked-storesetting.--no-allow-unsafe-native-code-during-evaluationโ disable theallow-unsafe-native-code-during-evaluationsetting ๐ญ that name is a whole paragraph fr.--no-auto-allocate-uidsโ disable theauto-allocate-uidssetting.--no-auto-optimise-storeโ disable theauto-optimise-storesetting.--no-builders-use-substitutesโ disable thebuilders-use-substitutessetting.--no-compress-build-logโ disable thecompress-build-logsetting.--no-eval-cacheโ disable theeval-cachesetting.--no-fallbackโ disable thefallbacksetting.--no-filter-syscallsโ disable thefilter-syscallssetting.--no-fsync-metadataโ disable thefsync-metadatasetting.--no-http2โ disable thehttp2setting.--no-ignore-tryโ disable theignore-trysetting.--no-impersonate-linux-26โ disable theimpersonate-linux-26setting.--no-keep-build-logโ disable thekeep-build-logsetting.--no-keep-derivationsโ disable thekeep-derivationssetting.--no-keep-env-derivationsโ disable thekeep-env-derivationssetting.--no-keep-failedโ disable thekeep-failedsetting.--no-keep-goingโ disable thekeep-goingsetting.--no-keep-outputsโ disable thekeep-outputssetting.--no-preallocate-contentsโ disable thepreallocate-contentssetting.--no-print-missingโ disable theprint-missingsetting.--no-pure-evalโ disable thepure-evalsetting.--no-require-drop-supplementary-groupsโ disable therequire-drop-supplementary-groupssetting.--no-require-sigsโ disable therequire-sigssetting.--no-restrict-evalโ disable therestrict-evalsetting.--no-run-diff-hookโ disable therun-diff-hooksetting.--no-sandboxโ disable sandboxing ๐ (like, actually, the sandbox is off now).--no-sandbox-fallbackโ disable thesandbox-fallbacksetting.--no-show-traceโ disable theshow-tracesetting.--no-substituteโ disable thesubstitutesetting.--no-sync-before-registeringโ disable thesync-before-registeringsetting.--no-trace-function-callsโ disable thetrace-function-callssetting.--no-trace-verboseโ disable thetrace-verbosesetting.--no-use-case-hackโ disable theuse-case-hacksetting.--no-use-cgroupsโ disable theuse-cgroupssetting.--no-use-registriesโ disable theuse-registriessetting.--no-use-sqlite-walโ disable theuse-sqlite-walsetting.--no-use-xdg-base-directoriesโ disable theuse-xdg-base-directoriessetting.--no-warn-dirtyโ disable thewarn-dirtysetting.--plugin-filesvalue โ set theplugin-filessetting.--post-build-hookvalue โ set thepost-build-hooksetting.--pre-build-hookvalue โ set thepre-build-hooksetting.--preallocate-contentsโ enable thepreallocate-contentssetting.--print-missingโ enable theprint-missingsetting.--pure-evalโ enable thepure-evalsetting ๐ง--relaxed-sandboxโ enable sandboxing, but allow builds to disable it ๐--require-drop-supplementary-groupsโ enable therequire-drop-supplementary-groupssetting.--require-sigsโ enable therequire-sigssetting.--restrict-evalโ enable therestrict-evalsetting.--run-diff-hookโ enable therun-diff-hooksetting.--sandboxโ enable sandboxing ๐--sandbox-build-dirvalue โ set thesandbox-build-dirsetting.--sandbox-dev-shm-sizevalue โ set thesandbox-dev-shm-sizesetting.--sandbox-fallbackโ enable thesandbox-fallbacksetting.--sandbox-pathsvalue โ set thesandbox-pathssetting.--secret-key-filesvalue โ set thesecret-key-filessetting.--show-traceโ enable theshow-tracesetting.--ssl-cert-filevalue โ set thessl-cert-filesetting.--stalled-download-timeoutvalue โ set thestalled-download-timeoutsetting.--start-idvalue โ set thestart-idsetting.--storevalue โ set thestoresetting.--substituteโ enable thesubstitutesetting.--substitutersvalue โ set thesubstituterssetting.--sync-before-registeringโ enable thesync-before-registeringsetting.--systemvalue โ set thesystemsetting.--system-featuresvalue โ set thesystem-featuressetting.--tarball-ttlvalue โ set thetarball-ttlsetting.--timeoutvalue โ set thetimeoutsetting.--trace-function-callsโ enable thetrace-function-callssetting.--trace-verboseโ enable thetrace-verbosesetting.--trusted-public-keysvalue โ set thetrusted-public-keyssetting.--trusted-substitutersvalue โ set thetrusted-substituterssetting.--trusted-usersvalue โ set thetrusted-userssetting.--use-case-hackโ enable theuse-case-hacksetting.--use-cgroupsโ enable theuse-cgroupssetting.--use-registriesโ enable theuse-registriessetting.--use-sqlite-walโ enable theuse-sqlite-walsetting.--use-xdg-base-directoriesโ enable theuse-xdg-base-directoriessetting.--user-agent-suffixvalue โ set theuser-agent-suffixsetting.--warn-dirtyโ enable thewarn-dirtysetting.
and that's the whole options buffet, bestie โ every single one accounted for, no cap ๐
that was nix3-shell(1), coming at you from the Nix manual fam, dated 2024-08-31 (or whatever day your copy is stamped with โ check your local page, i'm just the vibe translator) ๐ฆ
stay slaying, keep your store clean, and remember: nix shell loves you back ๐ธโจ
๐ฆ where this page comes from
- ubuntu noble: nix-bin 2.18.1+dfsg-1ubuntu5 ยท LGPL-2.1-only
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms