2024-01-05 23:22:27 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
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 { };
|
2024-05-24 15:29:26 +00:00
|
|
|
home.stateVersion = lib.mkForce "24.05";
|
2024-01-05 23:22:27 +00:00
|
|
|
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
|
2024-01-13 22:15:00 +00:00
|
|
|
run rm $VERBOSE_ARG -r "$hmDataPath"
|
2024-01-05 23:22:27 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ -e $hmStatePath ]]; then
|
2024-01-13 22:15:00 +00:00
|
|
|
run rm $VERBOSE_ARG -r "$hmStatePath"
|
2024-01-05 23:22:27 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ -e $genProfilePath ]]; then
|
2024-01-13 22:15:00 +00:00
|
|
|
run rm $VERBOSE_ARG "$genProfilePath"*
|
2024-01-05 23:22:27 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ -e $legacyGenGcPath ]]; then
|
2024-01-13 22:15:00 +00:00
|
|
|
run rm $VERBOSE_ARG "$legacyGenGcPath"
|
2024-01-05 23:22:27 +00:00
|
|
|
fi
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
}
|