Add assertion for needed upgrade to home-manager 20.03

This commit is contained in:
Tobias Happ 2020-04-24 21:49:49 +02:00
parent 55d33896fd
commit b4c185c146

View file

@ -7,6 +7,9 @@ with lib;
let let
cfg = config.home-manager; cfg = config.home-manager;
tryEval = builtins.tryEval <home-manager/modules/modules.nix>;
assertion = tryEval.success && builtins.functionArgs (import tryEval.value) ? useNixpkgsModule;
extendedLib = import <home-manager/modules/lib/stdlib-extended.nix> pkgs.lib; extendedLib = import <home-manager/modules/lib/stdlib-extended.nix> pkgs.lib;
hmModule = types.submoduleWith { hmModule = types.submoduleWith {
@ -49,7 +52,10 @@ in
}; };
config = mkOption { config = mkOption {
type = types.nullOr hmModule; type =
if assertion
then types.nullOr hmModule
else types.unspecified;
default = null; default = null;
description = "Home Manager configuration."; description = "Home Manager configuration.";
}; };
@ -71,7 +77,20 @@ in
###### implementation ###### implementation
config = mkIf (cfg.config != null) { config = mkIf (cfg.config != null) (mkMerge [
{
assertions = [
{
inherit assertion;
message = "You are currently using release-19.09 branch of home-manager, you need "
+ "to update to the release-20.03 channel.";
}
];
}
# hack to determine if cfg.config is a valid home-manager config
(mkIf (cfg.config ? home && cfg.config.home ? activationPackage) {
inherit (cfg.config) assertions warnings; inherit (cfg.config) assertions warnings;
@ -94,5 +113,7 @@ in
environment.packages = mkIf cfg.useUserPackages cfg.config.home.packages; environment.packages = mkIf cfg.useUserPackages cfg.config.home.packages;
}; })
]);
} }