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:
parent
1617e56c2f
commit
5f433eb164
90 changed files with 743 additions and 307 deletions
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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 != { }) {
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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 ];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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";
|
||||
|
|
|
|||
|
|
@ -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; };
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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 = {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue