fd: add module

This commit is contained in:
uncenter 2024-04-12 10:19:25 -04:00 committed by Robert Helgesson
parent ff1c364654
commit ffc3600f40
No known key found for this signature in database
GPG Key ID: 96E745BD17AA17ED
3 changed files with 67 additions and 0 deletions

View File

@ -1476,6 +1476,13 @@ in {
A new module is available: 'programs.bun'.
'';
}
{
time = "2024-04-18T22:30:49+00:00";
message = ''
A new module is available: 'programs.fd'.
'';
}
];
};
}

View File

@ -86,6 +86,7 @@ let
./programs/emacs.nix
./programs/eww.nix
./programs/eza.nix
./programs/fd.nix
./programs/feh.nix
./programs/firefox.nix
./programs/fish.nix

59
modules/programs/fd.nix Normal file
View File

@ -0,0 +1,59 @@
{ config, lib, pkgs, ... }:
with lib; {
meta.maintainers = [ maintainers.uncenter ];
options.programs.fd = {
enable = mkEnableOption
"fd, a simple, fast and user-friendly alternative to {command}`find`";
ignores = mkOption {
type = types.listOf types.str;
default = [ ];
example = [ ".git/" "*.bak" ];
description = "List of paths that should be globally ignored.";
};
hidden = mkOption {
type = types.bool;
default = false;
description = ''
Search hidden files and directories ({option}`--hidden` argument).
'';
};
extraOptions = mkOption {
type = types.listOf types.str;
default = [ ];
example = [ "--no-ignore" "--absolute-path" ];
description = ''
Extra command line options passed to fd.
'';
};
package = mkPackageOption pkgs "fd" { };
};
config = let
cfg = config.programs.fd;
args = escapeShellArgs (optional cfg.hidden "--hidden" ++ cfg.extraOptions);
optionsAlias = { fd = "fd ${args}"; };
in mkIf cfg.enable {
home.packages = [ cfg.package ];
programs.bash.shellAliases = optionsAlias;
programs.zsh.shellAliases = optionsAlias;
programs.fish.shellAliases = optionsAlias;
programs.ion.shellAliases = optionsAlias;
programs.nushell.shellAliases = optionsAlias;
xdg.configFile."fd/ignore" = mkIf (cfg.ignores != [ ]) {
text = concatStringsSep "\n" cfg.ignores + "\n";
};
};
}