mirror of
https://github.com/nix-community/home-manager.git
synced 2025-03-19 06:43:01 +00:00
* nixos: remove with lib * nix-darwin: remove with lib * home-manager: remove with lib * modules/accounts: remove with lib * modules/config: remove with lib * modules/i18n: remove with lib * modules/misc: remove with lib * modules: remove with lib * modules/targets: remove with lib * tests/modules/firefox: remove with lib * tests/modules/services: remove with lib
50 lines
1.3 KiB
Nix
50 lines
1.3 KiB
Nix
{ config, lib, ... }:
|
|
|
|
let
|
|
|
|
inherit (lib) mkIf mkOption types;
|
|
|
|
in {
|
|
options.uninstall = mkOption {
|
|
type = types.bool;
|
|
default = false;
|
|
description = ''
|
|
Whether to set up a minimal configuration that will remove all managed
|
|
files and packages.
|
|
|
|
Use this with extreme care since running the generated activation script
|
|
will remove all Home Manager state from your user environment. This
|
|
includes removing all your historic Home Manager generations.
|
|
'';
|
|
};
|
|
|
|
config = mkIf config.uninstall {
|
|
home.packages = lib.mkForce [ ];
|
|
home.file = lib.mkForce { };
|
|
home.stateVersion = lib.mkForce "24.11";
|
|
home.enableNixpkgsReleaseCheck = lib.mkForce false;
|
|
manual.manpages.enable = lib.mkForce false;
|
|
news.display = lib.mkForce "silent";
|
|
|
|
home.activation.uninstall =
|
|
lib.hm.dag.entryAfter [ "installPackages" "linkGeneration" ] ''
|
|
nixProfileRemove home-manager-path
|
|
|
|
if [[ -e $hmDataPath ]]; then
|
|
run rm $VERBOSE_ARG -r "$hmDataPath"
|
|
fi
|
|
|
|
if [[ -e $hmStatePath ]]; then
|
|
run rm $VERBOSE_ARG -r "$hmStatePath"
|
|
fi
|
|
|
|
if [[ -e $genProfilePath ]]; then
|
|
run rm $VERBOSE_ARG "$genProfilePath"*
|
|
fi
|
|
|
|
if [[ -e $legacyGenGcPath ]]; then
|
|
run rm $VERBOSE_ARG "$legacyGenGcPath"
|
|
fi
|
|
'';
|
|
};
|
|
}
|