ripgrep: add module (#4017)
* ripgrep: add module * ripgrep: Apply suggestions from code review Co-authored-by: Naïm Favier <n@monade.li> * ripgrep: fix maintainers Co-authored-by: Naïm Favier <n@monade.li> * ripgrep: rename config into arguments --------- Co-authored-by: Naïm Favier <n@monade.li>
This commit is contained in:
parent
3876cc613a
commit
2951946183
|
@ -394,4 +394,10 @@
|
|||
github = "natecox";
|
||||
githubId = 2782695;
|
||||
};
|
||||
pedorich-n = {
|
||||
name = "Mykyta Pedorich";
|
||||
email = "pedorich.n@gmail.com";
|
||||
github = "pedorich-n";
|
||||
githubId = 15573098;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -163,6 +163,7 @@ let
|
|||
./programs/qutebrowser.nix
|
||||
./programs/rbw.nix
|
||||
./programs/readline.nix
|
||||
./programs/ripgrep.nix
|
||||
./programs/rofi-pass.nix
|
||||
./programs/rofi.nix
|
||||
./programs/rtorrent.nix
|
||||
|
|
51
modules/programs/ripgrep.nix
Normal file
51
modules/programs/ripgrep.nix
Normal file
|
@ -0,0 +1,51 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let cfg = config.programs.ripgrep;
|
||||
in {
|
||||
meta.maintainers = [ hm.maintainers.pedorich-n ];
|
||||
|
||||
options = {
|
||||
programs.ripgrep = {
|
||||
enable = mkEnableOption "Ripgrep";
|
||||
|
||||
package = mkPackageOption pkgs "ripgrep" { };
|
||||
|
||||
configDir = mkOption {
|
||||
type = types.str;
|
||||
default = "${config.xdg.configHome}/ripgrep";
|
||||
defaultText =
|
||||
literalExpression ''"''${config.xdg.configHome}/ripgrep"'';
|
||||
description = ''
|
||||
Directory where the <filename>ripgreprc</filename> file will be stored.
|
||||
'';
|
||||
};
|
||||
|
||||
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 <link xlink:href="https://github.com/BurntSushi/ripgrep/blob/master/GUIDE.md#configuration-file"/>
|
||||
for an example configuration.
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
home = {
|
||||
packages = [ cfg.package ];
|
||||
|
||||
file."${cfg.configDir}/ripgreprc" =
|
||||
mkIf (cfg.arguments != [ ]) { text = lib.concatLines cfg.arguments; };
|
||||
|
||||
sessionVariables = {
|
||||
"RIPGREP_CONFIG_PATH" = "${cfg.configDir}/ripgreprc";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
|
@ -115,6 +115,7 @@ import nmt {
|
|||
./modules/programs/pubs
|
||||
./modules/programs/qutebrowser
|
||||
./modules/programs/readline
|
||||
./modules/programs/ripgrep
|
||||
./modules/programs/sagemath
|
||||
./modules/programs/sbt
|
||||
./modules/programs/scmpuff
|
||||
|
|
24
tests/modules/programs/ripgrep/custom-arguments.nix
Normal file
24
tests/modules/programs/ripgrep/custom-arguments.nix
Normal file
|
@ -0,0 +1,24 @@
|
|||
{ pkgs, config, ... }: {
|
||||
config = {
|
||||
programs.ripgrep = {
|
||||
enable = true;
|
||||
package = config.lib.test.mkStubPackage { name = "ripgrep"; };
|
||||
arguments = [
|
||||
"--max-columns-preview"
|
||||
"--colors=line:style:bold"
|
||||
"--no-require-git"
|
||||
];
|
||||
};
|
||||
|
||||
nmt.script = ''
|
||||
assertFileExists home-files/.config/ripgrep/ripgreprc
|
||||
assertFileContent home-files/.config/ripgrep/ripgreprc ${
|
||||
pkgs.writeText "ripgrep.expected" ''
|
||||
--max-columns-preview
|
||||
--colors=line:style:bold
|
||||
--no-require-git
|
||||
''
|
||||
}
|
||||
'';
|
||||
};
|
||||
}
|
12
tests/modules/programs/ripgrep/default-arguments.nix
Normal file
12
tests/modules/programs/ripgrep/default-arguments.nix
Normal file
|
@ -0,0 +1,12 @@
|
|||
{ config, ... }: {
|
||||
config = {
|
||||
programs.ripgrep = {
|
||||
enable = true;
|
||||
package = config.lib.test.mkStubPackage { name = "ripgrep"; };
|
||||
};
|
||||
|
||||
nmt.script = ''
|
||||
assertPathNotExists home-files/.config/ripgrep/ripgreprc
|
||||
'';
|
||||
};
|
||||
}
|
4
tests/modules/programs/ripgrep/default.nix
Normal file
4
tests/modules/programs/ripgrep/default.nix
Normal file
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
ripgrep-default-arguments = ./default-arguments.nix;
|
||||
ripgrep-custom-arguments = ./custom-arguments.nix;
|
||||
}
|
Loading…
Reference in a new issue