Move platform check into modules

Before, loading a module would be guarded by an optional platform
condition. This made it possible to avoid loading and evaluating a
module if it did not support the host platform.

Unfortunately, this made it impossible to share a single configuration
between GNU/Linux and Darwin hosts, which some wish to do.

This removes the conditional load and instead inserts host platform
assertions in the modules that are platform specific.

Fixes #1906
This commit is contained in:
Robert Helgesson 2021-07-07 23:24:27 +02:00
parent 1617e56c2f
commit 5f433eb164
No known key found for this signature in database
GPG key ID: 36BDAA14C2797E89
90 changed files with 743 additions and 307 deletions

View file

@ -27,7 +27,11 @@ in {
};
config = mkIf cfg.enable {
assertions =
[ (hm.assertions.assertPlatform "programs.abook" pkgs platforms.linux) ];
home.packages = [ pkgs.abook ];
xdg.configFile."abook/abookrc" = mkIf (cfg.extraConfig != "") {
text = ''
# Generated by Home Manager.

View file

@ -49,6 +49,9 @@ in {
};
config = mkIf cfg.enable {
assertions =
[ (hm.assertions.assertPlatform "programs.foot" pkgs platforms.linux) ];
home.packages = [ cfg.package ];
xdg.configFile."foot/foot.ini" = mkIf (cfg.settings != { }) {

View file

@ -55,6 +55,10 @@ in {
};
config = mkIf getmailEnabled {
assertions = [
(hm.assertions.assertPlatform "programs.getmail" pkgs platforms.linux)
];
home.file = foldl' (a: b: a // b) { }
(map (a: { "${renderConfigFilepath a}".text = renderAccountConfig a; })
accounts);

View file

@ -249,6 +249,11 @@ in {
};
config = mkIf cfg.enable {
assertions = [
(hm.assertions.assertPlatform "programs.i3status-rust" pkgs
platforms.linux)
];
home.packages = [ cfg.package ];
xdg.configFile = mapAttrs' (cfgFileSuffix: cfg:

View file

@ -82,24 +82,25 @@ in {
};
};
config = mkIf cfg.enable (mkMerge [
{
home.packages = [ cfg.package ];
config = mkIf cfg.enable {
assertions = [
(hm.assertions.assertPlatform "programs.mangohud" pkgs platforms.linux)
];
home.sessionVariables = mkIf cfg.enableSessionWide {
MANGOHUD = 1;
MANGOHUD_DLSYM = 1;
};
home.packages = [ cfg.package ];
xdg.configFile."MangoHud/MangoHud.conf" =
home.sessionVariables = mkIf cfg.enableSessionWide {
MANGOHUD = 1;
MANGOHUD_DLSYM = 1;
};
xdg.configFile = {
"MangoHud/MangoHud.conf" =
mkIf (cfg.settings != { }) { text = renderSettings cfg.settings; };
}
{
xdg.configFile = mapAttrs'
(n: v: nameValuePair "MangoHud/${n}.conf" { text = renderSettings v; })
cfg.settingsPerApplication;
}
]);
} // mapAttrs'
(n: v: nameValuePair "MangoHud/${n}.conf" { text = renderSettings v; })
cfg.settingsPerApplication;
};
meta.maintainers = with maintainers; [ zeratax ];
}

View file

@ -402,12 +402,15 @@ in {
};
config = mkIf cfg.enable {
assertions = [{
assertion = cfg.theme == null || cfg.colors == null;
message = ''
Cannot use the rofi options 'theme' and 'colors' simultaneously.
'';
}];
assertions = [
(hm.assertions.assertPlatform "programs.rofi" pkgs platforms.linux)
{
assertion = cfg.theme == null || cfg.colors == null;
message = ''
Cannot use the rofi options 'theme' and 'colors' simultaneously.
'';
}
];
lib.formats.rasi.mkLiteral = value: {
_type = "literal";

View file

@ -63,7 +63,12 @@ in {
};
config = mkIf cfg.enable {
assertions = [
(hm.assertions.assertPlatform "programs.terminator" pkgs platforms.linux)
];
home.packages = [ cfg.package ];
xdg.configFile."terminator/config" =
mkIf (cfg.config != { }) { text = toConfigObject cfg.config; };
};

View file

@ -353,16 +353,26 @@ in {
in allWarnings;
in mkIf cfg.enable (mkMerge [
{ home.packages = [ cfg.package ]; }
{
assertions = [
(lib.hm.assertions.assertPlatform "programs.waybar" pkgs
lib.platforms.linux)
];
home.packages = [ cfg.package ];
}
(mkIf (cfg.settings != [ ]) {
# Generate warnings about defined but unreferenced modules
inherit warnings;
xdg.configFile."waybar/config".source = configSource;
})
(mkIf (cfg.style != null) {
xdg.configFile."waybar/style.css".text = cfg.style;
})
(mkIf cfg.systemd.enable {
systemd.user.services.waybar = {
Unit = {