mirror of
https://github.com/nix-community/home-manager.git
synced 2026-01-11 01:19:32 +08:00
pistol: deduplicate platform-dependent files
This commit is contained in:
committed by
Austin Horstman
parent
802ce0a7b1
commit
a1a11393d9
@@ -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,31 +77,23 @@ in
|
||||
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable (
|
||||
lib.mkMerge [
|
||||
config = mkIf cfg.enable {
|
||||
assertions = [
|
||||
{
|
||||
assertions = [
|
||||
{
|
||||
assertion = lib.all (
|
||||
{ fpath, mime, ... }: (fpath != "" && mime == "") || (fpath == "" && mime != "")
|
||||
) cfg.associations;
|
||||
message = ''
|
||||
Each entry in programs.pistol.associations must contain exactly one
|
||||
of fpath or mime.
|
||||
'';
|
||||
}
|
||||
];
|
||||
|
||||
home.packages = lib.mkIf (cfg.package != null) [ cfg.package ];
|
||||
assertion = lib.all (
|
||||
{ fpath, mime, ... }: (fpath != "" && mime == "") || (fpath == "" && mime != "")
|
||||
) cfg.associations;
|
||||
message = ''
|
||||
Each entry in programs.pistol.associations must contain exactly one
|
||||
of fpath or mime.
|
||||
'';
|
||||
}
|
||||
];
|
||||
|
||||
(mkIf (cfg.associations != [ ] && pkgs.stdenv.hostPlatform.isDarwin) {
|
||||
home.file."Library/Preferences/pistol/pistol.conf".text = configFile;
|
||||
})
|
||||
home.packages = lib.mkIf (cfg.package != null) [ cfg.package ];
|
||||
|
||||
(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;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user