fork/home-manager

git clone https://git.julia.blue/fork/home-manager

Naïm Favierripgrep: don't set env. variable if no config (#4254)0841242b

master
1.1 KiB42 linesraw
1{ config, lib, pkgs, ... }:
2
3with lib;
4
5let
6  cfg = config.programs.ripgrep;
7  configPath = "${config.xdg.configHome}/ripgrep/ripgreprc";
8in {
9  meta.maintainers = [ hm.maintainers.pedorich-n ];
10
11  options = {
12    programs.ripgrep = {
13      enable = mkEnableOption "Ripgrep";
14
15      package = mkPackageOption pkgs "ripgrep" { };
16
17      arguments = mkOption {
18        type = with types; listOf str;
19        default = [ ];
20        example = [ "--max-columns-preview" "--colors=line:style:bold" ];
21        description = ''
22          List of arguments to pass to ripgrep. Each item is given to ripgrep as
23          a single command line argument verbatim.
24
25          See <https://github.com/BurntSushi/ripgrep/blob/master/GUIDE.md#configuration-file>
26          for an example configuration.
27        '';
28      };
29    };
30  };
31
32  config = mkIf cfg.enable {
33    home = mkMerge [
34      { packages = [ cfg.package ]; }
35      (mkIf (cfg.arguments != [ ]) {
36        file."${configPath}".text = lib.concatLines cfg.arguments;
37
38        sessionVariables."RIPGREP_CONFIG_PATH" = configPath;
39      })
40    ];
41  };
42}