pistol: deduplicate platform-dependent files

This commit is contained in:
Benedikt Rips
2026-01-05 23:00:13 +01:00
committed by Austin Horstman
parent 802ce0a7b1
commit a1a11393d9

View File

@@ -9,6 +9,9 @@ let
cfg = config.programs.pistol;
configDir =
if pkgs.stdenv.hostPlatform.isDarwin then "Library/Preferences" else config.xdg.configHome;
configFile = lib.concatStringsSep "\n" (
map (
{
@@ -74,9 +77,7 @@ in
};
config = mkIf cfg.enable (
lib.mkMerge [
{
config = mkIf cfg.enable {
assertions = [
{
assertion = lib.all (
@@ -90,15 +91,9 @@ in
];
home.packages = lib.mkIf (cfg.package != null) [ cfg.package ];
}
(mkIf (cfg.associations != [ ] && pkgs.stdenv.hostPlatform.isDarwin) {
home.file."Library/Preferences/pistol/pistol.conf".text = configFile;
})
(mkIf (cfg.associations != [ ] && !pkgs.stdenv.hostPlatform.isDarwin) {
xdg.configFile."pistol/pistol.conf".text = configFile;
})
]
);
home.file."${configDir}/pistol/pistol.conf" = mkIf (cfg.associations != [ ]) {
text = configFile;
};
};
}