1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2025-03-18 14:28:15 +00:00
home-manager/modules/programs/ripgrep.nix
Austin Horstman d2c014e1c7
treewide: null package support (#6582)
Can generate the config without installing application through home-manager. Helpful when a package is broken (or not provided) on a specific platform through nixpkgs and needs to be installed through other means but you still can benefit from the declarative configuration.
2025-03-07 18:17:52 -06:00

42 lines
1.2 KiB
Nix

{ config, lib, pkgs, ... }:
with lib;
let cfg = config.programs.ripgrep;
in {
meta.maintainers =
[ lib.maintainers.khaneliman lib.hm.maintainers.pedorich-n ];
options = {
programs.ripgrep = {
enable = mkEnableOption "Ripgrep";
package = mkPackageOption pkgs "ripgrep" { nullable = true; };
arguments = mkOption {
type = with types; listOf str;
default = [ ];
example = [ "--max-columns-preview" "--colors=line:style:bold" ];
description = ''
List of arguments to pass to ripgrep. Each item is given to ripgrep as
a single command line argument verbatim.
See <https://github.com/BurntSushi/ripgrep/blob/master/GUIDE.md#configuration-file>
for an example configuration.
'';
};
};
};
config = mkIf cfg.enable {
home = let configPath = "${config.xdg.configHome}/ripgrep/ripgreprc";
in mkMerge [
{ packages = lib.mkIf (cfg.package != null) [ cfg.package ]; }
(mkIf (cfg.arguments != [ ]) {
file."${configPath}".text = lib.concatLines cfg.arguments;
sessionVariables."RIPGREP_CONFIG_PATH" = configPath;
})
];
};
}