From ccf205c0c4f6af740cbc37d3cab44b844e8ad374 Mon Sep 17 00:00:00 2001 From: klea Date: Mon, 12 Jan 2026 22:47:04 +0000 Subject: pkgs(little-things-script): init made fun script so i technically could remove little-things from PATH. --- pkgs/default.nix | 1 + pkgs/little-things-script/default.nix | 82 +++++++++++++++++++++++++++++++++++ pkgs/shell/default.nix | 2 + 3 files changed, 85 insertions(+) create mode 100644 pkgs/little-things-script/default.nix diff --git a/pkgs/default.nix b/pkgs/default.nix index 12db68a..ed2aedf 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -9,6 +9,7 @@ lib.makeScope newScope (self: { warcPackages = self.callPackage ./warcPackages { }; little-things = self.callPackage ./little-things { }; + little-things-script = self.callPackage ./little-things-script { }; shell = self.callPackage ./shell { }; diff --git a/pkgs/little-things-script/default.nix b/pkgs/little-things-script/default.nix new file mode 100644 index 0000000..dc094e5 --- /dev/null +++ b/pkgs/little-things-script/default.nix @@ -0,0 +1,82 @@ +{ + lib, + stdenv, + little-things, + installShellFiles, + fzf, +}: + +stdenv.mkDerivation (finalAttrs: { + pname = "little-things-script"; + version = "0-unstable-2026-01-12"; + + buildInputs = [ little-things ]; + src = little-things; + + buildPhase = '' + mkdir $out $out/bin + echo '#!/usr/bin/env bash + ltb="${little-things}/bin" + if [ "$#" -lt 1 ]; then + "$0" __comp__ | ${fzf}/bin/fzf -m | sed "s,^,little-things ," + exit 127; + else + cmd="$1" + shift + fi + if [ "$cmd" == "__comp__" ]; then + ls -1 "$ltb" + elif [ -x "$ltb/$cmd" ]; then + exec "$ltb/$cmd" "$@" + else + echo "$cmd is not executable or not a file" >&2 + exit 127; + fi' >$out/bin/little-things + chmod +x $out/bin/little-things + ''; + + nativeBuildInputs = [ installShellFiles ]; + + postInstall = '' + compfuns() { + echo '_generate_little-things_completions() { + local idx=$1; shift + local words=( "$@" ) + local current_word=''${words[idx]} + + local array=() + while IFS= read -r line; do + array+=("$line") + done < <(little-things __comp__) + for elem in "''${array[@]}"; do + if [[ $elem == "$current_word"* ]]; then echo "$elem"; fi + done +} + +_complete_little-things_bash() { + local raw=($(_generate_little-things_completions "$COMP_CWORD" "''${COMP_WORDS[@]}")) + COMPREPLY=( "''${raw[@]}" ) +} + +_complete_little-things_zsh() { + local -a raw + raw=($(_generate_little-things_completions "$CURRENT" "''${words[@]}")) + compadd -- $raw +} + +if [ -n "''${ZSH_VERSION:-}" ]; then + autoload -Uz compinit + compinit + compdef _complete_little-things_zsh little-things +elif [ -n "''${BASH_VERSION:-}" ]; then + complete -F _complete_little-things_bash little-things +fi' + } + installShellCompletion --cmd little-things \ + --bash <(compfuns) \ + --zsh <(compfuns) + ''; + + meta = little-things.meta; + +}) diff --git a/pkgs/shell/default.nix b/pkgs/shell/default.nix index 7d19eb1..da72fc3 100644 --- a/pkgs/shell/default.nix +++ b/pkgs/shell/default.nix @@ -5,6 +5,7 @@ jq, libfaketime, little-things, + little-things-script, mkShellNoCC, python3, python3Packages, @@ -31,6 +32,7 @@ mkShellNoCC { fossil git # scms internetarchive # ia cmdline tool little-things + little-things-script (zstd.overrideAttrs(prev: { buildInputs = prev.buildInputs ++ [ zlib ]; cmakeFlags = prev.cmakeFlags ++ [ "-DZSTD_ZLIB_SUPPORT:BOOL=ON" ]; })) wikiteam.wikiteam3 wikiteam.dokuwiki-dumper -- cgit v1.3.1-10-gc9f91