diff options
author | makefu <github@syntax-fehler.de> | 2020-06-26 13:12:45 +0200 |
---|---|---|
committer | makefu <github@syntax-fehler.de> | 2020-06-26 13:12:45 +0200 |
commit | 237a56464d13ff36b5872387d9dbdc43eeefa146 (patch) | |
tree | b3751d87c6e9a935a2fa19babc1633b252468249 /krebs | |
parent | 5cd6756ceda7da9bfc467a7e2275d2a6a8bd1a80 (diff) | |
parent | 74a050db4e556524b361a73395964272bd1bae18 (diff) |
Merge remote-tracking branch 'tv/master'
Diffstat (limited to 'krebs')
-rw-r--r-- | krebs/5pkgs/simple/dic/default.nix | 6 | ||||
-rw-r--r-- | krebs/5pkgs/simple/fzfmenu/default.nix | 130 | ||||
-rw-r--r-- | krebs/5pkgs/simple/red.nix | 23 |
3 files changed, 112 insertions, 47 deletions
diff --git a/krebs/5pkgs/simple/dic/default.nix b/krebs/5pkgs/simple/dic/default.nix index 6533a1b9b..a74899630 100644 --- a/krebs/5pkgs/simple/dic/default.nix +++ b/krebs/5pkgs/simple/dic/default.nix @@ -4,9 +4,9 @@ stdenv.mkDerivation { name = "dic"; src = fetchgit { - url = http://cgit.ni.krebsco.de/dic; - rev = "refs/tags/v1.1.0"; - sha256 = "1xzn20b9kfz96nvjli8grpi11v80jbl0dmifksmirwcj5v81ndav"; + url = https://cgit.ni.krebsco.de/dic; + rev = "refs/tags/v1.1.1"; + sha256 = "1gbj967a5hj53fdkkxijqgwnl9hb8kskz0cmpjq7v65ffz3v6vag"; }; phases = [ diff --git a/krebs/5pkgs/simple/fzfmenu/default.nix b/krebs/5pkgs/simple/fzfmenu/default.nix index 64e95d233..537b90f42 100644 --- a/krebs/5pkgs/simple/fzfmenu/default.nix +++ b/krebs/5pkgs/simple/fzfmenu/default.nix @@ -1,55 +1,97 @@ -{ pkgs, ... }: +with import <stockholm/lib>; +{ pkgs, ... }@args: + +let + # config cannot be declared in the input attribute set because that would + # cause callPackage to inject the wrong config. Instead, get it from ... + # via args. + config = args.config or {}; + + cfg = eval.config; + + eval = evalModules { + modules = singleton { + _file = toString ./profile.nix; + imports = singleton config; + options = { + appName = mkOption { + default = "fzfmenu"; + type = types.label; + }; + defaultPrompt = mkOption { + default = ">"; + type = types.str; + }; + printQuery = mkOption { + default = true; + type = types.bool; + }; + reverse = mkOption { + default = true; + type = types.bool; + }; + windowTitle = mkOption { + default = "fzfmenu"; + type = types.str; + }; + }; + }; + }; +in pkgs.writeDashBin "fzfmenu" '' set -efu - PROMPT=">" - for i in "$@" - do - case $i in + + # Spawn terminal if called without one, like e.g. from a window manager. + if [ -z ''${TERM+x} ]; then + exec 3<&0 + exec 4>&1 + export FZFMENU_INPUT_FD=3 + export FZFMENU_OUTPUT_FD=4 + exec ${pkgs.rxvt_unicode}/bin/urxvt \ + -name ${cfg.appName} \ + -title ${shell.escape cfg.windowTitle} \ + -e "$0" "$@" + else + exec 0<&''${FZFMENU_INPUT_FD-0} + exec 1>&''${FZFMENU_OUTPUT_FD-1} + fi + + PROMPT=${shell.escape cfg.defaultPrompt} + for i in "$@"; do + case $i in -p) - PROMPT="$2" - shift - shift - break - ;; + PROMPT=$2 + shift 2 + break + ;; -l) - # no reason to filter number of lines - LINES="$2" - shift - shift - break - ;; + # no reason to filter number of lines + LINES=$2 + shift 2 + break + ;; -i) - # we do this anyway - shift - break - ;; + # we do this anyway + shift + break + ;; *) - echo "Unknown option $1" >&2 - shift - ;; - esac + echo "Unknown option $1" >&2 + shift + ;; + esac done - INPUT=$(${pkgs.coreutils}/bin/cat) - OUTPUT="$(${pkgs.coreutils}/bin/mktemp)" - if [ -z ''${TERM+x} ]; then #check if we can print fzf in the shell - ${pkgs.rxvt_unicode}/bin/urxvt \ - -name fzfmenu -title fzfmenu \ - -e ${pkgs.dash}/bin/dash -c \ - "echo \"$INPUT\" | ${pkgs.fzf}/bin/fzf \ - --history=/dev/null \ - --print-query \ - --prompt=\"$PROMPT\" \ - --reverse \ - > \"$OUTPUT\"" 2>/dev/null - else - echo "$INPUT" | ${pkgs.fzf}/bin/fzf \ + + if test -n "''${FZFMENU_FZF_DEFAULT_OPTS-}"; then + FZF_DEFAULT_OPTS=''${FZFMENU_FZF_DEFAULT_OPTS-} + export FZF_DEFAULT_OPTS + fi + + ${pkgs.fzf}/bin/fzf \ --history=/dev/null \ - --print-query \ --prompt="$PROMPT" \ - --reverse \ - > "$OUTPUT" - fi - ${pkgs.coreutils}/bin/tail -1 "$OUTPUT" - ${pkgs.coreutils}/bin/rm "$OUTPUT" + ${optionalString cfg.reverse "--reverse"} \ + ${optionalString cfg.printQuery "--print-query"} \ + ${optionalString cfg.printQuery "| ${pkgs.coreutils}/bin/tail -1"} '' diff --git a/krebs/5pkgs/simple/red.nix b/krebs/5pkgs/simple/red.nix new file mode 100644 index 000000000..51f02aa5c --- /dev/null +++ b/krebs/5pkgs/simple/red.nix @@ -0,0 +1,23 @@ +{ buildGoModule, fetchFromGitHub, lib }: + +buildGoModule rec { + pname = "red"; + version = "g${lib.substring 0 7 src.rev}"; + + src = fetchFromGitHub { + owner = "antonmedv"; + repo = "red"; + rev = "0bfb499760f391d09c6addec2527b0f77eaacdd6"; + sha256 = "0i8f8ih3z97zzbkjkwy4y8z75izm1fscq0rr1g77q7z3kz1lrgrx"; + }; + + modSha256 = "0640x6p5hi7yp001cw13z5a17bi9vgd3gij5fxa1y06d3848cv7l"; + + meta = { + description = "Terminal log analysis tools"; + homepage = https://github.com/analysis/red; + license = lib.licenses.mit; + maintainers = [ lib.maintainers.tv ]; + platforms = lib.platforms.linux; + }; +} |