nixos/cosmic: add warning when a core package is excluded

Also add an option to toggle the visibility of warning to not cause
alarm fatigue.
This commit is contained in:
Pratham Patel 2025-04-23 20:50:29 +05:30 committed by Alyssa Ross
parent b3fab2e4b1
commit 0aae134f2f

View file

@ -13,6 +13,7 @@
let
cfg = config.services.desktopManager.cosmic;
excludedCorePkgs = lib.lists.intersectLists corePkgs config.environment.cosmic.excludePackages;
# **ONLY ADD PACKAGES WITHOUT WHICH COSMIC CRASHES, NOTHING ELSE**
corePkgs =
with pkgs;
@ -47,6 +48,10 @@ in
services.desktopManager.cosmic = {
enable = lib.mkEnableOption "Enable the COSMIC desktop environment";
showExcludedPkgsWarning = lib.mkEnableOption "Disable the warning for excluding core packages." // {
default = true;
};
xwayland.enable = lib.mkEnableOption "Xwayland support for the COSMIC compositor" // {
default = true;
};
@ -152,5 +157,22 @@ in
services.power-profiles-daemon.enable = lib.mkDefault (
!config.hardware.system76.power-daemon.enable
);
warnings = lib.optionals (cfg.showExcludedPkgsWarning && excludedCorePkgs != [ ]) [
''
The `environment.cosmic.excludePackages` option was used to exclude some
packages from the environment which also includes some packages that the
maintainers of the COSMIC DE deem necessary for the COSMIC DE to start
and initialize. Excluding said packages creates a high probability that
the COSMIC DE will fail to initialize properly, or completely. This is an
unsupported use case. If this was not intentional, please assign an empty
list to the `environment.cosmic.excludePackages` option. If you want to
exclude non-essential packages, please look at the NixOS module for the
COSMIC DE and look for the essential packages in the `corePkgs` list.
You can stop this warning from appearing by setting the option
`services.desktopManager.cosmic.showExcludedPkgsWarning` to `false`.
''
];
};
}