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 { };
|
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;
|
|
||||||
})
|
|
||||||
]
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user