mirror of
https://github.com/nix-community/home-manager.git
synced 2026-01-11 17:39:37 +08:00
rbw: deduplicate platform-dependent files
This commit is contained in:
committed by
Austin Horstman
parent
db116ceb76
commit
e926e27968
@@ -10,7 +10,6 @@ let
|
||||
jsonFormat = pkgs.formats.json { };
|
||||
|
||||
inherit (lib) mkOption types;
|
||||
inherit (pkgs.stdenv.hostPlatform) isDarwin;
|
||||
|
||||
settingsModule = types.submodule {
|
||||
freeformType = jsonFormat.type;
|
||||
@@ -62,6 +61,9 @@ let
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
configDir =
|
||||
if pkgs.stdenv.hostPlatform.isDarwin then "Library/Application Support" else config.xdg.configHome;
|
||||
in
|
||||
{
|
||||
meta.maintainers = with lib.maintainers; [ ambroisie ];
|
||||
@@ -93,21 +95,11 @@ in
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable (
|
||||
lib.mkMerge [
|
||||
{
|
||||
home.packages = [ cfg.package ];
|
||||
}
|
||||
config = lib.mkIf cfg.enable {
|
||||
home.packages = [ cfg.package ];
|
||||
|
||||
# Only manage configuration if not empty
|
||||
(lib.mkIf (cfg.settings != null && !isDarwin) {
|
||||
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;
|
||||
})
|
||||
]
|
||||
);
|
||||
home.file."${configDir}/rbw/config.json" = lib.mkIf (cfg.settings != null) {
|
||||
source = jsonFormat.generate "rbw-config.json" cfg.settings;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user