mirror of
https://github.com/nix-community/home-manager
synced 2024-12-24 02:39:48 +01:00
pistol: add module
This commit is contained in:
parent
65bcfaccc5
commit
223b9deead
8 changed files with 99 additions and 0 deletions
3
.github/CODEOWNERS
vendored
3
.github/CODEOWNERS
vendored
|
@ -211,6 +211,9 @@
|
|||
|
||||
/modules/programs/pidgin.nix @rycee
|
||||
|
||||
/modules/programs/pistol.nix @mtoohey31
|
||||
/tests/modules/programs/pistol @mtoohey31
|
||||
|
||||
/modules/programs/piston-cli.nix @ethancedwards8
|
||||
|
||||
/modules/programs/powerline-go.nix @DamienCassou
|
||||
|
|
|
@ -287,4 +287,10 @@
|
|||
fingerprint = "D5D6 FD1F 0D9A 3284 FB9B C26D 3F98 EC7E C2B8 7ED1";
|
||||
}];
|
||||
};
|
||||
mtoohey = {
|
||||
name = "Matthew Toohey";
|
||||
email = "contact@mtoohey.com";
|
||||
github = "mtoohey31";
|
||||
githubId = 36740602;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -568,6 +568,13 @@ in
|
|||
A new module is available: 'programs.micro'.
|
||||
'';
|
||||
}
|
||||
|
||||
{
|
||||
time = "2022-06-24T22:40:27+00:00";
|
||||
message = ''
|
||||
A new module is available: 'programs.pistol'.
|
||||
'';
|
||||
}
|
||||
];
|
||||
};
|
||||
}
|
||||
|
|
|
@ -132,6 +132,7 @@ let
|
|||
./programs/pazi.nix
|
||||
./programs/pet.nix
|
||||
./programs/pidgin.nix
|
||||
./programs/pistol.nix
|
||||
./programs/piston-cli.nix
|
||||
./programs/powerline-go.nix
|
||||
./programs/pubs.nix
|
||||
|
|
49
modules/programs/pistol.nix
Normal file
49
modules/programs/pistol.nix
Normal file
|
@ -0,0 +1,49 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
|
||||
cfg = config.programs.pistol;
|
||||
|
||||
configFile =
|
||||
concatStringsSep "\n" (mapAttrsToList (k: v: "${k} ${v}") cfg.config);
|
||||
|
||||
in {
|
||||
meta.maintainers = [ hm.maintainers.mtoohey ];
|
||||
|
||||
options.programs.pistol = {
|
||||
enable = mkEnableOption ''
|
||||
Pistol, a general purpose file previewer designed for terminal file
|
||||
managers'';
|
||||
|
||||
config = mkOption {
|
||||
type = with types; attrsOf str;
|
||||
default = { };
|
||||
example = literalExpression ''
|
||||
{
|
||||
"text/*" = "bat --paging=never --color=always %pistol-filename%";
|
||||
"inode/directory" = "ls -l --color %pistol-filename%";
|
||||
}
|
||||
'';
|
||||
description = ''
|
||||
Pistol configuration written to
|
||||
<filename>$XDG_CONFIG_HOME/pistol/pistol.conf</filename>.
|
||||
'';
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable (mkMerge [
|
||||
{ home.packages = [ pkgs.pistol ]; }
|
||||
|
||||
(mkIf (cfg.config != { } && pkgs.stdenv.hostPlatform.isDarwin) {
|
||||
home.file."Library/Application Support/pistol/pistol.conf".text =
|
||||
configFile;
|
||||
})
|
||||
|
||||
(mkIf (cfg.config != { } && !pkgs.stdenv.hostPlatform.isDarwin) {
|
||||
xdg.configFile."pistol/pistol.conf".text = configFile;
|
||||
})
|
||||
]);
|
||||
}
|
|
@ -88,6 +88,7 @@ import nmt {
|
|||
./modules/programs/nushell
|
||||
./modules/programs/pandoc
|
||||
./modules/programs/pet
|
||||
./modules/programs/pistol
|
||||
./modules/programs/powerline-go
|
||||
./modules/programs/pubs
|
||||
./modules/programs/qutebrowser
|
||||
|
|
31
tests/modules/programs/pistol/config.nix
Normal file
31
tests/modules/programs/pistol/config.nix
Normal file
|
@ -0,0 +1,31 @@
|
|||
{ pkgs, ... }:
|
||||
|
||||
let
|
||||
|
||||
expected = builtins.toFile "settings-expected" ''
|
||||
application/json bat --paging=never --color=always --style=auto --wrap=character --terminal-width=%pistol-extra0% --line-range=1:%pistol-extra1% %pistol-filename%
|
||||
text/* bat --paging=never --color=always --style=auto --wrap=character --terminal-width=%pistol-extra0% --line-range=1:%pistol-extra1% %pistol-filename%'';
|
||||
|
||||
in {
|
||||
programs.pistol = {
|
||||
enable = true;
|
||||
config = {
|
||||
"text/*" =
|
||||
"bat --paging=never --color=always --style=auto --wrap=character --terminal-width=%pistol-extra0% --line-range=1:%pistol-extra1% %pistol-filename%";
|
||||
"application/json" =
|
||||
"bat --paging=never --color=always --style=auto --wrap=character --terminal-width=%pistol-extra0% --line-range=1:%pistol-extra1% %pistol-filename%";
|
||||
};
|
||||
};
|
||||
|
||||
test.stubs.pistol = { };
|
||||
|
||||
nmt.script = let
|
||||
path = if pkgs.stdenv.hostPlatform.isDarwin then
|
||||
"home-files/Library/Application Support/pistol/pistol.conf"
|
||||
else
|
||||
"home-files/.config/pistol/pistol.conf";
|
||||
in ''
|
||||
assertFileExists '${path}'
|
||||
assertFileContent '${path}' '${expected}'
|
||||
'';
|
||||
}
|
1
tests/modules/programs/pistol/default.nix
Normal file
1
tests/modules/programs/pistol/default.nix
Normal file
|
@ -0,0 +1 @@
|
|||
{ pistol-config = ./config.nix; }
|
Loading…
Reference in a new issue