NIX-ENV-UNINSTALL(1)
π nix-env --uninstall π
okay bestie, welcome to the nix-env --uninstall(1) page β part one of three, and yes, we're doing this together, no cap. General Commands Manual energy, but make it cute. π
β¨ Name β¨
nix-env --uninstall β remove packages from user environment ποΈβ¨ like... say goodbye, but politely.
π¦ Synopsis π¦
nix-env {--uninstall | -e} drvnamesβ¦
πΈ Description πΈ
So here's the tea, bestie: the uninstall operation creates a new user environment, based on the current generation of the active profile, and from that new environment the store paths designated by the symbolic names drvnames get removed. π«Ά
Lowkey that's it. That's the whole vibe. New env, minus the stuff you named. π
π Options π
The following options are allowed for all nix-env operations, but ngl they may not always have an effect. It's giving "universal pass, sometimes no-op." π
--file,-fpath β Specifies the Nix expression (and from here on out we're calling it the active Nix expression, iconic nickname honestly) that the--install,--upgrade, and--query --availableoperations use to obtain derivations. The default is~/.nix-defexpr.
And here's the plot twist: if the argument starts with http:// or https://, it gets interpreted as the URL of a tarball that will be downloaded and unpacked to a temporary location. π¦ That tarball must include a single top-level directory containing at least a file named default.nix. So like, one folder, one default.nix, that's the requirement, fr fr.
--profile,-ppath β Specifies the profile to be used by those operations that operate on a profile (which we're now calling the active profile, slay). A profile is a sequence of user environments called generations, one of which is the current generation. It's giving family tree but for environments. π--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. π Manifesting but making zero moves.
--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). So you get the full tea before anything happens. π₯
--system-filtersystem β By default, operations such as--query --availableshow derivations matching any platform. This option lets you use derivations for the specified platform system. Like a vibe check but for architectures. π
π reminder bestie:--dry-runis your friend. Never raw-dog a--delete-generations, iykyk.
more coming in part two, don't you dare close the tab π«Ά
π Common Options π
okay so bestie, most Nix commands share the same lil starter pack of command-line options. like, they all went to the same nail salon. here's the full menu π
--helpβ prints out a summary of the command syntax and then exits. your classic "what do i even type" escape hatch.--versionβ prints out the Nix version number on standard output and exits.--verbose/-vβ turns the volume UP on diagnostic messages printed on standard error. here's the tea tho: for each Nix operation, what shows up on standard output is well-defined; any diagnostic info goes to standard error, never standard output. you can pass this flag again and again. currently these verbosity levels exist:0"Errors only" β only prints messages explaining why the Nix invocation failed.1"Informational" β prints useful messages about what Nix is doing. this one 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. and honestly? appropriate name, no notes π
--quietβ turns the volume DOWN on diagnostic messages printed on standard error. it's the inverse option to-v/--verbose. you can pass this repeatedly too, and it uses the same verbosity levels list as above.--log-formatformat β lets you change the output of the log format. format is one of:rawβ this is 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 like, don't build your whole personality on parsing it, k?
barβ only display a progress bar during the builds.bar-with-logsβ display the raw logs, with the progress bar at the bottom. visually it's giving multitasking π
--no-build-output/-Qβ by default, output written by builders to standard output and standard error gets echoed to the Nix command's standard error. this option suppresses that behaviour. but note, the builder's standard output and error are always written to a log file inprefix/nix/var/log/nix. so they're never actually lost, they're just not yapping at you πΈ--max-jobs/-jnumber β sets the maximum number of build jobs that Nix will do in parallel to number. specifyautoto use the number of CPUs in the system. the default comes from themax-jobsconfiguration setting, which itself defaults to1. a higher value is useful on SMP systems or to exploit I/O latency. setting it to0disallows building on the local machine β which is exactly what you want when you only want builds to happen on remote builders. cute π¦--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 the builder should use all available CPU cores in the system. go girl, use the whole machine π₯--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 comes from themax-silent-timeconfiguration setting.0means no time-out.--timeoutβ sets the maximum number of seconds that a builder can run. the default comes from thetimeoutconfiguration setting.0means no timeout.--keep-going/-kβ keep going in case of failed builds, to the greatest extent possible. so like, 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 the "we don't gatekeep, we keep going" energy π«Ά--keep-failed/-Kβ says that in case of a build failure, the temporary directory (usually in/tmp) where the build takes place should not be deleted. the path of the build directory gets printed as an informational message. so you can go snoop π--fallbackβ whenever Nix tries 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 where 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. so 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). like bestie, one flaky wifi moment should not cost you your whole afternoon π
--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. heads up.--argname 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.) β yes this is fiddly, we've all been there π
--arg-from-filename path β passes the contents of file path as the argument name to Nix functions.--arg-from-stdinname β passes the contents of stdin as the argument name to Nix functions.--argstrname 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. so much less escaping drama β¨--attr/-AattrPath β selects 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. yeah, zero-indexed, she's counting from zero, periodt π
--eval-storestore-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. choose your fighter π
-I/--includepath β 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. so -I is the main character here, no cap π
--impureβ allow access to mutable paths and repositories.--optionname value β set the Nix configuration option name to value. this overrides settings in the Nix configuration file (seenix.conf(5)). command line flag said "i'm the boss now" π--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. like, she's thorough, she's not fast π
π Note β see man nix.conf for overriding configuration settings with command line flags.
πΈ Environment variables πΈ
the vibes the environment gives us π¦
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. so if you ever wondered where your profile actually lives, it's this or those two fallbacks, bestie π
β¨ COMMON ENVIRONMENT VARIABLES β¨
okay bestie, this is where Nix actually listens to your shell. Most Nix commands interpret the following environment variables, so if something's acting weird, vibe check these first. π
π Configuration environment variables π
The following environment variables affect how Nix loads its configuration. See the configuration file documentation for full details. lowkey important, ngl.
NIX_CONF_DIRβ overrides the system configuration directory. ποΈNIX_USER_CONF_FILESβ overrides the user configuration file locations.NIX_CONFIGβ provides configuration settings inline. like, straight into the env var, no file needed. iconic. β¨
π Store setting environment variables π
NIX_IGNORE_SYMLINK_STOREβ normally, the Nix store directory (typically/nix/store) is not allowed to contain any symlink components, and that's on purpose: it's how Nix prevents "impure" builds. here's the tea π΅ β builders sometimes "canonicalise" paths by resolving all symlink components. So builds on different machines (where/nix/storeresolves to different locations) could totally yield different results. Usually that's not a problem, except when builds get deployed to machines where/nix/storeresolves differently. If you're sure you're not gonna do that, you can setNIX_IGNORE_SYMLINK_STOREto1.
note that if you're symlinking the Nix store so you can put it on another file system than the root file system, on Linux you're better off using bind mount points, e.g.,
$ mkdir /nix
$ mount -o bind /mnt/otherdisk/nix /nix
Consult the mount 8 manual page for details.
NIX_STORE_DIRβ overrides the location of the Nix store. πΎ On Unix, the default is/nix/store, set at compile time by thelibstore:store-dirbuild option. On Windows, there is no compile-time setting; the default is%PROGRAMDATA%\nix\store, determined at runtime using the%PROGRAMDATA%Known Folder.
See the Store Types chapter; each store has a store setting linking back to this as its default.
NIX_LOG_DIRβ overrides the location of the Nix log directory. π On Unix, the default is/nix/var/log/nix, set at compile time by thelog-dirbuild option. On Windows, there's no compile-time setting; the 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 have per-store settings that override this.
NIX_STATE_DIRβ overrides the location of the Nix state directory. π§ On Unix, the default is${localstatedir}/nix, wherelocalstatediris a compile-time build option defaulting to/nix/var. On Windows, there's no compile-time setting; the 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.
NIX_DAEMON_SOCKET_PATHβ overrides the path to the Unix domain socket used to communicate with the Nix daemon. π Defaults todaemon-socket/socketwithin the state directory (seeNIX_STATE_DIR).
See the Local Daemon Store documentation for details on how the socket path is resolved.
TMPDIRβ use the specified directory to store temporary files. In particular, this includes temporary build directories, and bestie those can eat up substantial amounts of disk space. π The default is/tmp.NIX_REMOTEβ overrides the store setting. that's it, that's the whole thing.
π¦ Nix language evaluator settings π¦
NIX_SHOW_STATSβ if set to1, Nix will print some evaluation statistics, such as the number of values allocated. πNIX_COUNT_CALLSβ if set to1, Nix will print how often functions were called during Nix expression evaluation. super useful for profiling your Nix expressions.GC_INITIAL_HEAP_SIZEβ if Nix has been configured to use the Boehm garbage collector, this variable sets the initial size of the heap in bytes. It defaults to384 MiB. Setting it to a low value reduces memory consumption, but will increase runtime due to the overhead of garbage collection. trade-offs, always trade-offs. π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. The following environment variables override the locations for these directories:
- user configuration directory (
#user-conf-dir):NIX_CONFIG_HOME(#env-NIXCONFIGHOME) - user state directory:
NIX_STATE_HOME(#env-NIXSTATEHOME) - user cache directory:
NIX_CACHE_HOME(#env-NIXCACHEHOME)
When these are not set, 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 (e.g. nix-env, nix-channel) use dotfiles in $HOME instead of these directories unless use-xdg-base-directories is enabled. New Nix commands (experimental) use the proper directories by default. glow up. β¨
When use-xdg-base-directories is enabled, the configuration directory is resolved as:
$NIX_CONFIG_HOME, if it is defined- Otherwise, the platform default (e.g.
$XDG_CONFIG_HOME/nixon Unix)
Likewise for the state and cache directories.
π Miscellaneous environment variables π
IN_NIX_SHELLβ indicator that tells if the current environment was set up bynix-shell. It can have the valuespureorimpure. π
π Appendix: OS-specific conventions π
This information is not Nix-specific, but is referenced above. still slay though.
β Unix: XDG Base Directories β
The XDG Base Directory Specification defines standard locations for user-specific configuration, state, and cache files on Unix systems.
The following environment variables are used:
XDG_CONFIG_HOME(#env-XDGCONFIGHOME) (default~/.config)XDG_STATE_HOME(#env-XDGSTATEHOME) (default~/.local/state)XDG_CACHE_HOME(#env-XDGCACHEHOME) (default~/.cache)XDG_CONFIG_DIRS(#env-XDGCONFIGDIRS) (default/etc/xdg) β colon-separated list of additional configuration base directories, searched afterXDG_CONFIG_HOME
β Windows: Known Folders β
On Windows, Known Folders provide standard locations for application data on Windows.
The relevant folders are:
%APPDATA%(#env-APPDATA) β per-user roaming application data%LOCALAPPDATA%(#env-LOCALAPPDATA) β per-user local application data%PROGRAMDATA%(#env-PROGRAMDATA) β system-wide application data
π Examples π
$ nix-env --uninstall gcc
$ nix-env --uninstall '.*' (remove everything)
and that's the whole page bestie!! π«Ά we ate, fr fr. this was nix-env --uninstall(1) β screaming, crying, uninstalling. πβ¨ go forth and remove packages, you absolute icon. πππ¦
π¦ 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