In most cases where this function is used, suppressing only the standard
output is more appropriate. Culling diagnostic output hides error
messages and makes debugging more difficult and confusing.
`$DRY_RUN_NULL`, which the `--silence` flag replaced, was used both for
suppressing standard output on its own, and for doing so along with
diagnostic output; however, when the `run` function was added this
distinction was lost, and both outputs would be discarded.
This reintroduces the needed functionality, and changes usages of
`--silence` to `--quiet` where previously only standard output was
suppressed, or where this should have probably been the case anyway.
Change-Id: Ifb1b52a1d1eea0117261c782d686ad7c71b43162
This adds a Boolean option `uninstall`. When enabled this option will
reset side-effecting configurations to their "empty" state. The intent
is that this will cause the activation script to remove all managed
files and packages.
Doing it this way should hopefully be more robust than the previous
solution. It also allows a somewhat more convenient uninstall process
when using Flakes; put `uninstall = true` in your existing
configuration and then do a switch.
Also add simple uninstall test in CI test job.
The generation activation script should be run by the user specified
in `home.username` and `home.homeDirectory`. If some other user runs
the activation script, then files may end up in the wrong place or
with the wrong owner.
This commits adds a check early in the activation script that verifies
that the running user match the user in the configuration.
Fixes#4019
The Nix profiles path may not exist right after installing Nix. In
that case, it is created on demand by the Nix CLI tools. However, Home
Manager assumes it exists and fails if it doesn't.
This change makes sure to trigger the creation of the Nix profiles
path before attempting to access it.
If the user runs a recent Nix version that places per-user profiles in
`$XDG_STATE_DIR/nix/profiles`, then migrate the home-manager profile
there.
Also clean up `setupVars` a bit.
Specifically, if the global per-user profiles path do not exist and we
cannot create it during the activation, then place our profile in the
Home Manager data directory. We prefer to use the global location,
though, since it makes it visible to `nix-collect-garbage`.
This is intended to improve compatibility with Nix version 2.14 and
later, which no longer creates the per-user directories.
Also, use the Home Manager data directory to manage the gcroot for the
current generation. It does not have to sit in the global per-user
gcroots directory since it should never be eligible for GC.
This adds an empty `nix-build` command to verify that the user is
having a good Nix install. It also, as a side effect, will create the
necessary per-user `profiles` and `gcroots` directories.
Fixes#1246
Using the `nix-env` command is far more robust. It also has the
benefit that if the per-user `profiles` and `gcroots` directories do
not exist then they will be created with the correct permissions.
Because of the second point this commit also removes the `mkdir` step
of the installation instructions.
PR #1239Closes#474, #948, #1091
It is safest to use the system install of Nix since that will be
compatible with the running nix-daemon and/or databases.
Also add a printout of the used Nix version in the activation script
when running in verbose mode.
Fixes#218.