NIX-ENV-SET(1)
๐ nix-env --set(1) โ General Commands Manual ๐
okay bestie, welcome to nix-env --set ๐
this is part of the nix-env manual, and this page is short but mighty, so let's get into it.
โจ Name โจ
nix-env --set โ set profile to contain a specified derivation
๐ธ Synopsis ๐ธ
nix-env --set drvname
๐ฆ Description ๐ฆ
The --set operation modifies the current generation of a profile so that it contains exactly the specified derivation, and nothing else.
Like. exactly. Nothing else. It's giving "you are the entire vibe, there is no other vibe." ๐
๐ Options ๐
The following options are allowed for all nix-env operations, but may not always have an effect. (So they're always invited to the party, they just don't always dance. ๐)
--file,-fpath โ Specifies the Nix expression (designated below as the active Nix expression) used by the--install,--upgrade, and--query --availableoperations to obtain derivations. The default is~/.nix-defexpr.
If the argument 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 include a single top-level directory containing at least a file named default.nix. ๐ฆโจ
--profile,-ppath โ Specifies the profile to be used by those operations that operate on a profile (designated below as the active profile). A profile is a sequence of user environments called generations, one of which is the current generation. ๐ฑ--dry-runโ For the--install,--upgrade,--uninstall,--switch-generation,--delete-generationsand--rollbackoperations, this flag will causenix-envto print what would be done if this flag had not been specified, without actually doing it. ๐ no cap, it just tells you.
--dry-run also prints out which paths will be substituted (i.e., downloaded) and which paths will be built from source (because no substitute is available). sneak peek energy ๐ฎ
--system-filtersystem โ By default, operations such as--query --availableshow derivations matching any platform. This option allows you to use derivations for the specified platform system. ๐ฅ๏ธ๐
more coming, bestie โ this page keeps going ๐
โจ Common Options โจ
okay so bestie, listen up ๐ โ most Nix commands accept these command-line options. They're like the shared group chat of every Nix binary. Learn them once, use them everywhere. Periodt.
--helpโ prints out a lil summary of the command syntax and then dips. That's it, that's the whole vibe.--versionโ prints the Nix version number on standard output and exits. Iconic, quick, done.--verbose/-vโ turns the drama up on diagnostic messages printed to standard error. Here's the thing tho: for each Nix operation, what gets printed to standard output is well-defined; any diagnostic tea gets spilled to standard error, never to standard output. So stdout stays clean, stderr does the talking ๐ฃ๏ธ
This option can be specified repeatedly โ stack it, girl. Currently these are the verbosity levels that exist:
- 0 โErrors onlyโ โ only prints messages explaining why the Nix invocation flopped ๐ญ
- 1 โInformationalโ โ prints useful messages about what Nix is doing. This is the default โจ
- 2 โTalkativeโ โ prints more informational messages.
- 3 โChattyโ โ prints even more informational messages.
- 4 โDebugโ โ prints debug information.
- 5 โVomitโ โ prints vast amounts of debug information. Yes it's really called that ๐
--quietโ decreases the level of verbosity of diagnostic messages printed on standard error. It's the inverse option to-v/--verbose. Also stackable โ specify it repeatedly, babes. See the verbosity levels list above โ๏ธ--log-format formatโ changes the output of the log format, where format is one of these queens:rawโ the raw format, as outputted bynix-build.internal-jsonโ outputs the logs in a structured manner.
โ ๏ธ Warning โ while the schema itself is relatively stable, the format of the error-messages (namely of the msg-field) can change between releases. So don't hardcode your parsing and then act shocked, bestie ๐
barโ only displays a progress bar during the builds. Minimalist slay.bar-with-logsโ displays the raw logs, with the progress bar at the bottom. Best of both worlds fr fr.
--no-build-output/-Qโ by default, output written by builders to standard output and standard error is echoed to the Nix command's standard error. This option suppresses that behaviour. BUT โ and this is important โ the builder's standard output and error are always written to a log file inprefix/nix/var/log/nix. So nothing is lost, it's just not yelling at you anymore ๐ซถ--max-jobs/-j numberโ sets the maximum number of build jobs that Nix will perform in parallel to the specified number. Specifyautoto use the number of CPUs in the system. The default is specified by themax-jobsconfiguration setting, which itself defaults to1. A higher value is useful on SMP systems or to exploit I/O latency. Get that parallelism, girl ๐ฅ
Setting it to 0 disallows building on the local machine โ which is useful when you want builds to happen only on remote builders. Bye local machine ๐
--coresโ sets the value of theNIX_BUILD_CORESenvironment variable in the invocation of builders. Builders can use this variable at their discretion to control the maximum amount of parallelism. For instance, in Nixpkgs, if the derivation attributeenableParallelBuildingis set totrue, the builder passes the-jNflag to GNU Make. It defaults to the value of thecoresconfiguration setting, if set, or1otherwise. The value0means that the builder should use all available CPU cores in the system. All of them. Every last one ๐--max-silent-timeโ sets the maximum number of seconds that a builder can go without producing any data on standard output or standard error. The default is specified by themax-silent-timeconfiguration setting.0means no time-out. So if your build is being silent, this is the vibe check it's failing ๐ง--timeoutโ sets the maximum number of seconds that a builder can run. The default is specified by thetimeoutconfiguration setting.0means no timeout. Live your truth, run forever, whatever.--keep-going/-kโ keep going in case of failed builds, to the greatest extent possible. That is, if building an input of some derivation fails, Nix will still build the other inputs, but not the derivation itself. Without this option, Nix stops if any build fails (except for builds of substitutes), possibly killing builds in progress (in case of parallel or distributed builds). It's giving "we don't stop, we keep going" ๐ช--keep-failed/-Kโ specifies that in case of a build failure, the temporary directory (usually in/tmp) in which the build takes place should not be deleted. The path of the build directory is printed as an informational message. Perfect for when you need to go snooping through the wreckage ๐--fallbackโ whenever Nix attempts to build a derivation for which substitutes are known for each output path, but realising the output paths through the substitutes fails, fall back on building the derivation.
The most common scenario in which this is useful is when we have registered substitutes in order to perform binary distribution from, say, a network repository. If the repository is down, the realisation of the derivation will fail. When this option is specified, Nix will build the derivation instead. Thus, installation from binaries falls back on installation from source. This option is not the default since it is generally not desirable for a transient failure in obtaining the substitutes to lead to a full build from source (with the related consumption of resources). So like, it's the backup plan, not the plan ๐
--readonly-modeโ when this option is used, no attempt is made to open the Nix database. Most Nix operations do need database access, so those operations will fail. Look but don't touch energy ๐ซ--arg name valueโ this option is accepted bynix-env,nix-instantiate,nix-shellandnix-build. When evaluating Nix expressions, the expression evaluator will automatically try to call functions that it encounters. It can automatically call functions for which every argument has a default value (e.g.,{ argName ? defaultValue }: ...).
With --arg, you can also call functions that have arguments without a default value (or override a default value). That is, if the evaluator encounters a function with an argument named name, it will call it with value value.
For instance, the top-level default.nix in Nixpkgs is actually a function:
{ # The system (e.g., `i686-linux') for which to build the packages.
system ? builtins.currentSystem
...
}: ...
So if you call this Nix expression (e.g., when you do nix-env --install --attr pkgname), the function will be called automatically using the value builtins.currentSystem for the system argument. You can override this using --arg, e.g., nix-env --install --attr pkgname --arg system \"i686-freebsd\". (Note that since the argument is a Nix string literal, you have to escape the quotes.) Shell escaping is the enemy and it always has been ๐ญ
--arg-from-file name pathโ pass the contents of file path as the argument name to Nix functions. No quoting gymnastics required.--arg-from-stdin nameโ pass the contents of stdin as the argument name to Nix functions. Pipe it in and go ๐--argstr name valueโ this option is like--arg, only the value is not a Nix expression but a string. So instead of--arg system \"i686-linux\"(the outer quotes are to keep the shell happy) you can say--argstr system i686-linux. Way less screaming at your terminal.--attr/-A attrPathโ select an attribute from the top-level Nix expression being evaluated. (nix-env,nix-instantiate,nix-buildandnix-shellonly.) The attribute path attrPath is a sequence of attribute names separated by dots. For instance, given a top-level Nix expression e, the attribute pathxorg.xorgserverwould cause the expressione.xorg.xorgserverto be used. Seenix-env --installfor some concrete examples.
In addition to attribute names, you can also specify array indices. For instance, the attribute path foo.3.bar selects the bar attribute of the fourth element of the array in the foo attribute of the top-level expression. Zero-indexed, bestie, don't forget ๐ง
--eval-store store-urlโ the URL to the Nix store to use for evaluation, i.e. where to store derivations (.drvfiles) and inputs referenced by them.--expr/-Eโ interpret the command line arguments as a list of Nix expressions to be parsed and evaluated, rather than as a list of file names of Nix expressions. (nix-instantiate,nix-buildandnix-shellonly.)
For nix-shell, this option is commonly used to give you a shell in which you can build the packages returned by the expression. If you want to get a shell which contain the built packages ready for use, give your expression to the nix-shell --packages convenience flag instead. Different vibe, different flag ๐ฆ
-I/--include pathโ add an entry to the list of search paths used to resolve lookup paths. This option may be given multiple times.
Paths added through -I take precedence over the nix-path configuration setting and the NIX_PATH environment variable. Loud and clear, she goes first ๐
--impureโ allow access to mutable paths and repositories. We're breaking the rules today I guess ๐--option name valueโ set the Nix configuration option name to value. This overrides settings in the Nix configuration file (seenix.confโต). The โต means it's a manual page reference, iykyk.--repairโ fix corrupted or missing store paths by redownloading or rebuilding them. Note that this is slow because it requires computing a cryptographic hash of the contents of every path in the closure of the build. Also note the warning undernix-store --repair-path. It's the deep-clean, not the tidy-up ๐งผ
๐ Note โ see man nix.conf for overriding configuration settings with command line flags.
๐ธ Environment variables ๐ธ
NIX_PROFILEโ location of the Nix profile. Defaults to the target of the symlink~/.nix-profile, if it exists, or/nix/var/nix/profiles/defaultotherwise. That's where your profile actually lives, no cap ๐
โจ Common Environment Variables โจ
Okay so most Nix commands read these little guys, bestie โ here's the full lineup ๐
๐ง Configuration environment variables
These ones decide how Nix loads its config. Full deets live in the configuration file documentation, but here's the vibe:
NIX_CONF_DIRโ overrides where the system configuration directory lives.NIX_USER_CONF_FILESโ overrides the locations of the user configuration files.NIX_CONFIGโ lets you feed configuration settings in inline, right there in the env. iconic.
๐ฌ Store setting environment variables
NIX_IGNORE_SYMLINK_STOREโ so normally the Nix store directory (typically/nix/store) is not allowed to contain any symlink components, and that's on purpose: it stops "impure" builds. Here's why, bestie: builders sometimes "canonicalise" paths by resolving all the symlink components. So if/nix/storeresolves to different places on different machines, the same build could spit out different results. Usually that's fine, except when you deploy builds to machines where/nix/storeresolves differently. If you're sure you're not gonna do that, you can setNIX_IGNORE_SYMLINK_STOREto1.
Heads up tho: if you're symlinking the Nix store just so you can park it on a different file system than root, on Linux you're way better off using bind mount points, like:
$ mkdir /nix
$ mount -o bind /mnt/otherdisk/nix /nix
Consult the mount 8 manual page for the details ๐
NIX_STORE_DIRโ overrides where the Nix store is. On Unix, default is/nix/store, set at compile time by thelibstore:store-dirbuild option. On Windows, there's no compile-time setting at all; the default is%PROGRAMDATA%\nix\store, figured out at runtime using the%PROGRAMDATA%Known Folder.
See the Store Types chapter โ every store has a store setting that links back to this as its default.
NIX_LOG_DIRโ overrides where the Nix log directory is. On Unix, default is/nix/var/log/nix, set at compile time by thelog-dirbuild option. On Windows, no compile-time setting; default is%PROGRAMDATA%\nix\log, determined at runtime using the%PROGRAMDATA%Known Folder.
The Local Store, Local Daemon Store, and Experimental SSH Store with filesystem mounted all have per-store settings that override this.
NIX_STATE_DIRโ overrides where the Nix state directory is. On Unix, default is${localstatedir}/nix, wherelocalstatediris a compile-time build option defaulting to/nix/var. On Windows, no compile-time setting; default is%PROGRAMDATA%\nix\state, determined at runtime using the%PROGRAMDATA%Known Folder.
The Local Store, Local Daemon Store, and Experimental SSH Store with filesystem mounted have per-store settings that override this too.
NIX_DAEMON_SOCKET_PATHโ overrides the path to the Unix domain socket used to talk to the Nix daemon. Defaults todaemon-socket/socketinside the state directory (peepNIX_STATE_DIR).
See the Local Daemon Store documentation for how the socket path actually gets resolved.
TMPDIRโ use this directory for temporary files. Specifically it includes temporary build directories, and those can eat up substantial amounts of disk space, so choose wisely. Default is/tmp.NIX_REMOTEโ overrides the store setting.
๐ง Nix language evaluator settings
NIX_SHOW_STATSโ set it to1and Nix prints some evaluation statistics, like how many values got allocated. numbers go brrr.NIX_COUNT_CALLSโ set it to1and Nix prints how often functions got called during Nix expression evaluation. So useful for profiling your Nix expressions, fr.GC_INITIAL_HEAP_SIZEโ if Nix was configured to use the Boehm garbage collector, this sets the initial heap size in bytes. Defaults to 384 MiB. Set it low and you use less memory, but runtime goes up because of garbage collection overhead. tradeoffs, bestie.NIX_PATHโ a colon-separated list of search path entries used to resolve lookup paths.
This environment variable overrides the value of the nix-path configuration setting.
It can be extended using the -I option.
Example
$ export NIX_PATH=/home/eelco/Dev:nixos-config=/etc/nixos
If NIX_PATH is set to an empty string, resolving search paths will always fail. ๐ญ
Example
$ NIX_PATH= nix-instantiate --eval '<nixpkgs>'
error: file 'nixpkgs' was not found in the Nix search path (add it using $NIX_PATH or -I)
๐ User Directories
Nix supports per-user configuration, state, and cache directories, and these environment variables override where they go:
- user configuration directory:
NIX_CONFIG_HOME - user state directory:
NIX_STATE_HOME - user cache directory:
NIX_CACHE_HOME
When you don't set them, the defaults depend on the platform:
- On Unix, the XDG base directories:
$XDG_CONFIG_HOME/nix,$XDG_STATE_HOME/nix,$XDG_CACHE_HOME/nix - On Windows, the Windows Known Folders:
%APPDATA%\nix\config,%LOCALAPPDATA%\nix\state,%LOCALAPPDATA%\nix\cache
For backwards compatibility, legacy Nix commands (like nix-env, nix-channel) use dotfiles in $HOME instead of these directories, unless use-xdg-base-directories is enabled. New Nix commands (the experimental ones) use the proper directories by default. slay.
When use-xdg-base-directories is enabled, the configuration directory gets resolved like:
$NIX_CONFIG_HOME, if it is defined- Otherwise, the platform default (e.g.
$XDG_CONFIG_HOME/nixon Unix)
Same energy for the state and cache directories.
๐ Miscellaneous environment variables
IN_NIX_SHELLโ an indicator that tells you whether the current environment was set up bynix-shell. It can have the valuespureorimpure.
๐ Appendix: OS-specific conventions
This info isn't Nix-specific at all, it's just referenced above. still valid tho ๐ซถ
๐ง Unix: XDG Base Directories
The XDG Base Directory Specification defines standard locations for user-specific configuration, state, and cache files on Unix systems.
These environment variables are used:
XDG_CONFIG_HOME(default~/.config)XDG_STATE_HOME(default~/.local/state)XDG_CACHE_HOME(default~/.cache)XDG_CONFIG_DIRS(default/etc/xdg) โ a colon-separated list of additional configuration base directories, searched afterXDG_CONFIG_HOME
๐ช Windows: Known Folders
On Windows, Known Folders give you standard locations for application data on Windows.
The relevant folders:
%APPDATA%โ per-user roaming application data%LOCALAPPDATA%โ per-user local application data%PROGRAMDATA%โ system-wide application data
๐ Examples
The following updates a profile so that its current generation will contain just Firefox:
$ nix-env --profile /nix/var/nix/profiles/browser --set firefox
And that's a wrap on this whole page, bestie!! ๐ You officially survived every single environment variable Nix could possibly throw at you. This was pulled from the nix-env --set(1) page โ go be iconic with it ๐๐
๐ฆ where this page comes from
- fedora 44: nix-legacy 2.35.3-2.fc44 ยท LGPL-2.1-or-later
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms