mirror of
https://github.com/nix-community/home-manager.git
synced 2025-11-08 11:36:05 +01:00
visidata: add module (#6956)
This commit is contained in:
parent
355a6b937d
commit
d6b0c05457
6 changed files with 84 additions and 0 deletions
|
|
@ -295,6 +295,7 @@ let
|
|||
./programs/vinegar.nix
|
||||
./programs/vscode.nix
|
||||
./programs/vscode/haskell.nix
|
||||
./programs/visidata.nix
|
||||
./programs/pywal.nix
|
||||
./programs/rbenv.nix
|
||||
./programs/wallust.nix
|
||||
|
|
|
|||
50
modules/programs/visidata.nix
Normal file
50
modules/programs/visidata.nix
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
{
|
||||
lib,
|
||||
pkgs,
|
||||
config,
|
||||
...
|
||||
}:
|
||||
let
|
||||
inherit (lib)
|
||||
types
|
||||
mkIf
|
||||
mkEnableOption
|
||||
mkPackageOption
|
||||
mkOption
|
||||
;
|
||||
|
||||
cfg = config.programs.visidata;
|
||||
in
|
||||
{
|
||||
meta.maintainers = with lib.hm.maintainers; [ aguirre-matteo ];
|
||||
|
||||
options.programs.visidata = {
|
||||
enable = mkEnableOption "Visidata";
|
||||
package = mkPackageOption pkgs "visidata" { nullable = true; };
|
||||
visidatarc = mkOption {
|
||||
type = types.lines;
|
||||
default = "";
|
||||
example = ''
|
||||
options.min_memory_mb=100 # stop processing without 100MB free
|
||||
|
||||
bindkey('0', 'go-leftmost') # alias '0' to go to first column, like vim
|
||||
|
||||
def median(values):
|
||||
L = sorted(values)
|
||||
return L[len(L)//2]
|
||||
|
||||
vd.aggregator('median', median)
|
||||
'';
|
||||
description = ''
|
||||
Configuration settings and Python function declarations
|
||||
to be written to ~/.visidatarc. All available options
|
||||
can be found here: <https://www.visidata.org/docs/>.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
home.packages = mkIf (cfg.package != null) [ cfg.package ];
|
||||
home.file.".visidatarc" = mkIf (cfg.visidatarc != "") { text = cfg.visidatarc; };
|
||||
};
|
||||
}
|
||||
|
|
@ -309,6 +309,7 @@ import nmtSrc {
|
|||
./modules/programs/uv
|
||||
./modules/programs/vifm
|
||||
./modules/programs/vim-vint
|
||||
./modules/programs/visidata
|
||||
./modules/programs/vscode
|
||||
./modules/programs/wallust
|
||||
./modules/programs/watson
|
||||
|
|
|
|||
9
tests/modules/programs/visidata/config
Normal file
9
tests/modules/programs/visidata/config
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
options.min_memory_mb=100
|
||||
|
||||
bindkey('0', 'go-leftmost')
|
||||
|
||||
def median(values):
|
||||
L = sorted(values)
|
||||
return L[len(L)//2]
|
||||
|
||||
vd.aggregator('median', median)
|
||||
1
tests/modules/programs/visidata/default.nix
Normal file
1
tests/modules/programs/visidata/default.nix
Normal file
|
|
@ -0,0 +1 @@
|
|||
{ visidata-example-config = ./example-config.nix; }
|
||||
22
tests/modules/programs/visidata/example-config.nix
Normal file
22
tests/modules/programs/visidata/example-config.nix
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
{
|
||||
programs.visidata = {
|
||||
enable = true;
|
||||
visidatarc = ''
|
||||
options.min_memory_mb=100
|
||||
|
||||
bindkey('0', 'go-leftmost')
|
||||
|
||||
def median(values):
|
||||
L = sorted(values)
|
||||
return L[len(L)//2]
|
||||
|
||||
vd.aggregator('median', median)
|
||||
'';
|
||||
};
|
||||
|
||||
nmt.script = ''
|
||||
assertFileExists home-files/.visidatarc
|
||||
assertFileContent home-files/.visidatarc \
|
||||
${./config}
|
||||
'';
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue