diff --git a/modules/programs/pistol.nix b/modules/programs/pistol.nix index 89a39ff79..1dde8c8da 100644 --- a/modules/programs/pistol.nix +++ b/modules/programs/pistol.nix @@ -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; + }; + }; }