rbw: deduplicate platform-dependent files

This commit is contained in:
Benedikt Rips
2026-01-05 23:00:14 +01:00
committed by Austin Horstman
parent db116ceb76
commit e926e27968

View File

@@ -10,7 +10,6 @@ let
jsonFormat = pkgs.formats.json { }; jsonFormat = pkgs.formats.json { };
inherit (lib) mkOption types; inherit (lib) mkOption types;
inherit (pkgs.stdenv.hostPlatform) isDarwin;
settingsModule = types.submodule { settingsModule = types.submodule {
freeformType = jsonFormat.type; freeformType = jsonFormat.type;
@@ -62,6 +61,9 @@ let
}; };
}; };
}; };
configDir =
if pkgs.stdenv.hostPlatform.isDarwin then "Library/Application Support" else config.xdg.configHome;
in in
{ {
meta.maintainers = with lib.maintainers; [ ambroisie ]; meta.maintainers = with lib.maintainers; [ ambroisie ];
@@ -93,21 +95,11 @@ in
}; };
}; };
config = lib.mkIf cfg.enable ( config = lib.mkIf cfg.enable {
lib.mkMerge [ home.packages = [ cfg.package ];
{
home.packages = [ cfg.package ];
}
# Only manage configuration if not empty home.file."${configDir}/rbw/config.json" = lib.mkIf (cfg.settings != null) {
(lib.mkIf (cfg.settings != null && !isDarwin) { source = jsonFormat.generate "rbw-config.json" cfg.settings;
xdg.configFile."rbw/config.json".source = jsonFormat.generate "rbw-config.json" cfg.settings; };
}) };
(lib.mkIf (cfg.settings != null && isDarwin) {
home.file."Library/Application Support/rbw/config.json".source =
jsonFormat.generate "rbw-config.json" cfg.settings;
})
]
);
} }