diff options
Diffstat (limited to '')
97 files changed, 4533 insertions, 1234 deletions
diff --git a/pkgs/by-name/au/aumo/aumo.sh b/pkgs/by-name/au/aumo/aumo.sh index 84d39deb..991f257c 100755 --- a/pkgs/by-name/au/aumo/aumo.sh +++ b/pkgs/by-name/au/aumo/aumo.sh @@ -1,28 +1,63 @@ #! /usr/bin/env dash -# shellcheck source=/dev/null -SHELL_LIBRARY_VERSION="2.1.2" . %SHELL_LIBRARY_PATH +NAME="aumo" + +error() { + printf "\033[1;91m==> ERROR:\033[0m \033[1;93m%s\033[0m\n" "$*" >&2 +} + +die() { + error "$1" + exit "${2-1}" +} + +usage() { + echo "Usage: $NAME mount|unmount" +} + +get_mounted_labels() { + findmnt --output label --json | jq '.filesystems | map(.label) | sort | unique | map(select(. != null))' +} +get_unmounted_labels() { + first=true + + find /dev/disk/by-label -printf "%P\n" | while read -r label; do + if ! get_mounted_labels | jq 'join("\n")' --raw-output | grep "$label" --quiet; then + if [ "$first" = "true" ]; then + first=false + else + printf "|" + fi + printf "%s" "$label" + fi + done +} unmounting() { - disk_name="$(find /dev/disk/by-label -type l -printf "%P|" | rofi -sep "|" -dmenu -p "Select disk to mount")" + disk_name="$(get_mounted_labels | jq 'join("|")' --join-output | rofi -sep "|" -dmenu -p "Select disk to unmount")" udisksctl unmount --block-device "/dev/disk/by-label/$disk_name" } mounting() { - disk_name="$(find /dev/disk/by-label -type l -printf "%P|" | rofi -sep "|" -dmenu -p "Select disk to mount")" + disk_name="$(get_unmounted_labels | rofi -sep "|" -dmenu -p "Select disk to mount")" udisksctl mount --block-device "/dev/disk/by-label/$disk_name" } -case "$1" in +case "${1-unset}" in "mount") mounting ;; "unmount" | "umount") unmounting ;; +"unset") + usage + die "You need to provide one argument." + ;; *) - die "Usage: $NAME mount|unmount" + usage + die "Unknown command: '$1'" ;; esac diff --git a/pkgs/by-name/au/aumo/package.nix b/pkgs/by-name/au/aumo/package.nix index 20054bb5..5ced60dc 100644 --- a/pkgs/by-name/au/aumo/package.nix +++ b/pkgs/by-name/au/aumo/package.nix @@ -1,17 +1,23 @@ { - sysLib, + writeShellApplication, + # Dependencies udisks, findutils, rofi, + jq, + gnugrep, + util-linux, }: -sysLib.writeShellScript { +writeShellApplication { name = "aumo"; - src = ./aumo.sh; - generateCompletions = false; - keepPath = false; - dependencies = [ + text = builtins.readFile ./aumo.sh; + inheritPath = false; + runtimeInputs = [ udisks findutils rofi + jq + gnugrep + util-linux # for findmnt ]; } diff --git a/pkgs/by-name/ba/battery/battery.sh b/pkgs/by-name/ba/battery/battery.sh index e650ba5d..771a892a 100755 --- a/pkgs/by-name/ba/battery/battery.sh +++ b/pkgs/by-name/ba/battery/battery.sh @@ -1,8 +1,5 @@ #!/usr/bin/env dash -# shellcheck source=/dev/null -SHELL_LIBRARY_VERSION="2.1.2" . %SHELL_LIBRARY_PATH - capacity="$(cat /sys/class/power_supply/BAT0/capacity)" status="$(cat /sys/class/power_supply/BAT0/status)" diff --git a/pkgs/by-name/ba/battery/package.nix b/pkgs/by-name/ba/battery/package.nix index 9c0e194b..71ab1b9f 100644 --- a/pkgs/by-name/ba/battery/package.nix +++ b/pkgs/by-name/ba/battery/package.nix @@ -1,9 +1,12 @@ -{sysLib}: -sysLib.writeShellScript { +{ + writeShellApplication, + + # Dependencies + coreutils, +}: +writeShellApplication { name = "battery"; - src = ./battery.sh; - generateCompletions = false; - keepPath = false; - dependencies = [ - ]; + text = builtins.readFile ./battery.sh; + inheritPath = false; + runtimeInputs = [coreutils]; } diff --git a/pkgs/by-name/be/beetsExtraPlugins/package.nix b/pkgs/by-name/be/beetsExtraPlugins/package.nix index 1cea9d3b..f019922e 100644 --- a/pkgs/by-name/be/beetsExtraPlugins/package.nix +++ b/pkgs/by-name/be/beetsExtraPlugins/package.nix @@ -1,3 +1,3 @@ -{pkgs, ...}: { +{...}: { # xtractor = pkgs.callPackage ./xtractor.nix {beets = pkgs.beetsPackages.beets-minimal;}; } diff --git a/pkgs/by-name/be/beetsExtraPlugins/xtractor.nix b/pkgs/by-name/be/beetsExtraPlugins/xtractor.nix index ecbc10ce..17981cdb 100644 --- a/pkgs/by-name/be/beetsExtraPlugins/xtractor.nix +++ b/pkgs/by-name/be/beetsExtraPlugins/xtractor.nix @@ -3,11 +3,10 @@ fetchFromGitHub, python3Packages, beets, -}: +}: {} # # NOTE: This fails to build now. It didn't work anyways. See # https://git.sr.ht/~johnhamelink/nix/tree/master/item/home/hosts/sun/beets/beets-plugin-xtractor.nix # for a possibly working version. <2025-03-29> - # # FIXME: Find a way to update this derivation <2024-08-11> # let # version = "0.4.2"; @@ -56,3 +55,4 @@ # license = lib.licenses.mit; # }; # } + diff --git a/pkgs/by-name/br/brightness/brightness.sh b/pkgs/by-name/br/brightness/brightness.sh index 887dbb1e..3d6b2335 100755 --- a/pkgs/by-name/br/brightness/brightness.sh +++ b/pkgs/by-name/br/brightness/brightness.sh @@ -1,24 +1,23 @@ -#!/usr/bin/env dash +#!/usr/bin/env sh -# shellcheck source=/dev/null -SHELL_LIBRARY_VERSION="2.1.2" . %SHELL_LIBRARY_PATH +die() { + echo "ERROR: $1" + exit 1 +} help() { cat <<EOF This is a system brightness manager USAGE: - $NAME up [VALUE] | down [VALUE] + $NAME set VALUE OPTIONS: --help | -h Output this help and exit. - --version | -v - Output the version and exit. - COMMANDS: - set [VALUE] + set VALUE Set the brightness to the specified percentage. ARGUMENTS: @@ -27,17 +26,14 @@ ARGUMENTS: EOF } -BACKLIGHT="/sys/class/backlight/%BACKLIGHT_NAME" +BACKLIGHT="/sys/class/backlight/$BACKLIGHT_NAME" brightness() { perc="$1" - max="$(cat $BACKLIGHT/max_brightness)" - + max="$(cat "$BACKLIGHT/max_brightness")" new="$(echo | awk --assign=perc="$perc" '{printf (perc / 100)}')" - output="$(echo | awk --assign=new="$new" --assign=max="$max" '{printf max * new}')" - echo "$output" >"$BACKLIGHT/brightness" } @@ -47,10 +43,6 @@ for arg in "$@"; do help exit 0 ;; - "--version" | "-v") - version - exit 0 - ;; esac done diff --git a/pkgs/by-name/br/brightness/package.nix b/pkgs/by-name/br/brightness/package.nix index c2e31a0c..7d9d2194 100644 --- a/pkgs/by-name/br/brightness/package.nix +++ b/pkgs/by-name/br/brightness/package.nix @@ -1,14 +1,20 @@ { - sysLib, + writeShellApplication, + # Arguments backlightName ? "intel_backlight", # nixosConfig.soispha.laptop.backlight + # Dependencies + gawk, + coreutils, }: -sysLib.writeShellScript { +writeShellApplication { name = "brightness"; - src = ./brightness.sh; - generateCompletions = true; - keepPath = false; + text = builtins.readFile ./brightness.sh; + inheritPath = false; - replacementStrings = {BACKLIGHT_NAME = backlightName;}; + runtimeEnv = {BACKLIGHT_NAME = backlightName;}; - dependencies = []; + runtimeInputs = [ + gawk + coreutils + ]; } diff --git a/pkgs/by-name/co/con2pdf/con2pdf.sh b/pkgs/by-name/co/con2pdf/con2pdf.sh index 27c9d092..e5d8ce37 100755 --- a/pkgs/by-name/co/con2pdf/con2pdf.sh +++ b/pkgs/by-name/co/con2pdf/con2pdf.sh @@ -1,19 +1,8 @@ #! /usr/bin/env dash -# shellcheck source=/dev/null -SHELL_LIBRARY_VERSION="2.1.2" . %SHELL_LIBRARY_PATH - -# needed for help() and version -# shellcheck disable=2034 -AUTHORS="Soispha" -# shellcheck disable=2034 -YEARS="2023" -# shellcheck disable=2034 -VERSION="1.0.0" - -# NAME is from the wrapper -# shellcheck disable=SC2269 -NAME="$NAME" +# TODO(@bpeetz): This should probably be rewritten in rust. <2025-04-14> + +NAME="con2pdf" help() { cat <<EOF Scan images and turn them into a pdf. diff --git a/pkgs/by-name/co/con2pdf/package.nix b/pkgs/by-name/co/con2pdf/package.nix index 8eb994fd..df24872c 100644 --- a/pkgs/by-name/co/con2pdf/package.nix +++ b/pkgs/by-name/co/con2pdf/package.nix @@ -1,24 +1,25 @@ { - sysLib, + writeShellApplication, writeText, - # dependencies + # Dependencies sane-backends, imagemagick, coreutils, fd, }: -sysLib.writeShellScript { +writeShellApplication { name = "con2pdf"; - src = ./con2pdf.sh; - generateCompletions = true; - keepPath = false; - dependencies = [ + text = builtins.readFile ./con2pdf.sh; + inheritPath = false; + + runtimeInputs = [ sane-backends imagemagick coreutils fd ]; - replacementStrings = { + + runtimeEnv = { DEVICE_FUNCTION = # This is here, because escaping the whole function, to use it in the shell script # directly just isn't possible diff --git a/pkgs/by-name/fu/fupdate-flake/fupdate-flake.sh b/pkgs/by-name/fu/fupdate-flake/fupdate-flake.sh new file mode 100755 index 00000000..f63d7de0 --- /dev/null +++ b/pkgs/by-name/fu/fupdate-flake/fupdate-flake.sh @@ -0,0 +1,184 @@ +#! /usr/bin/env sh + +UPDATE_SCRIPT_NAME="update.sh" + +info() { + echo "Info: $1" +} +dbg() { + if [ "${DEBUG_ENABLE-unset}" != "unset" ]; then + echo "Debug: $1" >&2 + fi +} +die() { + echo "Error: $1" + exit 1 +} + +# Search for a file “upwards”. +# This will return the relative path from "$1" to the found file. +# +# # Type +# upfind :: Path -> String -> Path +# +# # Arguments +# $1 +# : The directory to use as start of your search. +# +# $2 +# : The file to search for. +# +# # Example +# upfind "/home/user1" "/usr" +# => /usr +upfind() { + starting_directory="$(readlink --canonicalize "$1")" + search_string="$2" + + current_directory="$starting_directory" + + while + search_result=$(fd "$search_string" "$current_directory/" --max-depth 1) + dbg "upfind - search in $current_directory gives: $search_result" + [ -z "$search_result" ] && [ "$current_directory" != "/" ] + do current_directory=$(dirname "$current_directory"); done + + realpath --relative-to="$1" "$search_result" +} + +# Construct the storage path for the update script allowed hashes. +# +# # Type +# get_storage_path :: Path -> Path +# +# # Arguments +# $1 +# : The path to the update script +# +# # Returns +# The constructed storage path. +get_storage_path() { + update_script="$(realpath "$1")" + + storage_path="$XDG_DATA_HOME/fupdate-flake/$update_script" + echo "$storage_path" +} + +# Checks if a given path to the update script is allowed. +# +# # Type +# is_allowed :: Path -> bool +# +# # Arguments +# $1 +# : The path to the update script to check. +# +# # Return exit code +# 0 +# : If the update script is allowed +# +# 1 +# : If it is not. +is_allowed() { + update_script="$(realpath "$1")" + + storage_path="$(get_storage_path "$update_script")" + + # Use this invocation, to also include the path to the `$update_script` + update_script_hash="$(sha256sum "$update_script")" + + if [ -f "$storage_path" ]; then + if [ "$(cat "$storage_path")" = "$update_script_hash" ]; then + return 0 + else + return 1 + fi + else + return 1 + fi +} + +# Asks the user if they want to allow a given script. +# +# # Type +# ask_to_allow_update_script :: Path +# +# # Arguments +# $1 +# : The path to the update script to ask for. +ask_to_allow_update_script() { + update_script="$(realpath "$1")" + + printf "\033[2J" # clear the screen + cat "$update_script" + + printf "Do you want to allow this script?[N/y]: " + read -r allow + + case "$allow" in + [yY]) + info "Update script allowed." + + storage_path="$(get_storage_path "$update_script")" + update_script_hash="$(sha256sum "$update_script")" + + mkdir --parents "$(dirname "$storage_path")" + printf "%s" "$update_script_hash" >"$storage_path" + ;; + *) + info "Update script not allowed." + ;; + esac +} + +# Performs a full update. +# This consists of running an update script. +# Additionally, it also checks for duplicated inputs in a `flake.lock` file, if it exists. +# +# # Type +# update :: Path -> Path -> [String] +# +# # Arguments +# $1 +# : The path to the update script to execute. +# +# $2 +# : The base directory from which to start the update. +# +# $3 +# : Arguments to pass to the update script. +update() { + update_script="$1" + base_directory="$2" + shift 2 + + cd "$base_directory" || die "The provided base directory '$base_directory' cannot be accessed" + dbg "Changed directory to: $base_directory" + + dbg "Executing update script ('$update_script') following args: '$*'" + "$update_script" "$@" + + if [ -f "flake.lock" ] && grep '[^0-9]_[0-9]' flake.lock --quiet; then + batgrep '[^0-9]_[0-9]' flake.lock + die "Your flake.nix contains duplicate inputs!" + fi +} + +main() { + base_directory="$(git rev-parse --show-toplevel)" + update_script="$(upfind "$PWD" "$UPDATE_SCRIPT_NAME")" + dbg "update_script is: $update_script" + + if [ "$update_script" = "" ]; then + die "Failed to find update script." + elif is_allowed "$update_script"; then + update "$update_script" "$base_directory" "$@" + else + ask_to_allow_update_script "$update_script" + is_allowed "$update_script" && main "$@" + fi +} + +main + +# vim: ft=sh diff --git a/pkgs/by-name/fu/fupdate-flake/package.nix b/pkgs/by-name/fu/fupdate-flake/package.nix new file mode 100644 index 00000000..5b2d7d29 --- /dev/null +++ b/pkgs/by-name/fu/fupdate-flake/package.nix @@ -0,0 +1,28 @@ +{ + writeShellApplication, + # Dependencies + coreutils, + fd, + gnugrep, + bat-extras, # For `batgrep` + bat, # used by batgrep + gnused, # required by batgrep + git, +}: +writeShellApplication { + name = "fupdate-flake"; + text = builtins.readFile ./fupdate-flake.sh; + + # The `update.sh` script might actually want to keep the path. + inheritPath = true; + + runtimeInputs = [ + coreutils + fd + gnugrep + bat-extras.batgrep + bat # Used by `batgrep` + gnused # Required by `batgrep` + git + ]; +} diff --git a/pkgs/by-name/fu/fupdate-sys/fupdate-sys.sh b/pkgs/by-name/fu/fupdate-sys/fupdate-sys.sh new file mode 100755 index 00000000..28e09f3d --- /dev/null +++ b/pkgs/by-name/fu/fupdate-sys/fupdate-sys.sh @@ -0,0 +1,158 @@ +#!/usr/bin/env dash + +# FIXME(@bpeetz): Ideally I could replace this script with a deployment tool. Thus we +# would have the same tool on the server as I use in my config. <2025-04-14> + +# Shell library {{{ +die() { + error "$1" + if [ -n "$2" ]; then + exit "$2" + else + exit 1 + fi +} +print() { + # shellcheck disable=SC2059 + printf "$*" +} +println() { + # shellcheck disable=SC2059 + printf "$*\n" +} +eprint() { + >&2 print "$@" +} +eprintln() { + >&2 println "$@" +} +if [ "${NO_COLOR-unset}" != "unset" ]; then + error() { + eprintln "==> ERROR:" "$*" + } + warning() { + eprintln "==> WARNING:" "$*" + } + debug() { + [ -n "$SHELL_LIBRARY_DEBUG" ] && eprintln "==> [Debug:]" "$*" + } + debug2() { + [ -n "$SHELL_LIBRARY_DEBUG" ] && eprintln " -> [Debug:]" "$*" + } + msg() { + eprintln "==>" "$*" + } + msg2() { + eprintln " ->" "$*" + } + prompt() { + eprint "..>" "$*" + } +else + error() { + eprintln "\033[1;91m==> ERROR:\033[0m" "\033[1;93m$*\033[0m" + } + warning() { + eprintln "\033[1;91m==> WARNING:\033[0m" "\033[1;93m$*\033[0m" + } + debug() { + [ -n "$SHELL_LIBRARY_DEBUG" ] && eprintln "\033[1;94m==> [Debug:]\033[0m" "\033[1;93m$*\033[0m" + } + debug2() { + [ -n "$SHELL_LIBRARY_DEBUG" ] && eprintln "\033[1;94m -> [Debug:]\033[0m" "\033[1;93m$*\033[0m" + } + msg() { + eprintln "\033[1;96m==>\033[0m" "\033[1;93m$*\033[0m" + } + msg2() { + eprintln "\033[1;96m ->\033[0m" "\033[1;93m$*\033[0m" + } + prompt() { + eprint "\033[1;96m..>\033[0m" "\033[1;93m$*\033[0m" + } +fi +# }}} + +NAME="update-sys" +help() { + cat <<EOF +This is a NixOS System flake update manager. + +USAGE: + $NAME [--branch <branchname>] [--help] + +OPTIONS: + --branch | -b BRANCHNAME + select a branch to update from. + + --mode | -m MODE + select a mode to update with + + --help | -h + output this help. +ARGUMENTS: + BRANCHNAME := [[ git branch --list --format '%(refname:short)' ]] + The name of the branch to deploy the config from + + MODE := switch|boot|test|build|dry-build|dry-activate|edit|repl|build-vm|build-vm-with-bootloader + See the 'nixos-rebuild' manpage for more information about these modes. +EOF + exit "$1" +} +BRANCH="" + +while [ "$#" -gt 0 ]; do + case "$1" in + "--help" | "-h") + help 0 + ;; + "--branch" | "-b") + if [ "${2-unset}" != "unset" ]; then + BRANCH="$2" + else + error "$1 requires an argument" + help 1 + fi + shift 2 + ;; + "--mode" | "-m") + if [ "${2-unset}" != "unset" ]; then + MODE="$2" + else + error "$1 requires an argument" + help 1 + fi + shift 2 + ;; + *) + error "the option $1 does not exist!" + help 1 + ;; + esac +done + +cd /etc/nixos || die "No /etc/nixos" +msg "Starting system update..." +git remote update origin --prune >/dev/null 2>&1 +if ! [ "$BRANCH" = "" ]; then + git switch "$BRANCH" >/dev/null 2>&1 && msg2 "Switched to branch '$BRANCH'" +fi +msg2 "Updating git repository..." +git pull --rebase + +# We use a tempfile, to make this truly async. +default_branch=$(mktemp) +cleanup() { + rm "$default_branch" +} +trap cleanup EXIT + +git remote show origin | grep 'HEAD' | cut -d':' -f2 | sed -e 's/^ *//g' -e 's/ *$//g' >"$default_branch" & + +msg2 "Updating system..." +nixos-rebuild "${MODE-switch}" + +git switch "$(cat "$default_branch")" >/dev/null 2>&1 && msg2 "Switched to branch '$(cat "$default_branch")'" +msg "Finished Update!" + +# vim: ft=sh diff --git a/pkgs/by-name/up/update-sys/package.nix b/pkgs/by-name/fu/fupdate-sys/package.nix index 8777f82d..be692d12 100644 --- a/pkgs/by-name/up/update-sys/package.nix +++ b/pkgs/by-name/fu/fupdate-sys/package.nix @@ -1,5 +1,6 @@ { - sysLib, + writeShellApplication, + # Dependencies git, nixos-rebuild, sudo, @@ -10,12 +11,11 @@ gnused, systemd, }: -sysLib.writeShellScript { - name = "update-sys"; - src = ./update-sys.sh; - generateCompletions = true; - keepPath = false; - dependencies = [ +writeShellApplication { + name = "fupdate-sys"; + text = builtins.readFile ./fupdate-sys.sh; + inheritPath = false; + runtimeInputs = [ git nixos-rebuild sudo diff --git a/pkgs/by-name/fu/fupdate/.envrc b/pkgs/by-name/fu/fupdate/.envrc new file mode 100644 index 00000000..fdd3e9d8 --- /dev/null +++ b/pkgs/by-name/fu/fupdate/.envrc @@ -0,0 +1,3 @@ +#!/usr/bin/env sh + +use flake diff --git a/pkgs/by-name/fu/fupdate/.gitignore b/pkgs/by-name/fu/fupdate/.gitignore new file mode 100644 index 00000000..2d5df85d --- /dev/null +++ b/pkgs/by-name/fu/fupdate/.gitignore @@ -0,0 +1,2 @@ +/target +.direnv diff --git a/pkgs/by-name/fu/fupdate/Cargo.lock b/pkgs/by-name/fu/fupdate/Cargo.lock new file mode 100644 index 00000000..0fe25d12 --- /dev/null +++ b/pkgs/by-name/fu/fupdate/Cargo.lock @@ -0,0 +1,301 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "anstream" +version = "0.6.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8acc5369981196006228e28809f761875c0327210a891e941f4c683b3a99529b" +dependencies = [ + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "is_terminal_polyfill", + "utf8parse", +] + +[[package]] +name = "anstyle" +version = "1.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55cc3b69f167a1ef2e161439aa98aed94e6028e5f9a59be9a6ffb47aef1651f9" + +[[package]] +name = "anstyle-parse" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b2d16507662817a6a20a9ea92df6652ee4f94f914589377d69f3b21bc5798a9" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "79947af37f4177cfead1110013d678905c37501914fba0efea834c3fe9a8d60c" +dependencies = [ + "windows-sys", +] + +[[package]] +name = "anstyle-wincon" +version = "3.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca3534e77181a9cc07539ad51f2141fe32f6c3ffd4df76db8ad92346b003ae4e" +dependencies = [ + "anstyle", + "once_cell", + "windows-sys", +] + +[[package]] +name = "anyhow" +version = "1.0.98" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e16d2d3311acee920a9eb8d33b8cbc1787ce4a264e85f964c2404b969bdcd487" + +[[package]] +name = "clap" +version = "4.5.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2df961d8c8a0d08aa9945718ccf584145eee3f3aa06cddbeac12933781102e04" +dependencies = [ + "clap_builder", + "clap_derive", +] + +[[package]] +name = "clap_builder" +version = "4.5.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "132dbda40fb6753878316a489d5a1242a8ef2f0d9e47ba01c951ea8aa7d013a5" +dependencies = [ + "anstream", + "anstyle", + "clap_lex", + "strsim", +] + +[[package]] +name = "clap_complete" +version = "4.5.47" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c06f5378ea264ad4f82bbc826628b5aad714a75abf6ece087e923010eb937fb6" +dependencies = [ + "clap", + "clap_lex", + "is_executable", + "shlex", +] + +[[package]] +name = "clap_derive" +version = "4.5.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09176aae279615badda0765c0c0b3f6ed53f4709118af73cf4655d85d1530cd7" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "clap_lex" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f46ad14479a25103f283c0f10005961cf086d8dc42205bb44c46ac563475dca6" + +[[package]] +name = "colorchoice" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b63caa9aa9397e2d9480a9b13673856c78d8ac123288526c37d7839f2a86990" + +[[package]] +name = "fupdate" +version = "0.1.0" +dependencies = [ + "anyhow", + "clap", + "clap_complete", +] + +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + +[[package]] +name = "is_executable" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4a1b5bad6f9072935961dfbf1cced2f3d129963d091b6f69f007fe04e758ae2" +dependencies = [ + "winapi", +] + +[[package]] +name = "is_terminal_polyfill" +version = "1.70.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" + +[[package]] +name = "once_cell" +version = "1.21.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" + +[[package]] +name = "proc-macro2" +version = "1.0.94" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a31971752e70b8b2686d7e46ec17fb38dad4051d94024c88df49b667caea9c84" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + +[[package]] +name = "strsim" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" + +[[package]] +name = "syn" +version = "2.0.100" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b09a44accad81e1ba1cd74a32461ba89dee89095ba17b32f5d03683b1b1fc2a0" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "unicode-ident" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512" + +[[package]] +name = "utf8parse" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "windows-sys" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_gnullvm", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" diff --git a/pkgs/by-name/fu/fupdate/Cargo.toml b/pkgs/by-name/fu/fupdate/Cargo.toml new file mode 100644 index 00000000..20aab801 --- /dev/null +++ b/pkgs/by-name/fu/fupdate/Cargo.toml @@ -0,0 +1,71 @@ +[package] +name = "fupdate" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +anyhow = "1.0.98" +clap = { version = "4.5.36", features = ["derive"] } +clap_complete = { version = "4.5.47", features = ["unstable-dynamic"] } + +[profile.release] +lto = true +codegen-units = 1 +panic = "abort" +split-debuginfo = "off" + +[lints.rust] +# rustc lint groups https://doc.rust-lang.org/rustc/lints/groups.html +warnings = "warn" +future_incompatible = { level = "warn", priority = -1 } +let_underscore = { level = "warn", priority = -1 } +nonstandard_style = { level = "warn", priority = -1 } +rust_2018_compatibility = { level = "warn", priority = -1 } +rust_2018_idioms = { level = "warn", priority = -1 } +rust_2021_compatibility = { level = "warn", priority = -1 } +unused = { level = "warn", priority = -1 } +# rustc allowed-by-default lints https://doc.rust-lang.org/rustc/lints/listing/allowed-by-default.html +# missing_docs = "warn" +macro_use_extern_crate = "warn" +meta_variable_misuse = "warn" +missing_abi = "warn" +missing_copy_implementations = "warn" +missing_debug_implementations = "warn" +non_ascii_idents = "warn" +noop_method_call = "warn" +single_use_lifetimes = "warn" +trivial_casts = "warn" +trivial_numeric_casts = "warn" +unreachable_pub = "warn" +unsafe_op_in_unsafe_fn = "warn" +unused_crate_dependencies = "warn" +unused_import_braces = "warn" +unused_lifetimes = "warn" +unused_qualifications = "warn" +variant_size_differences = "warn" + +[lints.rustdoc] +# rustdoc lints https://doc.rust-lang.org/rustdoc/lints.html +broken_intra_doc_links = "warn" +private_intra_doc_links = "warn" +missing_crate_level_docs = "warn" +private_doc_tests = "warn" +invalid_codeblock_attributes = "warn" +invalid_rust_codeblocks = "warn" +bare_urls = "warn" + +[lints.clippy] +# clippy allowed by default +dbg_macro = "warn" +# clippy categories https://doc.rust-lang.org/clippy/ +all = { level = "warn", priority = -1 } +correctness = { level = "warn", priority = -1 } +suspicious = { level = "warn", priority = -1 } +style = { level = "warn", priority = -1 } +complexity = { level = "warn", priority = -1 } +perf = { level = "warn", priority = -1 } +pedantic = { level = "warn", priority = -1 } +missing_panics_doc = "allow" +missing_errors_doc = "allow" diff --git a/pkgs/by-name/fu/fupdate/flake.lock b/pkgs/by-name/fu/fupdate/flake.lock new file mode 100644 index 00000000..d5cbe443 --- /dev/null +++ b/pkgs/by-name/fu/fupdate/flake.lock @@ -0,0 +1,27 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1744536153, + "narHash": "sha256-awS2zRgF4uTwrOKwwiJcByDzDOdo3Q1rPZbiHQg/N38=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "18dd725c29603f582cf1900e0d25f9f1063dbf11", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/pkgs/by-name/fu/fupdate/flake.nix b/pkgs/by-name/fu/fupdate/flake.nix new file mode 100644 index 00000000..4777c1e5 --- /dev/null +++ b/pkgs/by-name/fu/fupdate/flake.nix @@ -0,0 +1,25 @@ +{ + description = "This is a Nix flake update manager."; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + }; + + outputs = {nixpkgs, ...}: let + system = "x86_64-linux"; + pkgs = nixpkgs.legacyPackages."${system}"; + in { + devShells."${system}".default = pkgs.mkShell { + packages = with pkgs; [ + cargo + clippy + rustc + rustfmt + + cargo-edit + ]; + }; + }; +} +# vim: ts=2 + diff --git a/pkgs/by-name/fu/fupdate/fupdate.1.md b/pkgs/by-name/fu/fupdate/fupdate.1.md deleted file mode 100644 index 710e8fb7..00000000 --- a/pkgs/by-name/fu/fupdate/fupdate.1.md +++ /dev/null @@ -1,70 +0,0 @@ -% FUPDATE(1) fupdate 1.0.0 -% Soispha -% May 2023 - -# NAME - -fupdate - updates your flake, while checking for common mistakes - -# SYNOPSIS - -**fupdate** list of \[*flake*|*\<some word>*|*--help*|*-h*\] - -# DESCRIPTION - -Argument can be stacked, this makes it possible to specify multiple targets to be updated in succession. See the Examples section for further details. - -No argument or *flake* -: **fupdate**, when executed without arguments or with *flake*, will update your *flake.lock*, check for duplicate flake inputs, i.e., an input has an input declared, which you have also declared as input, and will run a script called *update.sh*, if you allow it. -The allowance for the script is asked, when you run **fupdate** and the found script is not yet allowed. Furthermore, the allowance is based on the concrete sha256 hash of the script, so any changes will require another allowance. - -**\<some word>** as argument -: If the executable **update-\<some word>** is reachable thought the PATH variable, than this is run. Otherwise, the program will exit. - -# OPTIONS - -**--help**, **-h** -: Displays a help message and exit. - -**--version**, **-v** -: Displays the software version and exit. - -# EXAMPLES - -**fupdate** or **fupdate flake** -: Updates your *flake.lock*. See the Description section for further details. - -**fupdate sys** -: Run the executable **update-sys**, if it exists. See the Description section for further details. - -**fupdate flake sys docs** -: First updates your flake, then, if the command succeeded, runs **update-sys**, afterweich **update-docs** is run. - -# FILES - -*update.sh* -: This is supposed to be a shell script located in your flake base directory, i.e., the directory which contains both a *flake.nix* and a *flake.lock* file. - -*~/.local/share/flake-update/* -: **fupdate** will store the hashes to the allowed *update.sh* files here. - -# BUGS - -Report bugs to <https://codeberg.org/soispha/flake_update/issues>. - -# COPYRIGHT - -Copyright (C) 2023 Soispha - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see <https://www.gnu.org/licenses/>. diff --git a/pkgs/by-name/fu/fupdate/fupdate.sh b/pkgs/by-name/fu/fupdate/fupdate.sh deleted file mode 100755 index 4322610a..00000000 --- a/pkgs/by-name/fu/fupdate/fupdate.sh +++ /dev/null @@ -1,197 +0,0 @@ -#! /usr/bin/env dash - -# shellcheck source=/dev/null -SHELL_LIBRARY_VERSION="2.1.2" . %SHELL_LIBRARY_PATH - -UPDATE_SCRIPT_NAME="update.sh" -CONFIG_DIRECTORY_PATH="$HOME/.local/share/flake-update" - -# Both are used in version() -# shellcheck disable=SC2034 -AUTHORS="Soispha" -# shellcheck disable=SC2034 -YEARS="2023" - -UPDATE_SCRIPT_NOT_WANTED=false - -# Searches upward for a `UPDATE_SCRIPT_NAME` script -# Returns a path to the script if it exists, otherwise nothing is returned -check_for_update_script() { - dirname="$(search_upward_files "$UPDATE_SCRIPT_NAME")" - if [ "$dirname" ]; then - printf "%s/%s" "$dirname" "$UPDATE_SCRIPT_NAME" - fi -} - -# Checks if a given path to the update script is allowed. -# Takes the path as input -# Return 0, if allowed, 1 if not. -check_for_allowed_update_script() { - update_script="$1" - config_path="${CONFIG_DIRECTORY_PATH}${update_script}" - update_script_hash="$(sha256sum "$update_script")" - if [ -f "$config_path" ]; then - if [ "$(cat "$config_path")" = "$update_script_hash" ]; then - dbg "Recorded hash matches" - return 0 - else - dbg "Recorded hash \'$(cat "$config_path")\' does not match real hash \'$update_script_hash\', assuming not allowed" - return 1 - fi - else - dbg "Path \'$config_path\' does not exist, assuming not allowed" - return 1 - fi -} - -# Asks the user if they want to allow a given script. -# Takes the path as input -ask_to_allow_update_script() { - update_script="$1" - config_path="${CONFIG_DIRECTORY_PATH}${update_script}" - update_script_hash="$(sha256sum "$update_script")" - println "\033[2J" # clear the screen - cat "$update_script" - readp "Do you want to allow this script?[N/y]: " allow - # shellcheck disable=SC2154 - dbg "allow is: $allow" - case "$allow" in - [yY]) - dbg "allowed script" - dbg "storing contents in: $config_path" - mkdir --parents "$(dirname "$config_path")" - print "$update_script_hash" >"$config_path" - ;; - *) - UPDATE_SCRIPT_NOT_ALLOWED=true - ;; - esac -} - -# Runs the provided script and continues to update the nix flake -# Takes the path to the script and the directory to the flake as arguments -# If the path to the update script is empty, it will be ignored -update() { - update_script="$1" - flake_base_dir="$2" - shift 2 - dbg "Provided following args to update script: '$*'" - - cd "$flake_base_dir" || die "Provided dir \'$flake_base_dir\' can not be accessed" - dbg "changed directory to: $flake_base_dir" - - nix flake update - - if ! [ "$update_script" = "" ] && ! [ "$UPDATE_SCRIPT_NOT_WANTED" = "true" ]; then - "$update_script" "$@" - fi - - if grep '[^0-9]_[0-9]' flake.lock >/dev/null; then - batgrep '[^0-9]_[0-9]' flake.lock - die "Your flake.nix contains duplicate inputs!" - fi -} - -help() { - cat <<EOF -This is a Nix flake update manager. - -USAGE: - $NAME [--help | --version] [flake [--no-script] | <some other command>] - -OPTIONS: - --help | -h - Display this help and exit. - - --version | -v - Display version and copyright information and exit. - - --no-script - Avoid running the 'update.sh' script -COMMANDS: - flake - update the flake project - - <some other command> - runs a executable called "update-<some other command>", if it exists -EOF -} - -main() { - if ! [ "$UPDATE_SCRIPT_NOT_ALLOWED" = true ]; then - update_script="$(check_for_update_script)" - flake_base_dir="$(search_flake_base_dir)" # Assume, that the update script is in the base dir - dbg "update_script is: $update_script" - dbg "flake_base_dir is: $flake_base_dir" - - if [ "$update_script" = "" ]; then - update "" "$flake_base_dir" "$@" - elif check_for_allowed_update_script "$update_script" && ! [ "$update_script" = "" ]; then - update "$update_script" "$flake_base_dir" "$@" - else - ask_to_allow_update_script "$update_script" - main "$@" - fi - fi -} - -if [ "$#" -eq 0 ]; then - main - exit 0 -fi - -for input in "$@"; do - case "$input" in - "--help" | "-h") - help - exit 0 - ;; - "--version" | "-v") - version - exit 0 - ;; - "--no-script" | "-n") - UPDATE_SCRIPT_NOT_WANTED=true - ;; - "--") - end_of_cli_options=true - - # Stop processing args after that marker. - break - ;; - esac - [ "$end_of_cli_options" = "true" ] && break -done - -case "$1" in -"flake") - shift 1 - - # Filter out fupdate specific flags - while [ "$1" != "--" ]; do - # FIXME: This check allows to add a flag multiple times, but this should probably - # not be allowed <2024-03-29> - case "$1" in - "--no-script" | "-n") - shift 1 - ;; - *) - break - ;; - esac - done - - [ "$1" = "--" ] && shift 1 - main "$@" - ;; -*) - command="$1" - shift 1 - [ "$1" = "--" ] && shift 1 - if which update-"$command" >/dev/null 2>&1; then - update-"$command" "$@" - else - die "command \"update-$command\" is not executable, or does not exist" - fi - ;; -esac diff --git a/pkgs/by-name/fu/fupdate/package.nix b/pkgs/by-name/fu/fupdate/package.nix index 66372add..d33138e3 100644 --- a/pkgs/by-name/fu/fupdate/package.nix +++ b/pkgs/by-name/fu/fupdate/package.nix @@ -1,29 +1,32 @@ { - sysLib, - dash, - lix, - gnugrep, - fd, - coreutils, - bat, # used by batgrep - bat-extras, - gnused, # required by batgrep - git, # needed to fetch through git + rustPlatform, + installShellFiles, + makeWrapper, }: -sysLib.writeShellScript { - name = "fupdate"; - src = ./fupdate.sh; - generateCompletions = true; - keepPath = true; - dependencies = [ - dash - lix - gnugrep - fd - coreutils - bat # used by batgrep - bat-extras.batgrep - gnused # required by batgrep - git # needed to fetch through git +rustPlatform.buildRustPackage (finalAttrs: { + pname = "fupdate"; + version = "0.1.0"; + + src = ./.; + cargoLock = { + lockFile = ./Cargo.lock; + }; + + buildInputs = []; + + nativeBuildInputs = [ + installShellFiles + makeWrapper ]; -} + + postInstall = '' + installShellCompletion --cmd fupdate \ + --bash <(COMPLETE=bash $out/bin/fupdate) \ + --fish <(COMPLETE=fish $out/bin/fupdate) \ + --zsh <(COMPLETE=zsh $out/bin/fupdate) + ''; + + meta = { + mainProgram = "fupdate"; + }; +}) diff --git a/pkgs/by-name/fu/fupdate/src/cli.rs b/pkgs/by-name/fu/fupdate/src/cli.rs new file mode 100644 index 00000000..6f970ac4 --- /dev/null +++ b/pkgs/by-name/fu/fupdate/src/cli.rs @@ -0,0 +1,46 @@ +use std::{env, ffi::OsStr, fs::read_dir}; + +use clap::Parser; +use clap_complete::{engine::ArgValueCompleter, CompletionCandidate}; + +/// This is a Nix flake update manager. +#[derive(Parser, Debug)] +#[command(author, version, about)] +pub struct CliArgs { + /// The command to execute. + #[arg(add = ArgValueCompleter::new(get_fupdate_commands))] + pub command: Vec<String>, +} + +fn get_fupdate_commands(current: &OsStr) -> Vec<CompletionCandidate> { + let mut output = vec![]; + let path = env::var("PATH").unwrap_or_default(); + + let Some(current) = current.to_str() else { + return output; + }; + + for directory in path.split(':') { + if let Ok(mut read) = read_dir(directory) { + for value in read.by_ref().flatten() { + let file_name = value.file_name(); + let name = file_name.to_string_lossy(); + let Some(stripped) = name.strip_prefix("fupdate-") else { + continue; + }; + + if stripped.starts_with(current) { + output.push(CompletionCandidate::new( + value + .file_name() + .to_string_lossy() + .strip_prefix("fupdate-") + .expect("Exists"), + )); + } + } + } + } + + output +} diff --git a/pkgs/by-name/fu/fupdate/src/main.rs b/pkgs/by-name/fu/fupdate/src/main.rs new file mode 100644 index 00000000..759f65ec --- /dev/null +++ b/pkgs/by-name/fu/fupdate/src/main.rs @@ -0,0 +1,46 @@ +use std::process::Command; + +use anyhow::{bail, Context, Result}; +use clap::{CommandFactory, Parser}; + +pub mod cli; + +use crate::cli::CliArgs; + +fn main() -> Result<(), anyhow::Error> { + clap_complete::CompleteEnv::with_factory(CliArgs::command).complete(); + + let args = CliArgs::parse(); + + let command = args.command.first().map_or("flake", String::as_str); + + { + let args = if args.command.len() > 1 { + &args.command[1..] + } else { + &[] + }; + + // println!("Running: `fupdate-{command} {}`", args.join(" ")); + + let mut child = Command::new(format!("fupdate-{command}")) + .args(args) + .spawn() + .with_context(|| format!("Failed to spawn `fupdate-{command}`"))?; + + if !child + .wait() + .with_context(|| format!("Failed to wait for `fupdate-{command}` to finish"))? + .success() + { + bail!("Command `fupdate-{command} {}` failed!", args.join(" ")); + } + } + + Ok(()) +} + +#[test] +fn verify_cli() { + CliArgs::command().debug_assert(); +} diff --git a/pkgs/by-name/fu/fupdate/update.sh b/pkgs/by-name/fu/fupdate/update.sh new file mode 100755 index 00000000..9268caf2 --- /dev/null +++ b/pkgs/by-name/fu/fupdate/update.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +cargo update && cargo upgrade diff --git a/pkgs/by-name/ge/generate_moz_extension/Cargo.lock b/pkgs/by-name/ge/generate_moz_extension/Cargo.lock index 10970fa6..8df79fc2 100644 --- a/pkgs/by-name/ge/generate_moz_extension/Cargo.lock +++ b/pkgs/by-name/ge/generate_moz_extension/Cargo.lock @@ -19,9 +19,9 @@ checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627" [[package]] name = "anyhow" -version = "1.0.97" +version = "1.0.98" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcfed56ad506cb2c684a14971b8861fdc3baaaae314b9e5f9bb532cbe3ba7a4f" +checksum = "e16d2d3311acee920a9eb8d33b8cbc1787ce4a264e85f964c2404b969bdcd487" [[package]] name = "atomic-waker" @@ -76,9 +76,9 @@ checksum = "d71b6127be86fdcfddb610f7182ac57211d4b18a3e9c82eb2d17662f2227ad6a" [[package]] name = "cc" -version = "1.2.17" +version = "1.2.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fcb57c740ae1daf453ae85f16e37396f672b039e00d9d866e07ddb24e328e3a" +checksum = "8e3a13707ac958681c13b39b458c073d0d9bc8a22cb1b2f4c8e55eb72c13f362" dependencies = [ "shlex", ] @@ -133,9 +133,9 @@ checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" [[package]] name = "errno" -version = "0.3.10" +version = "0.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33d852cb9b869c2a9b3df2f71a3074817f01e1844f839a144f5fcef059a4eb5d" +checksum = "976dd42dc7e85965fe702eb8164f21f450704bdde31faefd6471dba214cb594e" dependencies = [ "libc", "windows-sys 0.59.0", @@ -427,9 +427,9 @@ dependencies = [ [[package]] name = "hyper-util" -version = "0.1.10" +version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df2dcfbe0677734ab2f3ffa7fa7bfd4706bfdc1ef393f2ee30184aed67e631b4" +checksum = "497bbc33a26fdd4af9ed9c70d63f61cf56a938375fbb32df34db9b1cd6d643f2" dependencies = [ "bytes", "futures-channel", @@ -437,6 +437,7 @@ dependencies = [ "http", "http-body", "hyper", + "libc", "pin-project-lite", "socket2", "tokio", @@ -585,9 +586,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.8.0" +version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3954d50fe15b02142bf25d3b8bdadb634ec3948f103d04ffe3031bc8fe9d7058" +checksum = "cea70ddb795996207ad57735b50c5982d8844f38ba9ee5f1aedcfb708a2aa11e" dependencies = [ "equivalent", "hashbrown", @@ -623,9 +624,9 @@ checksum = "c19937216e9d3aa9956d9bb8dfc0b0c8beb6058fc4f7a4dc4d850edf86a237d6" [[package]] name = "linux-raw-sys" -version = "0.9.3" +version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe7db12097d22ec582439daf8618b8fdd1a7bef6270e9af3b1ebcd30893cf413" +checksum = "cd945864f07fe9f5371a27ad7b52a172b4b499999f1d97574c9fa68373937e12" [[package]] name = "litemap" @@ -653,9 +654,9 @@ checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" [[package]] name = "miniz_oxide" -version = "0.8.5" +version = "0.8.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e3e04debbb59698c15bacbb6d93584a8c0ca9cc3213cb423d31f760d8843ce5" +checksum = "3be647b768db090acb35d5ec5db2b0e1f1de11133ca123b9eacf5137868f892a" dependencies = [ "adler2", ] @@ -705,9 +706,9 @@ checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" [[package]] name = "openssl" -version = "0.10.71" +version = "0.10.72" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e14130c6a98cd258fdcb0fb6d744152343ff729cbfcb28c656a9d12b999fbcd" +checksum = "fedfea7d58a1f73118430a55da6a286e7b044961736ce96a16a17068ea25e5da" dependencies = [ "bitflags", "cfg-if", @@ -737,9 +738,9 @@ checksum = "d05e27ee213611ffe7d6348b942e8f942b37114c00cc03cec254295a4a17852e" [[package]] name = "openssl-sys" -version = "0.9.106" +version = "0.9.107" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8bb61ea9811cc39e3c2069f40b8b8e2e70d8569b361f879786cc7ed48b777cdd" +checksum = "8288979acd84749c744a9014b4382d42b8f7b2592847b5afb2ed29e5d16ede07" dependencies = [ "cc", "libc", @@ -861,9 +862,9 @@ checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" [[package]] name = "rustix" -version = "1.0.3" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e56a18552996ac8d29ecc3b190b4fdbb2d91ca4ec396de7bbffaf43f3d637e96" +checksum = "d97817398dd4bb2e6da002002db259209759911da105da92bec29ccb12cf58bf" dependencies = [ "bitflags", "errno", @@ -874,9 +875,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.23.25" +version = "0.23.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "822ee9188ac4ec04a2f0531e55d035fb2de73f18b41a63c70c2712503b6fb13c" +checksum = "df51b5869f3a441595eac5e8ff14d486ff285f7b8c0df8770e49c3b56351f0f0" dependencies = [ "once_cell", "rustls-pki-types", @@ -1016,15 +1017,15 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.14.0" +version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fcf8323ef1faaee30a44a340193b1ac6814fd9b7b4e88e9d4519a3e4abe1cfd" +checksum = "8917285742e9f3e1683f0a9c4e6b57960b7314d0b08d30d1ecd426713ee2eee9" [[package]] name = "socket2" -version = "0.5.8" +version = "0.5.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c970269d99b64e60ec3bd6ad27270092a5394c4e309314b18ae3fe575695fbe8" +checksum = "4f5fd57c80058a56cf5c777ab8a126398ece8e442983605d280a44ce79d0edef" dependencies = [ "libc", "windows-sys 0.52.0", @@ -1119,9 +1120,9 @@ dependencies = [ [[package]] name = "tokio" -version = "1.44.1" +version = "1.44.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f382da615b842244d4b8738c82ed1275e6c5dd90c459a30941cd07080b06c91a" +checksum = "e6b88822cbe49de4185e3a4cbf8321dd487cf5fe0c5c65695fef6346371e9c48" dependencies = [ "backtrace", "bytes", diff --git a/pkgs/by-name/ge/generate_moz_extension/Cargo.toml b/pkgs/by-name/ge/generate_moz_extension/Cargo.toml index 1b3ff4f0..8a07d055 100644 --- a/pkgs/by-name/ge/generate_moz_extension/Cargo.toml +++ b/pkgs/by-name/ge/generate_moz_extension/Cargo.toml @@ -11,4 +11,4 @@ futures = "0.3.31" reqwest = "0.12.15" serde = { version = "1.0.219", features = ["derive"] } serde_json = "1.0.140" -tokio = { version = "1.44.1", features = ["macros", "rt-multi-thread"] } +tokio = { version = "1.44.2", features = ["macros", "rt-multi-thread"] } diff --git a/pkgs/by-name/ge/generate_moz_extension/flake.lock b/pkgs/by-name/ge/generate_moz_extension/flake.lock index 9d72fb5b..90152156 100644 --- a/pkgs/by-name/ge/generate_moz_extension/flake.lock +++ b/pkgs/by-name/ge/generate_moz_extension/flake.lock @@ -2,11 +2,11 @@ "nodes": { "crane": { "locked": { - "lastModified": 1742394900, - "narHash": "sha256-vVOAp9ahvnU+fQoKd4SEXB2JG2wbENkpqcwlkIXgUC0=", + "lastModified": 1744386647, + "narHash": "sha256-DXwQEJllxpYeVOiSlBhQuGjfvkoGHTtILLYO2FvcyzQ=", "owner": "ipetkov", "repo": "crane", - "rev": "70947c1908108c0c551ddfd73d4f750ff2ea67cd", + "rev": "d02c1cdd7ec539699aa44e6ff912e15535969803", "type": "github" }, "original": { @@ -35,11 +35,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1743076231, - "narHash": "sha256-yQugdVfi316qUfqzN8JMaA2vixl+45GxNm4oUfXlbgw=", + "lastModified": 1744536153, + "narHash": "sha256-awS2zRgF4uTwrOKwwiJcByDzDOdo3Q1rPZbiHQg/N38=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "6c5963357f3c1c840201eda129a99d455074db04", + "rev": "18dd725c29603f582cf1900e0d25f9f1063dbf11", "type": "github" }, "original": { @@ -64,11 +64,11 @@ ] }, "locked": { - "lastModified": 1743215516, - "narHash": "sha256-52qbrkG65U1hyrQWltgHTgH4nm0SJL+9TWv2UDCEPNI=", + "lastModified": 1744599145, + "narHash": "sha256-yzaDPkJwZdUtRj/dzdOeB74yryWzpngYaD7BedqFKk8=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "524463199fdee49338006b049bc376b965a2cfed", + "rev": "fd6795d3d28f956de01a0458b6fa7baae5c793b4", "type": "github" }, "original": { diff --git a/pkgs/by-name/gi/git-cm/git-cm.sh b/pkgs/by-name/gi/git-cm/git-cm.sh index 2204e4d6..1eb46730 100755 --- a/pkgs/by-name/gi/git-cm/git-cm.sh +++ b/pkgs/by-name/gi/git-cm/git-cm.sh @@ -1,8 +1,5 @@ #!/usr/bin/env dash -# shellcheck source=/dev/null -SHELL_LIBRARY_VERSION="2.1.2" . %SHELL_LIBRARY_PATH - ROOT="$(git rev-parse --show-toplevel)" # Take first line from previous commit @@ -13,6 +10,6 @@ else fi sed '1d' "$(git config commit.template)" >>"$ROOT/.git/COMMIT_TEMPLATE" -git commit --template "$ROOT/.git/COMMIT_TEMPLATE" --verbose "$@" +git commit --template "$ROOT/.git/COMMIT_TEMPLATE" "$@" # vim: ft=sh diff --git a/pkgs/by-name/gi/git-cm/package.nix b/pkgs/by-name/gi/git-cm/package.nix index a9949783..576df2f7 100644 --- a/pkgs/by-name/gi/git-cm/package.nix +++ b/pkgs/by-name/gi/git-cm/package.nix @@ -1,13 +1,17 @@ { - sysLib, + writeShellApplication, + # Dependencies git, gnused, }: -sysLib.writeShellScript { +writeShellApplication { name = "git-cm"; - src = ./git-cm.sh; - keepPath = true; - dependencies = [ + text = builtins.readFile ./git-cm.sh; + + # We need access to the $EDITOR + inheritPath = true; + + runtimeInputs = [ git gnused ]; diff --git a/pkgs/by-name/gi/git-edit-index/git-edit-index.sh b/pkgs/by-name/gi/git-edit-index/git-edit-index.sh index e73dc53c..94a8d4a4 100755 --- a/pkgs/by-name/gi/git-edit-index/git-edit-index.sh +++ b/pkgs/by-name/gi/git-edit-index/git-edit-index.sh @@ -1,19 +1,10 @@ #!/usr/bin/env dash -# shellcheck source=/dev/null -SHELL_LIBRARY_VERSION="2.1.2" . %SHELL_LIBRARY_PATH +NAME="git-edit-index" -# needed for help() and version -# shellcheck disable=2034 -AUTHORS="Soispha" -# shellcheck disable=2034 -YEARS="2024" -# shellcheck disable=2034 -VERSION="1.0.0" - -# NAME is from the wrapper -# shellcheck disable=SC2269 -NAME="$NAME" +warn() { + echo "WARNING: $1" +} help() { cat <<EOF @@ -55,23 +46,24 @@ materialize_file() { } edit() { - files_to_add="$(mktmp)" - realpath --relative-to=. "$@" >"$files_to_add" + files_to_add="$(mktemp)" + cleanup() { + rm "$files_to_add" + } + trap cleanup EXIT - index_files="$(mktmp)" - git diff --name-only --cached --diff-filter=AM >"$index_files" + realpath --relative-to=. "$@" >"$files_to_add" - while read -r file; do - if grep -q "$file" "$files_to_add"; then - sed -i "s|$file||" "$files_to_add" - materialize_file "$file" + git diff --name-only --cached --diff-filter=AM | while read -r index_file; do + if grep -q "$index_file" "$files_to_add"; then + sed -i "s|$index_file||" "$files_to_add" + materialize_file "$index_file" fi - done <"$index_files" + done - files_to_check="$(mktmp)" - clean "$files_to_add" >"$files_to_check" - if [ "$(wc -l <"$files_to_check")" -gt 0 ]; then - warn "Could not edit every file:" + unedided_files="$(sed '/^\s*$/d' "$files_to_add" | wc -l)" + if [ "$unedided_files" -gt 0 ]; then + warn "Failed to edit $unedided_files file(s):" cat "$files_to_add" fi } @@ -82,10 +74,6 @@ for arg in "$@"; do help exit 0 ;; - "--version" | "-v") - version - exit 0 - ;; "--") end_of_cli_options=true ;; diff --git a/pkgs/by-name/gi/git-edit-index/package.nix b/pkgs/by-name/gi/git-edit-index/package.nix index 8ac085bf..d7bba6af 100644 --- a/pkgs/by-name/gi/git-edit-index/package.nix +++ b/pkgs/by-name/gi/git-edit-index/package.nix @@ -1,19 +1,20 @@ { - sysLib, + writeShellApplication, + # Dependencies + coreutils, git, gnused, }: -sysLib.writeShellScript { +writeShellApplication { name = "git-edit-index"; - src = ./git-edit-index.sh; - generateCompletions = true; + text = builtins.readFile ./git-edit-index.sh; # `git-edit-index` starts neovim, wich might want to shell out from - keepPath = true; + inheritPath = true; - dependencies = [ + runtimeInputs = [ + coreutils git gnused - # $EDITOR ]; } diff --git a/pkgs/by-name/hi/hibernate/hibernate.sh b/pkgs/by-name/hi/hibernate/hibernate.sh index 30868fd1..59b08ec0 100755 --- a/pkgs/by-name/hi/hibernate/hibernate.sh +++ b/pkgs/by-name/hi/hibernate/hibernate.sh @@ -1,7 +1,6 @@ #!/usr/bin/env dash -# shellcheck source=/dev/null -SHELL_LIBRARY_VERSION="2.1.2" . %SHELL_LIBRARY_PATH +# TODO(@bpeetz): This functionality could be moved to `tskm`. <2025-04-14> context="$(task _get rc.context)" [ "$context" ] && task context none diff --git a/pkgs/by-name/hi/hibernate/package.nix b/pkgs/by-name/hi/hibernate/package.nix index 24754f09..f0fb4e96 100644 --- a/pkgs/by-name/hi/hibernate/package.nix +++ b/pkgs/by-name/hi/hibernate/package.nix @@ -1,15 +1,14 @@ { - sysLib, + writeShellApplication, systemd, - taskwarrior, + taskwarrior3, }: -sysLib.writeShellScript { +writeShellApplication { name = "hibernate"; - src = ./hibernate.sh; - generateCompletions = false; - keepPath = false; - dependencies = [ + text = builtins.readFile ./hibernate.sh; + inheritPath = false; + runtimeInputs = [ systemd - taskwarrior + taskwarrior3 ]; } diff --git a/pkgs/by-name/lf/lf-make-map/Cargo.lock b/pkgs/by-name/lf/lf-make-map/Cargo.lock index d68f7492..516a2da8 100644 --- a/pkgs/by-name/lf/lf-make-map/Cargo.lock +++ b/pkgs/by-name/lf/lf-make-map/Cargo.lock @@ -69,9 +69,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.97" +version = "1.0.98" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcfed56ad506cb2c684a14971b8861fdc3baaaae314b9e5f9bb532cbe3ba7a4f" +checksum = "e16d2d3311acee920a9eb8d33b8cbc1787ce4a264e85f964c2404b969bdcd487" [[package]] name = "autocfg" @@ -87,9 +87,9 @@ checksum = "1628fb46dfa0b37568d12e5edd512553eccf6a22a78e8bde00bb4aed84d5bdbf" [[package]] name = "cc" -version = "1.2.17" +version = "1.2.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fcb57c740ae1daf453ae85f16e37396f672b039e00d9d866e07ddb24e328e3a" +checksum = "8e3a13707ac958681c13b39b458c073d0d9bc8a22cb1b2f4c8e55eb72c13f362" dependencies = [ "shlex", ] @@ -116,9 +116,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.34" +version = "4.5.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e958897981290da2a852763fe9cdb89cd36977a5d729023127095fa94d95e2ff" +checksum = "2df961d8c8a0d08aa9945718ccf584145eee3f3aa06cddbeac12933781102e04" dependencies = [ "clap_builder", "clap_derive", @@ -126,9 +126,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.34" +version = "4.5.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83b0f35019843db2160b5bb19ae09b4e6411ac33fc6a712003c33e03090e2489" +checksum = "132dbda40fb6753878316a489d5a1242a8ef2f0d9e47ba01c951ea8aa7d013a5" dependencies = [ "anstream", "anstyle", @@ -180,9 +180,9 @@ checksum = "fbd780fe5cc30f81464441920d82ac8740e2e46b29a6fad543ddd075229ce37e" [[package]] name = "iana-time-zone" -version = "0.1.62" +version = "0.1.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2fd658b06e56721792c5df4475705b6cda790e9298d19d2f8af083457bcd127" +checksum = "b0c919e5debc312ad217002b8048a17b7d83f80703865bbfcfebb0458b0b27d8" dependencies = [ "android_system_properties", "core-foundation-sys", @@ -446,11 +446,37 @@ dependencies = [ [[package]] name = "windows-core" -version = "0.52.0" +version = "0.61.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" +checksum = "4763c1de310c86d75a878046489e2e5ba02c649d185f21c67d4cf8a56d098980" dependencies = [ - "windows-targets", + "windows-implement", + "windows-interface", + "windows-link", + "windows-result", + "windows-strings", +] + +[[package]] +name = "windows-implement" +version = "0.60.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a47fddd13af08290e67f4acabf4b459f647552718f683a7b415d290ac744a836" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "windows-interface" +version = "0.59.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd9211b69f8dcdfa817bfd14bf1c97c9188afa36f4750130fcdf3f400eca9fa8" +dependencies = [ + "proc-macro2", + "quote", + "syn", ] [[package]] @@ -460,6 +486,24 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "76840935b766e1b0a05c0066835fb9ec80071d4c09a16f6bd5f7e655e3c14c38" [[package]] +name = "windows-result" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c64fd11a4fd95df68efcfee5f44a294fe71b8bc6a91993e2791938abcc712252" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-strings" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a2ba9642430ee452d5a7aa78d72907ebe8cfda358e8cb7918a2050581322f97" +dependencies = [ + "windows-link", +] + +[[package]] name = "windows-sys" version = "0.59.0" source = "registry+https://github.com/rust-lang/crates.io-index" diff --git a/pkgs/by-name/lf/lf-make-map/Cargo.toml b/pkgs/by-name/lf/lf-make-map/Cargo.toml index d2427d73..4266ce0c 100644 --- a/pkgs/by-name/lf/lf-make-map/Cargo.toml +++ b/pkgs/by-name/lf/lf-make-map/Cargo.toml @@ -8,7 +8,7 @@ edition = "2021" [dependencies] anyhow = "1.0.97" -clap = { version = "4.5.34", features = ["derive", "env"] } +clap = { version = "4.5.35", features = ["derive", "env"] } log = "0.4.27" stderrlog = "0.6.0" walkdir = "2.5.0" diff --git a/pkgs/by-name/lf/lf-make-map/flake.lock b/pkgs/by-name/lf/lf-make-map/flake.lock index c9c523d9..2ed775c1 100644 --- a/pkgs/by-name/lf/lf-make-map/flake.lock +++ b/pkgs/by-name/lf/lf-make-map/flake.lock @@ -2,11 +2,11 @@ "nodes": { "crane": { "locked": { - "lastModified": 1742394900, - "narHash": "sha256-vVOAp9ahvnU+fQoKd4SEXB2JG2wbENkpqcwlkIXgUC0=", + "lastModified": 1744386647, + "narHash": "sha256-DXwQEJllxpYeVOiSlBhQuGjfvkoGHTtILLYO2FvcyzQ=", "owner": "ipetkov", "repo": "crane", - "rev": "70947c1908108c0c551ddfd73d4f750ff2ea67cd", + "rev": "d02c1cdd7ec539699aa44e6ff912e15535969803", "type": "github" }, "original": { @@ -53,11 +53,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1743076231, - "narHash": "sha256-yQugdVfi316qUfqzN8JMaA2vixl+45GxNm4oUfXlbgw=", + "lastModified": 1744536153, + "narHash": "sha256-awS2zRgF4uTwrOKwwiJcByDzDOdo3Q1rPZbiHQg/N38=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "6c5963357f3c1c840201eda129a99d455074db04", + "rev": "18dd725c29603f582cf1900e0d25f9f1063dbf11", "type": "github" }, "original": { @@ -85,11 +85,11 @@ ] }, "locked": { - "lastModified": 1743215516, - "narHash": "sha256-52qbrkG65U1hyrQWltgHTgH4nm0SJL+9TWv2UDCEPNI=", + "lastModified": 1744599145, + "narHash": "sha256-yzaDPkJwZdUtRj/dzdOeB74yryWzpngYaD7BedqFKk8=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "524463199fdee49338006b049bc376b965a2cfed", + "rev": "fd6795d3d28f956de01a0458b6fa7baae5c793b4", "type": "github" }, "original": { @@ -120,11 +120,11 @@ ] }, "locked": { - "lastModified": 1743081648, - "narHash": "sha256-WRAylyYptt6OX5eCEBWyTwOEqEtD6zt33rlUkr6u3cE=", + "lastModified": 1743748085, + "narHash": "sha256-uhjnlaVTWo5iD3LXics1rp9gaKgDRQj6660+gbUU3cE=", "owner": "numtide", "repo": "treefmt-nix", - "rev": "29a3d7b768c70addce17af0869f6e2bd8f5be4b7", + "rev": "815e4121d6a5d504c0f96e5be2dd7f871e4fd99d", "type": "github" }, "original": { diff --git a/pkgs/by-name/ll/ll/ll.sh b/pkgs/by-name/ll/ll/ll.sh index 73328e3e..3fb8d9aa 100755 --- a/pkgs/by-name/ll/ll/ll.sh +++ b/pkgs/by-name/ll/ll/ll.sh @@ -1,9 +1,10 @@ #!/usr/bin/env dash -# shellcheck source=/dev/null -SHELL_LIBRARY_VERSION="2.1.2" . %SHELL_LIBRARY_PATH - last_directory="$(mktemp)" +cleanup() { + rm "$last_directory" +} +trap cleanup EXIT command lf -last-dir-path="$last_directory" "$@" @@ -15,5 +16,4 @@ else die "$dir does not exist!" fi -rm "$last_directory" # vim: ft=sh diff --git a/pkgs/by-name/ll/ll/package.nix b/pkgs/by-name/ll/ll/package.nix index 4c13b40e..caca5b4e 100644 --- a/pkgs/by-name/ll/ll/package.nix +++ b/pkgs/by-name/ll/ll/package.nix @@ -1,9 +1,9 @@ -{sysLib}: -sysLib.writeShellScript { +{writeShellApplication}: +writeShellApplication { name = "ll"; - src = ./ll.sh; - generateCompletions = false; + text = builtins.readFile ./ll.sh; - # `ll` must be able to change the path of the running shell. - wrap = false; + # This is sourced in the shell + inheritPath = true; + bashOptions = []; } diff --git a/pkgs/by-name/lm/lm/lm.sh b/pkgs/by-name/lm/lm/lm.sh index d5fdca10..9c61f30f 100755 --- a/pkgs/by-name/lm/lm/lm.sh +++ b/pkgs/by-name/lm/lm/lm.sh @@ -1,7 +1,13 @@ #!/usr/bin/env dash -# shellcheck source=/dev/null -SHELL_LIBRARY_VERSION="2.1.2" . %SHELL_LIBRARY_PATH +die() { + echo "ERROR: $1" + exit 1 +} + +msg() { + echo "$1" +} if [ -f "$XDG_RUNTIME_DIR/ll/last_directory" ]; then last_dir="$(cat "$XDG_RUNTIME_DIR/ll/last_directory")" diff --git a/pkgs/by-name/lm/lm/package.nix b/pkgs/by-name/lm/lm/package.nix index ef417cd2..a80c473e 100644 --- a/pkgs/by-name/lm/lm/package.nix +++ b/pkgs/by-name/lm/lm/package.nix @@ -1,9 +1,9 @@ -{sysLib}: -sysLib.writeShellScript { +{writeShellApplication}: +writeShellApplication { name = "lm"; - src = ./lm.sh; - generateCompletions = false; + text = builtins.readFile ./lm.sh; - # `ll` must be able to change the path of the running shell. - wrap = false; + # This is sourced in the shell + inheritPath = true; + bashOptions = []; } diff --git a/pkgs/by-name/lo/lock/package.nix b/pkgs/by-name/lo/lock/package.nix index 1c857cd6..a59fbdd0 100644 --- a/pkgs/by-name/lo/lock/package.nix +++ b/pkgs/by-name/lo/lock/package.nix @@ -1,13 +1,13 @@ { writeShellApplication, - taskwarrior, + taskwarrior3, swaylock, }: writeShellApplication { name = "lock"; text = builtins.readFile ./lock.sh; runtimeInputs = [ - taskwarrior + taskwarrior3 swaylock ]; meta = { diff --git a/pkgs/by-name/mp/mpp-beetrm/mpp-beetrm.sh b/pkgs/by-name/mp/mpp-beetrm/mpp-beetrm.sh index 3209503c..5a94662b 100755 --- a/pkgs/by-name/mp/mpp-beetrm/mpp-beetrm.sh +++ b/pkgs/by-name/mp/mpp-beetrm/mpp-beetrm.sh @@ -1,8 +1,5 @@ #!/usr/bin/env dash -# shellcheck source=/dev/null -SHELL_LIBRARY_VERSION="2.1.2" . %SHELL_LIBRARY_PATH - beet remove --delete \ title:"$(mpc --format '%title%' current)" \ album:"$(mpc --format '%album%' current)" diff --git a/pkgs/by-name/mp/mpp-beetrm/package.nix b/pkgs/by-name/mp/mpp-beetrm/package.nix index 24b56606..425d05fd 100644 --- a/pkgs/by-name/mp/mpp-beetrm/package.nix +++ b/pkgs/by-name/mp/mpp-beetrm/package.nix @@ -1,15 +1,15 @@ { - sysLib, + writeShellApplication, + # Dependencies mpc, beets, }: -sysLib.writeShellScript { +writeShellApplication { name = "mpp-beetrm"; - src = ./mpp-beetrm.sh; - generateCompletions = false; - keepPath = false; + text = builtins.readFile ./mpp-beetrm.sh; + inheritPath = false; - dependencies = [ + runtimeInputs = [ mpc beets ]; diff --git a/pkgs/by-name/mp/mpp-lyrics/mpp-lyrics.sh b/pkgs/by-name/mp/mpp-lyrics/mpp-lyrics.sh index 004c67c7..178eb924 100755 --- a/pkgs/by-name/mp/mpp-lyrics/mpp-lyrics.sh +++ b/pkgs/by-name/mp/mpp-lyrics/mpp-lyrics.sh @@ -1,11 +1,11 @@ #!/usr/bin/env dash -# shellcheck source=/dev/null -SHELL_LIBRARY_VERSION="2.1.2" . %SHELL_LIBRARY_PATH +die() { + echo "Error: $1" + exit 1 +} -( - cd "%MPD_MUSIC_DIR" || die "No music dir!" - exiftool "$(mpc --format '%file%' current)" -json | jq '.[0].Lyrics' -r | less -) +cd "$XDG_MUSIC_DIR" || die "No music dir!" +exiftool "$(mpc --format '%file%' current)" -json | jq '.[0].Lyrics' --raw-output | less # vim: ft=sh diff --git a/pkgs/by-name/mp/mpp-lyrics/package.nix b/pkgs/by-name/mp/mpp-lyrics/package.nix index 76b590c7..23979c14 100644 --- a/pkgs/by-name/mp/mpp-lyrics/package.nix +++ b/pkgs/by-name/mp/mpp-lyrics/package.nix @@ -1,23 +1,18 @@ { - sysLib, + writeShellApplication, + # Dependencies exiftool, mpc, jq, less, locale, # dependency of less - mpd_music_dir ? "\${XDG_MUSIC_DIR}", }: -sysLib.writeShellScript { +writeShellApplication { name = "mpp-lyrics"; - src = ./mpp-lyrics.sh; - generateCompletions = false; - keepPath = false; + text = builtins.readFile ./mpp-lyrics.sh; + inheritPath = false; - replacementStrings = { - MPD_MUSIC_DIR = mpd_music_dir; - }; - - dependencies = [ + runtimeInputs = [ exiftool mpc jq diff --git a/pkgs/by-name/mp/mpp-searchadd/mpp-searchadd.sh b/pkgs/by-name/mp/mpp-searchadd/mpp-searchadd.sh index 3fe9a6b6..7195bd35 100755 --- a/pkgs/by-name/mp/mpp-searchadd/mpp-searchadd.sh +++ b/pkgs/by-name/mp/mpp-searchadd/mpp-searchadd.sh @@ -1,14 +1,8 @@ #!/usr/bin/env dash -# shellcheck source=/dev/null -SHELL_LIBRARY_VERSION="2.1.2" . %SHELL_LIBRARY_PATH - -tracks="$(mktmp)" -beet list "$@" --path >"$tracks" - -while read -r track; do +beet list "$@" --path | while read -r track; do mpc add "$track" -done <"$tracks" +done mpc playlist # vim: ft=sh diff --git a/pkgs/by-name/mp/mpp-searchadd/package.nix b/pkgs/by-name/mp/mpp-searchadd/package.nix index a98472d1..2f9db4ca 100644 --- a/pkgs/by-name/mp/mpp-searchadd/package.nix +++ b/pkgs/by-name/mp/mpp-searchadd/package.nix @@ -1,15 +1,15 @@ { - sysLib, + writeShellApplication, + # Dependencies. mpc, beets, }: -sysLib.writeShellScript { +writeShellApplication { name = "mpp-searchadd"; - src = ./mpp-searchadd.sh; - generateCompletions = false; - keepPath = false; + text = builtins.readFile ./mpp-searchadd.sh; + inheritPath = false; - dependencies = [ + runtimeInputs = [ mpc beets ]; diff --git a/pkgs/by-name/mp/mpp/mpp.sh b/pkgs/by-name/mp/mpp/mpp.sh index 538a56ee..7941df07 100755 --- a/pkgs/by-name/mp/mpp/mpp.sh +++ b/pkgs/by-name/mp/mpp/mpp.sh @@ -1,8 +1,5 @@ #!/usr/bin/env dash -# shellcheck source=/dev/null -SHELL_LIBRARY_VERSION="2.1.2" . %SHELL_LIBRARY_PATH - case "$1" in "searchadd") shift 1 diff --git a/pkgs/by-name/mp/mpp/package.nix b/pkgs/by-name/mp/mpp/package.nix index 9c5315b0..7d7e0527 100644 --- a/pkgs/by-name/mp/mpp/package.nix +++ b/pkgs/by-name/mp/mpp/package.nix @@ -1,20 +1,26 @@ { - sysLib, - mpc, - fd, + writeShellApplication, symlinkJoin, stdenv, + # Dependencies + mpc, + mpp-searchadd, + mpp-lyrics, + mpp-beetrm, + # Build dependencies + fd, zsh, }: let - script = sysLib.writeShellScript { + script = writeShellApplication { name = "mpp"; - src = ./mpp.sh; - generateCompletions = false; - # We source the wrappers from the environment, to ensure that they have the same - # configurations (e.g. MPD_MUSIC_DIR in `mpc-lyrics`) - keepPath = true; - dependencies = [ + text = builtins.readFile ./mpp.sh; + inheritPath = false; + + runtimeInputs = [ mpc + mpp-searchadd + mpp-lyrics + mpp-beetrm ]; }; diff --git a/pkgs/by-name/ne/neorg/functions/add.sh b/pkgs/by-name/ne/neorg/functions/add.sh deleted file mode 100644 index 5a830a10..00000000 --- a/pkgs/by-name/ne/neorg/functions/add.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/usr/bin/env dash - -add0open_taskwarrior_project_file() { - task_project_file="%TASK_PROJECT_FILE" - - cd "$(dirname $task_project_file)" || die "BUG: task_project_file ('$task_project_file') can't be accessed" - - git_dir="$(search_flake_base_dir)" - [ "$git_dir" ] || die "(BUG): No git directory?" - cd "$git_dir" || die "Unreachable, this MUST exists" - - nvim "$task_project_file" - git add "$task_project_file" - - base_task_project_file_path="$(awk "{ gsub(\"$git_dir/\", \"\", \$0); print }" "$(ptmp "$task_project_file")")" - git add $task_project_file - - # Check that only the project file has been added (and that our file is actually - # modified) - if git status --porcelain=v2 | awk -v path="$base_task_project_file_path" 'BEGIN { hit = 0 } { if ($2 ~ /A./ || $2 ~ /M./) { if ($NF ~ path) { hit = 1 } else { hit = 0; exit 1 } } } END { if (hit == 1) { exit 0 } else { exit 1 } }'; then - git commit --verbose --message="chore($(dirname "$base_task_project_file_path")): Update" - fi -} diff --git a/pkgs/by-name/ne/neorg/functions/context.sh b/pkgs/by-name/ne/neorg/functions/context.sh deleted file mode 100644 index 7095847d..00000000 --- a/pkgs/by-name/ne/neorg/functions/context.sh +++ /dev/null @@ -1,43 +0,0 @@ -#!/usr/bin/env dash - -context0open_current_task_context() { - current_context="$(utils0get_current_context)" - - if [ "$current_context" ]; then - context_path="$(utils0get_current_context_path "$current_context")" - - extended_neorg_project_dir="$(utils0get_neorg_project_dir)" - cd "$extended_neorg_project_dir" || die "(BUG?): Can not access the project dir: $extended_neorg_project_dir" - - nvim "$extended_neorg_project_dir/$context_path" - - git add . - git commit --message="chore($(dirname "$context_path")): Update" --no-gpg-sign - else - warn "No context active" - fi -} - -context0open_current_task_context_at_task_id() { - task_id="$1" - current_context="$(utils0get_current_context)" - - if [ "$current_context" ]; then - context_path="$(utils0get_current_context_path "$current_context")" - extended_neorg_project_dir="$(utils0get_neorg_project_dir)" - task_uuid="$(task "$task_id" uuids)" - - cd "$extended_neorg_project_dir" || die "(BUG?): Can not access the project dir: $extended_neorg_project_dir" - - if ! grep -q "% $task_uuid" "$extended_neorg_project_dir/$context_path"; then - echo "* TITLE (% $task_uuid)" >>"$extended_neorg_project_dir/$context_path" - fi - - nvim "$extended_neorg_project_dir/$context_path" -c "/% $task_uuid" - - git add . - git commit --message="chore($(dirname "$context_path")): Update" --no-gpg-sign - else - warn "No context active" - fi -} diff --git a/pkgs/by-name/ne/neorg/functions/dmenu.sh b/pkgs/by-name/ne/neorg/functions/dmenu.sh deleted file mode 100644 index 5a138982..00000000 --- a/pkgs/by-name/ne/neorg/functions/dmenu.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env dash - -dmenu0open_context_in_browser() { - project="$(echo "%ALL_PROJECTS_PIPE" | rofi -sep "|" -dmenu)" - - if [ "$project" ]; then - [ -d "%NEORG_REVIEW_PATH" ] || mkdir --parents "%NEORG_REVIEW_PATH" - [ -f "%NEORG_REVIEW_PATH/$project.lock" ] || touch "%NEORG_REVIEW_PATH/$project.lock" - project0open_project_in_browser "$project" - else - notify-send "(neorg/dmenu) No project selected" - exit 1 - fi -} diff --git a/pkgs/by-name/ne/neorg/functions/f_start.sh b/pkgs/by-name/ne/neorg/functions/f_start.sh deleted file mode 100644 index 2423dd44..00000000 --- a/pkgs/by-name/ne/neorg/functions/f_start.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env dash - -fstart0start_new_task() { - task_id="$1" - fstop0stop_current_task - task start "$task_id" -} diff --git a/pkgs/by-name/ne/neorg/functions/f_stop.sh b/pkgs/by-name/ne/neorg/functions/f_stop.sh deleted file mode 100644 index e4ff0b94..00000000 --- a/pkgs/by-name/ne/neorg/functions/f_stop.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env dash - -fstop0stop_current_task() { - # we ensured that only one task may be active - active="$(task +ACTIVE _ids)" - [ "$active" ] && task stop "$active" -} diff --git a/pkgs/by-name/ne/neorg/functions/inputs.sh b/pkgs/by-name/ne/neorg/functions/inputs.sh deleted file mode 100644 index d47b129a..00000000 --- a/pkgs/by-name/ne/neorg/functions/inputs.sh +++ /dev/null @@ -1,62 +0,0 @@ -#!/usr/bin/env dash - -_git_commit() { - message="$1" - - cd "$(dirname "%NEORG_INPUTS_STORAGE_FILE")" || die "BUG. This should exist." - [ -d .git ] || git init - git add . - git commit --message "$message" --no-gpg-sign -} - -inputs0add() { - url_file="$1" - - mkdir --parents "$(dirname "%NEORG_INPUTS_STORAGE_FILE")" - - { - # Add another newline - echo "" - # echo "# $url_file " - - clean "$url_file" - } >>"%NEORG_INPUTS_STORAGE_FILE" && - msg2 "Successfully added file '$url_file' with $(clean "$url_file" | wc -l) entries to the url list" - - _git_commit "Add entries from '$url_file' ($(clean "$url_file" | wc -l))" -} - -inputs0review() { - base_profile="$1" - - [ -f "%NEORG_INPUTS_STORAGE_FILE" ] || die "'%NEORG_INPUTS_STORAGE_FILE' is not a file. Have you added something with 'inputs_add' yet?" - - done_urls="$(mktmp)" - - # We assume that the project is not yet open. - firefox -P "$base_profile" & - # Give it some time to start up. - sleep 2 - - if [ "$(wc -l <"%NEORG_INPUTS_STORAGE_FILE")" -gt 100 ]; then - echo "Your would want to review more than 100 inputs. Limiting it to the first 100 entries." - fi - - head --lines=100 "%NEORG_INPUTS_STORAGE_FILE" | while read -r url; do - echo "-> '$url'" - firefox -P "$base_profile" "$url" - - echo "$url" >>"$done_urls" - done - - # Wait for the Firefox process from above to finish. - wait - - tmp="$(mktmp)" - # source: https://stackoverflow.com/a/24324455 - awk 'NR==FNR {a[$0]=1; next} !a[$0]' "$done_urls" "%NEORG_INPUTS_STORAGE_FILE" >"$tmp" - - mv "$tmp" "%NEORG_INPUTS_STORAGE_FILE" - - _git_commit "Dump entries into firefox profile '$base_profile'" -} diff --git a/pkgs/by-name/ne/neorg/functions/list.sh b/pkgs/by-name/ne/neorg/functions/list.sh deleted file mode 100644 index 10659457..00000000 --- a/pkgs/by-name/ne/neorg/functions/list.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env dash - -list0list_all_contexts_newline() { - print "%ALL_PROJECTS_NEWLINE" -} -list0list_all_contexts_comma() { - print "%ALL_PROJECTS_COMMA" -} diff --git a/pkgs/by-name/ne/neorg/functions/project.sh b/pkgs/by-name/ne/neorg/functions/project.sh deleted file mode 100644 index 64591850..00000000 --- a/pkgs/by-name/ne/neorg/functions/project.sh +++ /dev/null @@ -1,41 +0,0 @@ -#!/usr/bin/env dash - -project0open_current_context_in_browser() { - current_context="$(utils0get_current_context)" - [ "$current_context" ] || die "No current context to use" - project0open_context_in_browser "$(utils0context2project "$current_context")" -} - -project0open_project_in_browser() { - project="$1" - [ "$project" ] || die "BUG: No context supplied to project0open_context_in_browser" - - old_context="$(utils0get_current_context)" - # We have ensured that only one task may be active - old_started_task="$(task +ACTIVE _ids)" - - tracking="$(mktmp)" - task "project:$project" _ids | xargs --no-run-if-empty task _zshids >"$tracking" - task context "$(utils0project2context "$project")" - - while read -r description; do - desc="$(echo "$description" | awk -F: '{print $2}')" - if [ "$desc" = "tracking" ]; then - task_id="$(echo "$description" | awk -F: '{print $1}')" - notify-send "(Neorg)" "Starting task $project -> $desc" - task start "$task_id" - break - fi - done <"$tracking" - - firefox -P "$project" - - task stop "$task_id" - [ "$old_started_task" ] && task start "$old_started_task" - - if [ "$old_context" ]; then - task context "$old_context" - else - task context none - fi -} diff --git a/pkgs/by-name/ne/neorg/functions/review.sh b/pkgs/by-name/ne/neorg/functions/review.sh deleted file mode 100644 index a0a9ab8d..00000000 --- a/pkgs/by-name/ne/neorg/functions/review.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env dash - -review0start() { - for project in $(list0list_all_contexts_newline); do - if [ -f "%NEORG_REVIEW_PATH/$project.lock" ]; then - msg "Reviewing '$project'" - notify-send "Neorg" "Reviewing '$project'" - firefox -P "$project" - rm "%NEORG_REVIEW_PATH/$project.lock" - fi - done -} diff --git a/pkgs/by-name/ne/neorg/functions/utils.sh b/pkgs/by-name/ne/neorg/functions/utils.sh deleted file mode 100644 index c3843e8e..00000000 --- a/pkgs/by-name/ne/neorg/functions/utils.sh +++ /dev/null @@ -1,40 +0,0 @@ -#!/usr/bin/env dash - -# Runs it's first argument and then the second, regardless if the first failed or -# succeeded -utils0chain() { - eval "$1" - eval "$2" -} - -utils0get_current_context() { - current_context="$(task _get rc.context)" - printf "%s\n" "$current_context" -} - -utils0get_current_context_path() { - current_context="$1" - context_path="$(task _get rc.context."$current_context".rc.neorg_path 2>/dev/null)" - if ! [ "$context_path" ]; then - context_path="$(grep "context.$current_context.rc.neorg_path" "%HOME_TASKRC" | awk 'BEGIN {FS="="} {print $2}')" - [ "$context_path" ] || die "All contexts should have a 'neorg_path' set!" - fi - printf "%s\n" "$context_path" -} - -utils0get_neorg_project_dir() { - # Perform shell expansion of Tilde - neorg_project_dir="$(sed "s|^~|$HOME|" "$(ptmp "%DEFAULT_NEORG_PROJECT_DIR")")" - printf "%s\n" "$neorg_project_dir" -} - -utils0project2context() { - project="$1" - context="$(sed 's|\.|_|g' "$(ptmp "$project")")" - printf "%s\n" "$context" -} -utils0context2project() { - context="$1" - project="$(sed 's|_|\.|g' "$(ptmp "$context")")" - printf "%s\n" "$project" -} diff --git a/pkgs/by-name/ne/neorg/functions/workspace.sh b/pkgs/by-name/ne/neorg/functions/workspace.sh deleted file mode 100644 index d5eb2fca..00000000 --- a/pkgs/by-name/ne/neorg/functions/workspace.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env dash - -workspace0open_neorg_workspace() { - workspace="$1" - nvim -c "NeorgStart" -s "$(ptmp ":Neorg workspace $workspace\n")" -} -workspace0open_neorg_workspace_prompt() { - nvim -c "NeorgStart" -s "$(ptmp ":Neorg workspace ")" -} diff --git a/pkgs/by-name/ne/neorg/main.sh b/pkgs/by-name/ne/neorg/main.sh deleted file mode 100755 index b4f0f0e6..00000000 --- a/pkgs/by-name/ne/neorg/main.sh +++ /dev/null @@ -1,189 +0,0 @@ -#!/usr/bin/env dash - -# shellcheck source=/dev/null -SHELL_LIBRARY_VERSION="2.1.2" . %SHELL_LIBRARY_PATH - -# load dependencies -. ./functions/add.sh -. ./functions/context.sh -. ./functions/dmenu.sh -. ./functions/f_start.sh -. ./functions/f_stop.sh -. ./functions/inputs.sh -. ./functions/list.sh -. ./functions/project.sh -. ./functions/review.sh -. ./functions/utils.sh -. ./functions/workspace.sh - -# these are used in version() -# shellcheck disable=2034 -AUTHORS="Soispha" -# shellcheck disable=2034 -YEARS="2023" - -NAME="neorg" - -help() { - cat <<EOF -This is the core interface to the system-integrated task management - -USAGE: - $NAME [OPTIONS] [COMMAND] - -OPTIONS: - --help | -h - Display this help and exit. - - --version | -v - Display version and copyright information and exit. -COMMANDS: - task [ID] - Open the neorg context associated with the current context and - the uuid of the task with id ID. Without ID, it'll open the - current context's norg file. - If no context is set, drops you to the selection prompt - - dmenu - Select a project in dmenu mode. This will give you all projects - and exectute the selected one as in 'neorg projects <selected>' - - workspace [WS] - The neorg workspace (WS) to open at startup, an empty value drops - you at a prompt to enter the workspace yourself. - - project [P] - Opens the webbrowser with either the context (P) or - the current active context as argument if no context is supplied - - list - Lists all available contexts - - add - Allows you to quickly add projects - - fstart ID - Starts the task (ID) but only after it stooped - the previous active task, if it existed. - - fstop - Stops the current active task - - review - Review all firefox tabs - - inputs_add F - Add all urls from the file F as inputs to be catogorized - - inputs_review P - Like 'review', but for the inputs that have previously been added. - It takes a project in which to open the urls. -ARGUMENTS: - ID | *([0-9]) := [[%ID_GENERATION_FUNCTION]] - The function displays all possible IDs of the eligable tasks. - - WS := %ALL_WORKSPACES - All possible workspaces. - - P := %ALL_PROJECTS_PIPE - The possible project. - - F := [[fd . --max-depth 3]] - A URL-Input file to use as source. - -EOF -} - -for arg in "$@"; do - case "$arg" in - "--help" | "-h") - help - exit 0 - ;; - "--version" | "-v") - version - exit 0 - ;; - esac -done - -while [ "$#" -ne 0 ]; do - case "$1" in - "t"*) # task - shift 1 - task_id="$1" - [ "$task_id" ] || utils0chain context0open_current_task_context "exit 0" - context0open_current_task_context_at_task_id "$task_id" - exit 0 - ;; - "w"*) # workspace - shift 1 - workspace_to_open="$1" - # TODO: Exit with 1 on error, instead of the 0 <2023-10-20> - [ "$workspace_to_open" ] || utils0chain workspace0open_neorg_workspace_prompt "exit 0" - workspace0open_neorg_workspace "$workspace_to_open" - exit 0 - ;; - "p"*) # project - shift 1 - project_to_open="$1" - # TODO: Exit with 1 on error, instead of the 0 <2023-10-20> - [ "$project_to_open" ] || utils0chain project0open_current_context_in_browser "exit 0" - if ! grep -q "$project_to_open" "$(ptmp "%ALL_PROJECTS_NEWLINE")"; then - die "Your project ('$project_to_open') is not in the list of available projects: -%ALL_PROJECTS_COMMA" - fi - project0open_project_in_browser "$project_to_open" - exit 0 - ;; - "l"*) # list - list0list_all_contexts_newline - exit 0 - ;; - "a"*) # add-project - add0open_taskwarrior_project_file - exit 0 - ;; - "d"*) # dmenu - dmenu0open_context_in_browser - exit 0 - ;; - "fsta"*) # fstart - shift 1 - task_id="$1" - [ "$task_id" ] || die "No task id provided to fstart" - fstart0start_new_task "$task_id" - exit 0 - ;; - "fsto"*) # fstop - fstop0stop_current_task - exit 0 - ;; - "r"*) # review - shift 1 - review0start - exit 0 - ;; - "inputs_a"*) # inputs_add - shift 1 - url_file="$1" - [ -f "$url_file" ] || die "Url file ('$url_file') is not a valid file." - inputs0add "$url_file" - exit 0 - ;; - "inputs_r"*) # inputs_review - shift 1 - base_project="$1" - [ -z "$base_project" ] && die "'inputs_review' requires a project." - inputs0review "$base_project" - exit 0 - ;; - *) - die "Command '$1' does not exist! Please look at:\n $NAME --help" - exit 0 - ;; - esac -done - -context0open_current_task_context -# vim: ft=sh diff --git a/pkgs/by-name/ne/neorg/neorg_id_function.sh b/pkgs/by-name/ne/neorg/neorg_id_function.sh deleted file mode 100755 index 865ecacf..00000000 --- a/pkgs/by-name/ne/neorg/neorg_id_function.sh +++ /dev/null @@ -1,16 +0,0 @@ -#! /usr/bin/env dash - -# shellcheck source=/dev/null -SHELL_LIBRARY_VERSION="2.1.2" . %SHELL_LIBRARY_PATH - -context="$(task _get rc.context)" -if [ "$context" ]; then - filter="project:$context" -else - filter="0-10000" -fi -tasks="$(task "$filter" _ids)" - -if [ "$tasks" ]; then - echo "$tasks" | xargs task _zshids | awk -F: -v q="'" '{gsub(/'\''/, q "\\" q q ); print $1 ":" q $2 q}' -fi diff --git a/pkgs/by-name/ne/neorg/package.nix b/pkgs/by-name/ne/neorg/package.nix deleted file mode 100644 index ad39290a..00000000 --- a/pkgs/by-name/ne/neorg/package.nix +++ /dev/null @@ -1,75 +0,0 @@ -{ - lib, - sysLib, - # dependencies - cocogitto, - rofi, - libnotify, - taskwarrior, - gawk, - findutils, - # config - defaultNeorgProjectDir ? "/no-default-dir", # homeConfig.programs.nixvim.plugins.neorg.settings.load."core.dirman".config.workspaces.projects - allProjectsNewline ? "", # homeConfig.soispha.taskwarrior.projects.projects_newline - allProjectsComma ? "", # homeConfig.soispha.taskwarrior.projects.projects_comma - allProjectsPipe ? "", # homeConfig.soispha.taskwarrior.projects.projects_pipe - allWorkspaces ? {}, # homeConfig.programs.nixvim.plugins.neorg.settings.load."core.dirman".config.workspaces - xdgConfigHome ? builtins.getEnv "XDG_CONFIG_HOME", - xdgDataHome ? builtins.getEnv "XDG_DATA_HOME", -}: -(sysLib.writeShellScriptMultiPart { - name = "neorg"; - src = ./.; - generateCompletions = true; - keepPath = true; - - baseName = "main.sh"; - cmdPrefix = "functions"; - cmdNames = [ - "add.sh" - "context.sh" - "dmenu.sh" - "f_start.sh" - "f_stop.sh" - "inputs.sh" - "list.sh" - "project.sh" - "review.sh" - "utils.sh" - "workspace.sh" - ]; - - dependencies = [ - cocogitto - rofi - libnotify - ]; - replacementStrings = { - DEFAULT_NEORG_PROJECT_DIR = defaultNeorgProjectDir; - HOME_TASKRC = "${xdgConfigHome}/task/home-manager-taskrc"; - NEORG_REVIEW_PATH = "${xdgDataHome}/neorg/review"; - - NEORG_INPUTS_STORAGE_FILE = "${xdgDataHome}/neorg/inputs/url_list.txt"; - - ALL_PROJECTS_NEWLINE = allProjectsNewline; - ALL_PROJECTS_COMMA = allProjectsComma; - ALL_PROJECTS_PIPE = allProjectsPipe; - ALL_WORKSPACES = "${lib.strings.concatStringsSep "|" (builtins.attrNames allWorkspaces)}"; - - ID_GENERATION_FUNCTION = "${sysLib.writeShellScript { - name = "neorg_id_function"; - src = ./neorg_id_function.sh; - dependencies = [ - taskwarrior - gawk - findutils # source of xargs - ]; - }}/bin/neorg_id_function"; - - # TODO: Replace the hard-coded path here with some reference <2023-10-20> - TASK_PROJECT_FILE = "/home/soispha/repos/nix/nixos-config/hm/soispha/conf/taskwarrior/projects/default.nix"; - }; -}) -// { - meta.mainProgram = "neorg"; -} diff --git a/pkgs/by-name/ri/river-mk-keymap/Cargo.lock b/pkgs/by-name/ri/river-mk-keymap/Cargo.lock index 7fb009ef..a7cd031e 100644 --- a/pkgs/by-name/ri/river-mk-keymap/Cargo.lock +++ b/pkgs/by-name/ri/river-mk-keymap/Cargo.lock @@ -54,15 +54,15 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.97" +version = "1.0.98" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcfed56ad506cb2c684a14971b8861fdc3baaaae314b9e5f9bb532cbe3ba7a4f" +checksum = "e16d2d3311acee920a9eb8d33b8cbc1787ce4a264e85f964c2404b969bdcd487" [[package]] name = "clap" -version = "4.5.34" +version = "4.5.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e958897981290da2a852763fe9cdb89cd36977a5d729023127095fa94d95e2ff" +checksum = "2df961d8c8a0d08aa9945718ccf584145eee3f3aa06cddbeac12933781102e04" dependencies = [ "clap_builder", "clap_derive", @@ -70,9 +70,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.34" +version = "4.5.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83b0f35019843db2160b5bb19ae09b4e6411ac33fc6a712003c33e03090e2489" +checksum = "132dbda40fb6753878316a489d5a1242a8ef2f0d9e47ba01c951ea8aa7d013a5" dependencies = [ "anstream", "anstyle", diff --git a/pkgs/by-name/ri/river-mk-keymap/Cargo.toml b/pkgs/by-name/ri/river-mk-keymap/Cargo.toml index f14411f2..576c62d0 100644 --- a/pkgs/by-name/ri/river-mk-keymap/Cargo.toml +++ b/pkgs/by-name/ri/river-mk-keymap/Cargo.toml @@ -6,8 +6,8 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -anyhow = "1.0.97" -clap = { version = "4.5.34", features = ["derive"] } +anyhow = "1.0.98" +clap = { version = "4.5.36", features = ["derive"] } keymaps = { version = "1.0.0", features = ["serde", "mouse-keys"] } serde = { version = "1.0.219", features = ["derive"] } serde_json = "1.0.140" diff --git a/pkgs/by-name/ri/river-mk-keymap/flake.lock b/pkgs/by-name/ri/river-mk-keymap/flake.lock index 82448387..d5cbe443 100644 --- a/pkgs/by-name/ri/river-mk-keymap/flake.lock +++ b/pkgs/by-name/ri/river-mk-keymap/flake.lock @@ -2,11 +2,11 @@ "nodes": { "nixpkgs": { "locked": { - "lastModified": 1743076231, - "narHash": "sha256-yQugdVfi316qUfqzN8JMaA2vixl+45GxNm4oUfXlbgw=", + "lastModified": 1744536153, + "narHash": "sha256-awS2zRgF4uTwrOKwwiJcByDzDOdo3Q1rPZbiHQg/N38=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "6c5963357f3c1c840201eda129a99d455074db04", + "rev": "18dd725c29603f582cf1900e0d25f9f1063dbf11", "type": "github" }, "original": { diff --git a/pkgs/by-name/sc/screenshot_temporary/package.nix b/pkgs/by-name/sc/screenshot_temporary/package.nix index f3739b01..1c45a07b 100644 --- a/pkgs/by-name/sc/screenshot_temporary/package.nix +++ b/pkgs/by-name/sc/screenshot_temporary/package.nix @@ -1,15 +1,15 @@ { - sysLib, + writeShellApplication, + # Dependencies grim, slurp, wl-clipboard, }: -sysLib.writeShellScript { +writeShellApplication { name = "screenshot_temporary"; - src = ./screenshot_temporary.sh; - generateCompletions = false; - keepPath = false; - dependencies = [ + text = builtins.readFile ./screenshot_temporary.sh; + inheritPath = false; + runtimeInputs = [ grim slurp wl-clipboard diff --git a/pkgs/by-name/sc/screenshot_temporary/screenshot_temporary.sh b/pkgs/by-name/sc/screenshot_temporary/screenshot_temporary.sh index 8968ca79..60a27057 100755 --- a/pkgs/by-name/sc/screenshot_temporary/screenshot_temporary.sh +++ b/pkgs/by-name/sc/screenshot_temporary/screenshot_temporary.sh @@ -1,8 +1,5 @@ #! /usr/bin/env dash -# shellcheck source=/dev/null -SHELL_LIBRARY_VERSION="2.1.2" . %SHELL_LIBRARY_PATH - grim -g "$(slurp)" | wl-copy # vim: ft=sh diff --git a/pkgs/by-name/sn/snap-sync-forked/package.nix b/pkgs/by-name/sn/snap-sync-forked/package.nix index b3f40b24..6e020b60 100644 --- a/pkgs/by-name/sn/snap-sync-forked/package.nix +++ b/pkgs/by-name/sn/snap-sync-forked/package.nix @@ -1,5 +1,5 @@ { - sysLib, + writeShellApplication, bash, btrfs-progs, coreutils, @@ -14,10 +14,11 @@ rsync, sudo, }: -sysLib.writeShellScript { +writeShellApplication { name = "snap-sync-forked"; - src = ./snap-sync-forked.sh; - dependencies = [ + text = builtins.readFile ./snap-sync-forked.sh; + inheritPath = false; + runtimeInputs = [ bash btrfs-progs coreutils diff --git a/pkgs/by-name/sn/snap-sync-forked/snap-sync-forked.sh b/pkgs/by-name/sn/snap-sync-forked/snap-sync-forked.sh index 3d9c1ac9..29f14b4f 100755 --- a/pkgs/by-name/sn/snap-sync-forked/snap-sync-forked.sh +++ b/pkgs/by-name/sn/snap-sync-forked/snap-sync-forked.sh @@ -1,8 +1,5 @@ #!/usr/bin/env bash -# shellcheck source=/dev/null -SHELL_LIBRARY_VERSION="2.1.2" . %SHELL_LIBRARY_PATH - # # snap-sync # https://github.com/wesbarnett/snap-sync diff --git a/pkgs/by-name/st/stamp/package.nix b/pkgs/by-name/st/stamp/package.nix index 703f73e3..998268a6 100644 --- a/pkgs/by-name/st/stamp/package.nix +++ b/pkgs/by-name/st/stamp/package.nix @@ -1,20 +1,18 @@ { - sysLib, - findutils, + writeShellApplication, + # Dependencies fd, - reuse, git, + reuse, }: -sysLib.writeShellScript { +writeShellApplication { name = "stamp"; - src = ./stamp.sh; - generateCompletions = false; - keepPath = false; + text = builtins.readFile ./stamp.sh; + inheritPath = false; - dependencies = [ - findutils + runtimeInputs = [ fd - reuse git + reuse ]; } diff --git a/pkgs/by-name/st/stamp/stamp.sh b/pkgs/by-name/st/stamp/stamp.sh index 0aa6c281..63b915a0 100755 --- a/pkgs/by-name/st/stamp/stamp.sh +++ b/pkgs/by-name/st/stamp/stamp.sh @@ -1,7 +1,9 @@ #!/usr/bin/env dash -# shellcheck source=/dev/null -SHELL_LIBRARY_VERSION="2.1.2" . %SHELL_LIBRARY_PATH +die() { + echo "Error: $1" + exit 1 +} help() { cat <<EOF diff --git a/pkgs/by-name/ts/tskm/.envrc b/pkgs/by-name/ts/tskm/.envrc new file mode 100644 index 00000000..a83561cc --- /dev/null +++ b/pkgs/by-name/ts/tskm/.envrc @@ -0,0 +1,5 @@ +#!/usr/bin/env sh + +export TSKM_PROJECT_FILE=/home/soispha/repos/nix/config/modules/common/projects.json + +use flake diff --git a/pkgs/by-name/ts/tskm/.gitignore b/pkgs/by-name/ts/tskm/.gitignore new file mode 100644 index 00000000..2d5df85d --- /dev/null +++ b/pkgs/by-name/ts/tskm/.gitignore @@ -0,0 +1,2 @@ +/target +.direnv diff --git a/pkgs/by-name/ts/tskm/Cargo.lock b/pkgs/by-name/ts/tskm/Cargo.lock new file mode 100644 index 00000000..e4872145 --- /dev/null +++ b/pkgs/by-name/ts/tskm/Cargo.lock @@ -0,0 +1,1330 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "adler2" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627" + +[[package]] +name = "ahash" +version = "0.8.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" +dependencies = [ + "cfg-if", + "once_cell", + "version_check", + "zerocopy", +] + +[[package]] +name = "android-tzdata" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" + +[[package]] +name = "android_system_properties" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +dependencies = [ + "libc", +] + +[[package]] +name = "anstream" +version = "0.6.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8acc5369981196006228e28809f761875c0327210a891e941f4c683b3a99529b" +dependencies = [ + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "is_terminal_polyfill", + "utf8parse", +] + +[[package]] +name = "anstyle" +version = "1.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55cc3b69f167a1ef2e161439aa98aed94e6028e5f9a59be9a6ffb47aef1651f9" + +[[package]] +name = "anstyle-parse" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b2d16507662817a6a20a9ea92df6652ee4f94f914589377d69f3b21bc5798a9" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "79947af37f4177cfead1110013d678905c37501914fba0efea834c3fe9a8d60c" +dependencies = [ + "windows-sys", +] + +[[package]] +name = "anstyle-wincon" +version = "3.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca3534e77181a9cc07539ad51f2141fe32f6c3ffd4df76db8ad92346b003ae4e" +dependencies = [ + "anstyle", + "once_cell", + "windows-sys", +] + +[[package]] +name = "anyhow" +version = "1.0.98" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e16d2d3311acee920a9eb8d33b8cbc1787ce4a264e85f964c2404b969bdcd487" + +[[package]] +name = "autocfg" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" + +[[package]] +name = "bitflags" +version = "2.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c8214115b7bf84099f1309324e63141d4c5d7cc26862f97a0a857dbefe165bd" + +[[package]] +name = "bumpalo" +version = "3.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1628fb46dfa0b37568d12e5edd512553eccf6a22a78e8bde00bb4aed84d5bdbf" + +[[package]] +name = "byteorder" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" + +[[package]] +name = "cc" +version = "1.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e3a13707ac958681c13b39b458c073d0d9bc8a22cb1b2f4c8e55eb72c13f362" +dependencies = [ + "shlex", +] + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "chrono" +version = "0.4.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a7964611d71df112cb1730f2ee67324fcf4d0fc6606acbbe9bfe06df124637c" +dependencies = [ + "android-tzdata", + "iana-time-zone", + "js-sys", + "num-traits", + "serde", + "wasm-bindgen", + "windows-link", +] + +[[package]] +name = "clap" +version = "4.5.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2df961d8c8a0d08aa9945718ccf584145eee3f3aa06cddbeac12933781102e04" +dependencies = [ + "clap_builder", + "clap_derive", +] + +[[package]] +name = "clap_builder" +version = "4.5.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "132dbda40fb6753878316a489d5a1242a8ef2f0d9e47ba01c951ea8aa7d013a5" +dependencies = [ + "anstream", + "anstyle", + "clap_lex", + "strsim", +] + +[[package]] +name = "clap_complete" +version = "4.5.47" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c06f5378ea264ad4f82bbc826628b5aad714a75abf6ece087e923010eb937fb6" +dependencies = [ + "clap", + "clap_lex", + "is_executable", + "shlex", +] + +[[package]] +name = "clap_derive" +version = "4.5.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09176aae279615badda0765c0c0b3f6ed53f4709118af73cf4655d85d1530cd7" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "clap_lex" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f46ad14479a25103f283c0f10005961cf086d8dc42205bb44c46ac563475dca6" + +[[package]] +name = "colorchoice" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b63caa9aa9397e2d9480a9b13673856c78d8ac123288526c37d7839f2a86990" + +[[package]] +name = "core-foundation-sys" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" + +[[package]] +name = "crc32fast" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a97769d94ddab943e4510d138150169a2758b5ef3eb191a9ee688de3e23ef7b3" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "dirs" +version = "6.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3e8aa94d75141228480295a7d0e7feb620b1a5ad9f12bc40be62411e38cce4e" +dependencies = [ + "dirs-sys", +] + +[[package]] +name = "dirs-sys" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e01a3366d27ee9890022452ee61b2b63a67e6f13f58900b651ff5665f0bb1fab" +dependencies = [ + "libc", + "option-ext", + "redox_users", + "windows-sys", +] + +[[package]] +name = "displaydoc" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "fallible-iterator" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2acce4a10f12dc2fb14a218589d4f1f62ef011b2d0cc4b3cb1bba8e94da14649" + +[[package]] +name = "fallible-streaming-iterator" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7360491ce676a36bf9bb3c56c1aa791658183a54d2744120f27285738d90465a" + +[[package]] +name = "flate2" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ced92e76e966ca2fd84c8f7aa01a4aea65b0eb6648d72f7c8f3e2764a67fece" +dependencies = [ + "crc32fast", + "miniz_oxide", +] + +[[package]] +name = "form_urlencoded" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" +dependencies = [ + "percent-encoding", +] + +[[package]] +name = "getrandom" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" +dependencies = [ + "cfg-if", + "libc", + "wasi 0.11.0+wasi-snapshot-preview1", +] + +[[package]] +name = "getrandom" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73fea8450eea4bac3940448fb7ae50d91f034f941199fcd9d909a5a07aa455f0" +dependencies = [ + "cfg-if", + "libc", + "r-efi", + "wasi 0.14.2+wasi-0.2.4", +] + +[[package]] +name = "hashbrown" +version = "0.14.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" +dependencies = [ + "ahash", +] + +[[package]] +name = "hashlink" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ba4ff7128dee98c7dc9794b6a411377e1404dba1c97deb8d1a55297bd25d8af" +dependencies = [ + "hashbrown", +] + +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + +[[package]] +name = "hermit-abi" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fbd780fe5cc30f81464441920d82ac8740e2e46b29a6fad543ddd075229ce37e" + +[[package]] +name = "iana-time-zone" +version = "0.1.63" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0c919e5debc312ad217002b8048a17b7d83f80703865bbfcfebb0458b0b27d8" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "log", + "wasm-bindgen", + "windows-core", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" +dependencies = [ + "cc", +] + +[[package]] +name = "icu_collections" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db2fa452206ebee18c4b5c2274dbf1de17008e874b4dc4f0aea9d01ca79e4526" +dependencies = [ + "displaydoc", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_locid" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13acbb8371917fc971be86fc8057c41a64b521c184808a698c02acc242dbf637" +dependencies = [ + "displaydoc", + "litemap", + "tinystr", + "writeable", + "zerovec", +] + +[[package]] +name = "icu_locid_transform" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01d11ac35de8e40fdeda00d9e1e9d92525f3f9d887cdd7aa81d727596788b54e" +dependencies = [ + "displaydoc", + "icu_locid", + "icu_locid_transform_data", + "icu_provider", + "tinystr", + "zerovec", +] + +[[package]] +name = "icu_locid_transform_data" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7515e6d781098bf9f7205ab3fc7e9709d34554ae0b21ddbcb5febfa4bc7df11d" + +[[package]] +name = "icu_normalizer" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19ce3e0da2ec68599d193c93d088142efd7f9c5d6fc9b803774855747dc6a84f" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_normalizer_data", + "icu_properties", + "icu_provider", + "smallvec", + "utf16_iter", + "utf8_iter", + "write16", + "zerovec", +] + +[[package]] +name = "icu_normalizer_data" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c5e8338228bdc8ab83303f16b797e177953730f601a96c25d10cb3ab0daa0cb7" + +[[package]] +name = "icu_properties" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93d6020766cfc6302c15dbbc9c8778c37e62c14427cb7f6e601d849e092aeef5" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_locid_transform", + "icu_properties_data", + "icu_provider", + "tinystr", + "zerovec", +] + +[[package]] +name = "icu_properties_data" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85fb8799753b75aee8d2a21d7c14d9f38921b54b3dbda10f5a3c7a7b82dba5e2" + +[[package]] +name = "icu_provider" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ed421c8a8ef78d3e2dbc98a973be2f3770cb42b606e3ab18d6237c4dfde68d9" +dependencies = [ + "displaydoc", + "icu_locid", + "icu_provider_macros", + "stable_deref_trait", + "tinystr", + "writeable", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_provider_macros" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "idna" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "686f825264d630750a544639377bae737628043f20d38bbc029e8f29ea968a7e" +dependencies = [ + "idna_adapter", + "smallvec", + "utf8_iter", +] + +[[package]] +name = "idna_adapter" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "daca1df1c957320b2cf139ac61e7bd64fed304c5040df000a745aa1de3b4ef71" +dependencies = [ + "icu_normalizer", + "icu_properties", +] + +[[package]] +name = "is-terminal" +version = "0.4.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e04d7f318608d35d4b61ddd75cbdaee86b023ebe2bd5a66ee0915f0bf93095a9" +dependencies = [ + "hermit-abi", + "libc", + "windows-sys", +] + +[[package]] +name = "is_executable" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4a1b5bad6f9072935961dfbf1cced2f3d129963d091b6f69f007fe04e758ae2" +dependencies = [ + "winapi", +] + +[[package]] +name = "is_terminal_polyfill" +version = "1.70.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" + +[[package]] +name = "itoa" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" + +[[package]] +name = "js-sys" +version = "0.3.77" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1cfaf33c695fc6e08064efbc1f72ec937429614f25eef83af942d0e227c3a28f" +dependencies = [ + "once_cell", + "wasm-bindgen", +] + +[[package]] +name = "libc" +version = "0.2.171" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c19937216e9d3aa9956d9bb8dfc0b0c8beb6058fc4f7a4dc4d850edf86a237d6" + +[[package]] +name = "libredox" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" +dependencies = [ + "bitflags", + "libc", +] + +[[package]] +name = "libsqlite3-sys" +version = "0.30.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e99fb7a497b1e3339bc746195567ed8d3e24945ecd636e3619d20b9de9e9149" +dependencies = [ + "pkg-config", + "vcpkg", +] + +[[package]] +name = "litemap" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23fb14cb19457329c82206317a5663005a4d404783dc74f4252769b0d5f42856" + +[[package]] +name = "log" +version = "0.4.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94" + +[[package]] +name = "lz4_flex" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75761162ae2b0e580d7e7c390558127e5f01b4194debd6221fd8c207fc80e3f5" +dependencies = [ + "twox-hash", +] + +[[package]] +name = "memchr" +version = "2.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" + +[[package]] +name = "miniz_oxide" +version = "0.8.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3be647b768db090acb35d5ec5db2b0e1f1de11133ca123b9eacf5137868f892a" +dependencies = [ + "adler2", +] + +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", +] + +[[package]] +name = "once_cell" +version = "1.21.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" + +[[package]] +name = "option-ext" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" + +[[package]] +name = "percent-encoding" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" + +[[package]] +name = "pkg-config" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7edddbd0b52d732b21ad9a5fab5c704c14cd949e5e9a1ec5929a24fded1b904c" + +[[package]] +name = "proc-macro2" +version = "1.0.94" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a31971752e70b8b2686d7e46ec17fb38dad4051d94024c88df49b667caea9c84" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "r-efi" +version = "5.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74765f6d916ee2faa39bc8e68e4f3ed8949b48cccdac59983d287a7cb71ce9c5" + +[[package]] +name = "redox_users" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd6f9d3d47bdd2ad6945c5015a226ec6155d0bcdfd8f7cd29f86b71f8de99d2b" +dependencies = [ + "getrandom 0.2.15", + "libredox", + "thiserror", +] + +[[package]] +name = "rusqlite" +version = "0.32.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7753b721174eb8ff87a9a0e799e2d7bc3749323e773db92e0984debb00019d6e" +dependencies = [ + "bitflags", + "fallible-iterator", + "fallible-streaming-iterator", + "hashlink", + "libsqlite3-sys", + "smallvec", +] + +[[package]] +name = "rustversion" +version = "1.0.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eded382c5f5f786b989652c49544c4877d9f015cc22e145a5ea8ea66c2921cd2" + +[[package]] +name = "ryu" +version = "1.0.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f" + +[[package]] +name = "same-file" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "serde" +version = "1.0.219" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.219" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.140" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20068b6e96dc6c9bd23e01df8827e6c7e1f2fddd43c21810382803c136b99373" +dependencies = [ + "itoa", + "memchr", + "ryu", + "serde", +] + +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + +[[package]] +name = "smallvec" +version = "1.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8917285742e9f3e1683f0a9c4e6b57960b7314d0b08d30d1ecd426713ee2eee9" + +[[package]] +name = "stable_deref_trait" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" + +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + +[[package]] +name = "stderrlog" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61c910772f992ab17d32d6760e167d2353f4130ed50e796752689556af07dc6b" +dependencies = [ + "chrono", + "is-terminal", + "log", + "termcolor", + "thread_local", +] + +[[package]] +name = "strsim" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" + +[[package]] +name = "strum" +version = "0.27.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f64def088c51c9510a8579e3c5d67c65349dcf755e5479ad3d010aa6454e2c32" + +[[package]] +name = "strum_macros" +version = "0.27.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c77a8c5abcaf0f9ce05d62342b7d298c346515365c36b673df4ebe3ced01fde8" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "rustversion", + "syn", +] + +[[package]] +name = "syn" +version = "2.0.100" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b09a44accad81e1ba1cd74a32461ba89dee89095ba17b32f5d03683b1b1fc2a0" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "synstructure" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "taskchampion" +version = "2.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b010f5ebe51e88ae490691ed2a43b699e3468c8e3838e244accd8526aca7751b" +dependencies = [ + "anyhow", + "byteorder", + "chrono", + "flate2", + "log", + "rusqlite", + "serde", + "serde_json", + "strum", + "strum_macros", + "thiserror", + "uuid", +] + +[[package]] +name = "termcolor" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "thiserror" +version = "2.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "567b8a2dae586314f7be2a752ec7474332959c6460e02bde30d702a66d488708" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "2.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f7cf42b4507d8ea322120659672cf1b9dbb93f8f2d4ecfd6e51350ff5b17a1d" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "thread_local" +version = "1.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b9ef9bad013ada3808854ceac7b46812a6465ba368859a37e2100283d2d719c" +dependencies = [ + "cfg-if", + "once_cell", +] + +[[package]] +name = "tinystr" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9117f5d4db391c1cf6927e7bea3db74b9a1c1add8f7eda9ffd5364f40f57b82f" +dependencies = [ + "displaydoc", + "zerovec", +] + +[[package]] +name = "tskm" +version = "0.1.0" +dependencies = [ + "anyhow", + "clap", + "clap_complete", + "dirs", + "log", + "lz4_flex", + "serde", + "serde_json", + "stderrlog", + "taskchampion", + "url", + "walkdir", +] + +[[package]] +name = "twox-hash" +version = "1.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97fee6b57c6a41524a810daee9286c02d7752c4253064d0b05472833a438f675" +dependencies = [ + "cfg-if", + "static_assertions", +] + +[[package]] +name = "unicode-ident" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512" + +[[package]] +name = "url" +version = "2.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32f8b686cadd1473f4bd0117a5d28d36b1ade384ea9b5069a1c40aefed7fda60" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", + "serde", +] + +[[package]] +name = "utf16_iter" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8232dd3cdaed5356e0f716d285e4b40b932ac434100fe9b7e0e8e935b9e6246" + +[[package]] +name = "utf8_iter" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" + +[[package]] +name = "utf8parse" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" + +[[package]] +name = "uuid" +version = "1.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "458f7a779bf54acc9f347480ac654f68407d3aab21269a6e3c9f922acd9e2da9" +dependencies = [ + "getrandom 0.3.2", + "serde", +] + +[[package]] +name = "vcpkg" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" + +[[package]] +name = "version_check" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" + +[[package]] +name = "walkdir" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b" +dependencies = [ + "same-file", + "winapi-util", +] + +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + +[[package]] +name = "wasi" +version = "0.14.2+wasi-0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9683f9a5a998d873c0d21fcbe3c083009670149a8fab228644b8bd36b2c48cb3" +dependencies = [ + "wit-bindgen-rt", +] + +[[package]] +name = "wasm-bindgen" +version = "0.2.100" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1edc8929d7499fc4e8f0be2262a241556cfc54a0bea223790e71446f2aab1ef5" +dependencies = [ + "cfg-if", + "once_cell", + "rustversion", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.100" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f0a0651a5c2bc21487bde11ee802ccaf4c51935d0d3d42a6101f98161700bc6" +dependencies = [ + "bumpalo", + "log", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.100" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7fe63fc6d09ed3792bd0897b314f53de8e16568c2b3f7982f468c0bf9bd0b407" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.100" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ae87ea40c9f689fc23f209965b6fb8a99ad69aeeb0231408be24920604395de" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.100" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a05d73b933a847d6cccdda8f838a22ff101ad9bf93e33684f39c1f5f0eece3d" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-util" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb" +dependencies = [ + "windows-sys", +] + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "windows-core" +version = "0.61.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4763c1de310c86d75a878046489e2e5ba02c649d185f21c67d4cf8a56d098980" +dependencies = [ + "windows-implement", + "windows-interface", + "windows-link", + "windows-result", + "windows-strings", +] + +[[package]] +name = "windows-implement" +version = "0.60.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a47fddd13af08290e67f4acabf4b459f647552718f683a7b415d290ac744a836" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "windows-interface" +version = "0.59.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd9211b69f8dcdfa817bfd14bf1c97c9188afa36f4750130fcdf3f400eca9fa8" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "windows-link" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76840935b766e1b0a05c0066835fb9ec80071d4c09a16f6bd5f7e655e3c14c38" + +[[package]] +name = "windows-result" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c64fd11a4fd95df68efcfee5f44a294fe71b8bc6a91993e2791938abcc712252" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-strings" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a2ba9642430ee452d5a7aa78d72907ebe8cfda358e8cb7918a2050581322f97" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-sys" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_gnullvm", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + +[[package]] +name = "wit-bindgen-rt" +version = "0.39.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f42320e61fe2cfd34354ecb597f86f413484a798ba44a8ca1165c58d42da6c1" +dependencies = [ + "bitflags", +] + +[[package]] +name = "write16" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1890f4022759daae28ed4fe62859b1236caebfc61ede2f63ed4e695f3f6d936" + +[[package]] +name = "writeable" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e9df38ee2d2c3c5948ea468a8406ff0db0b29ae1ffde1bcf20ef305bcc95c51" + +[[package]] +name = "yoke" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "120e6aef9aa629e3d4f52dc8cc43a015c7724194c97dfaf45180d2daf2b77f40" +dependencies = [ + "serde", + "stable_deref_trait", + "yoke-derive", + "zerofrom", +] + +[[package]] +name = "yoke-derive" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2380878cad4ac9aac1e2435f3eb4020e8374b5f13c296cb75b4620ff8e229154" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "synstructure", +] + +[[package]] +name = "zerocopy" +version = "0.7.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.7.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "zerofrom" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50cc42e0333e05660c3587f3bf9d0478688e15d870fab3346451ce7f8c9fbea5" +dependencies = [ + "zerofrom-derive", +] + +[[package]] +name = "zerofrom-derive" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d71e5d6e06ab090c67b5e44993ec16b72dcbaabc526db883a360057678b48502" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "synstructure", +] + +[[package]] +name = "zerovec" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa2b893d79df23bfb12d5461018d408ea19dfafe76c2c7ef6d4eba614f8ff079" +dependencies = [ + "yoke", + "zerofrom", + "zerovec-derive", +] + +[[package]] +name = "zerovec-derive" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6eafa6dfb17584ea3e2bd6e76e0cc15ad7af12b09abdd1ca55961bed9b1063c6" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] diff --git a/pkgs/by-name/ts/tskm/Cargo.toml b/pkgs/by-name/ts/tskm/Cargo.toml new file mode 100644 index 00000000..ec17c7b4 --- /dev/null +++ b/pkgs/by-name/ts/tskm/Cargo.toml @@ -0,0 +1,80 @@ +[package] +name = "tskm" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +anyhow = "1.0.98" +clap = { version = "4.5.36", features = ["derive"] } +clap_complete = { version = "4.5.47", features = ["unstable-dynamic"] } +dirs = "6.0.0" +log = "0.4.27" +lz4_flex = "0.11.3" +serde = { version = "1.0.219", features = ["derive"] } +serde_json = "1.0.140" +stderrlog = "0.6.0" +taskchampion = { version = "2.0.3", default-features = false } +url = { version = "2.5.4", features = ["serde"] } +walkdir = "2.5.0" + +[profile.release] +lto = true +codegen-units = 1 +panic = "abort" +split-debuginfo = "off" + +[lints.rust] +# rustc lint groups https://doc.rust-lang.org/rustc/lints/groups.html +warnings = "warn" +future_incompatible = { level = "warn", priority = -1 } +let_underscore = { level = "warn", priority = -1 } +nonstandard_style = { level = "warn", priority = -1 } +rust_2018_compatibility = { level = "warn", priority = -1 } +rust_2018_idioms = { level = "warn", priority = -1 } +rust_2021_compatibility = { level = "warn", priority = -1 } +unused = { level = "warn", priority = -1 } +# rustc allowed-by-default lints https://doc.rust-lang.org/rustc/lints/listing/allowed-by-default.html +# missing_docs = "warn" +macro_use_extern_crate = "warn" +meta_variable_misuse = "warn" +missing_abi = "warn" +missing_copy_implementations = "warn" +missing_debug_implementations = "warn" +non_ascii_idents = "warn" +noop_method_call = "warn" +single_use_lifetimes = "warn" +trivial_casts = "warn" +trivial_numeric_casts = "warn" +unreachable_pub = "warn" +unsafe_op_in_unsafe_fn = "warn" +unused_crate_dependencies = "warn" +unused_import_braces = "warn" +unused_lifetimes = "warn" +unused_qualifications = "warn" +variant_size_differences = "warn" + +[lints.rustdoc] +# rustdoc lints https://doc.rust-lang.org/rustdoc/lints.html +broken_intra_doc_links = "warn" +private_intra_doc_links = "warn" +missing_crate_level_docs = "warn" +private_doc_tests = "warn" +invalid_codeblock_attributes = "warn" +invalid_rust_codeblocks = "warn" +bare_urls = "warn" + +[lints.clippy] +# clippy allowed by default +dbg_macro = "warn" +# clippy categories https://doc.rust-lang.org/clippy/ +all = { level = "warn", priority = -1 } +correctness = { level = "warn", priority = -1 } +suspicious = { level = "warn", priority = -1 } +style = { level = "warn", priority = -1 } +complexity = { level = "warn", priority = -1 } +perf = { level = "warn", priority = -1 } +pedantic = { level = "warn", priority = -1 } +missing_panics_doc = "allow" +missing_errors_doc = "allow" diff --git a/pkgs/by-name/ts/tskm/flake.lock b/pkgs/by-name/ts/tskm/flake.lock new file mode 100644 index 00000000..d5cbe443 --- /dev/null +++ b/pkgs/by-name/ts/tskm/flake.lock @@ -0,0 +1,27 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1744536153, + "narHash": "sha256-awS2zRgF4uTwrOKwwiJcByDzDOdo3Q1rPZbiHQg/N38=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "18dd725c29603f582cf1900e0d25f9f1063dbf11", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/pkgs/by-name/ts/tskm/flake.nix b/pkgs/by-name/ts/tskm/flake.nix new file mode 100644 index 00000000..5a5f628b --- /dev/null +++ b/pkgs/by-name/ts/tskm/flake.nix @@ -0,0 +1,29 @@ +{ + description = "This is the core interface to the system-integrated task management"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + }; + + outputs = {nixpkgs, ...}: let + system = "x86_64-linux"; + pkgs = nixpkgs.legacyPackages."${system}"; + in { + devShells."${system}".default = pkgs.mkShell { + buildInputs = [ + pkgs.sqlite + ]; + + packages = with pkgs; [ + cargo + clippy + rustc + rustfmt + + cargo-edit + ]; + }; + }; +} +# vim: ts=2 + diff --git a/pkgs/by-name/ts/tskm/package.nix b/pkgs/by-name/ts/tskm/package.nix new file mode 100644 index 00000000..71ef7ed6 --- /dev/null +++ b/pkgs/by-name/ts/tskm/package.nix @@ -0,0 +1,49 @@ +{ + rustPlatform, + installShellFiles, + makeWrapper, + lib, + # Dependencies + taskwarrior3, + git, + rofi, + firefox, + sqlite, +}: +rustPlatform.buildRustPackage (finalAttrs: { + pname = "tskm"; + version = "0.1.0"; + + src = ./.; + cargoLock = { + lockFile = ./Cargo.lock; + }; + + buildInputs = [ + taskwarrior3 + git + rofi + firefox + sqlite + ]; + + nativeBuildInputs = [ + installShellFiles + makeWrapper + ]; + + postInstall = '' + installShellCompletion --cmd tskm \ + --bash <(COMPLETE=bash $out/bin/tskm) \ + --fish <(COMPLETE=fish $out/bin/tskm) \ + --zsh <(COMPLETE=zsh $out/bin/tskm) + + # NOTE: We cannot clear the path, because we need access to the $EDITOR. <2025-04-04> + wrapProgram $out/bin/tskm \ + --prefix PATH : ${lib.makeBinPath finalAttrs.buildInputs} + ''; + + meta = { + mainProgram = "tskm"; + }; +}) diff --git a/pkgs/by-name/ts/tskm/src/cli.rs b/pkgs/by-name/ts/tskm/src/cli.rs new file mode 100644 index 00000000..c1eba387 --- /dev/null +++ b/pkgs/by-name/ts/tskm/src/cli.rs @@ -0,0 +1,266 @@ +use std::{ffi::OsStr, path::PathBuf}; + +use anyhow::{bail, Result}; +use clap::{builder::StyledStr, ArgAction, Parser, Subcommand}; +use clap_complete::{ArgValueCompleter, CompletionCandidate}; +use url::Url; + +use crate::{ + interface::{input::Input, project::ProjectName}, + state, task, +}; + +#[derive(Parser, Debug)] +#[command(author, version, about, long_about, verbatim_doc_comment)] +/// This is the core interface to the system-integrated task management +/// +/// `tskm` effectively combines multiple applications together: +/// - `taskwarrior` projects are raised connected to `firefox` profiles, making it possible to “open” +/// a project. +/// +/// - Every `taskwarrior` project has a determined `neorg` path, so that extra information for a +/// `project` can be stored in this `norg` file. +/// +/// - `tskm` can track inputs for you. These are URLs with optional tags which you can that +/// “review” to open tasks based on them. +pub struct CliArgs { + #[command(subcommand)] + pub command: Command, + + /// Increase message verbosity + #[arg(long="verbose", short = 'v', action = ArgAction::Count, default_value_t = 2)] + pub verbosity: u8, + + /// Silence all output + #[arg(long, short = 'q')] + pub quiet: bool, +} + +#[derive(Subcommand, Debug)] +pub enum Command { + /// Interact with projects. + Projects { + #[command(subcommand)] + command: ProjectCommand, + }, + + /// Manage the input queue. + Inputs { + #[command(subcommand)] + command: InputCommand, + }, + + /// Access the associated `neorg` workspace for the project/task. + Neorg { + #[command(subcommand)] + command: NeorgCommand, + }, + + /// Interface with the Firefox profile of each project. + Open { + #[command(subcommand)] + command: OpenCommand, + }, +} + +#[derive(Subcommand, Debug)] +pub enum ProjectCommand { + /// Lists all available projects. + List, + + /// Allows you to quickly add projects. + Add { + /// The name of the new project. + #[arg(value_parser = ProjectName::try_from_project)] + new_project_name: ProjectName, + }, +} + +#[derive(Subcommand, Debug, Clone, Copy)] +pub enum NeorgCommand { + /// Open the `neorg` project associated with id of the task. + Task { + /// The working set id of the task + #[arg(value_parser = task_from_working_set_id, add = ArgValueCompleter::new(complete_task_id))] + id: task::Task, + }, +} + +fn task_from_working_set_id(id: &str) -> Result<task::Task> { + let id: usize = id.parse()?; + let mut state = state::State::new_ro()?; + + let Some(task) = task::Task::from_working_set(id, &mut state)? else { + bail!("Working set id '{id}' is not valid!") + }; + Ok(task) +} + +#[derive(Subcommand, Debug)] +pub enum OpenCommand { + /// Open each project's Firefox profile consecutively, that was opened since the last review. + /// + /// This allows you to remove stale opened tabs and to commit open tabs to the `inputs`. + Review, + + /// Opens Firefox with either the supplied project or the currently active project profile. + Project { + /// The project to open. + #[arg(value_parser = task::Project::from_project_string, add = ArgValueCompleter::new(complete_project))] + project: task::Project, + + /// The URL to open. + url: Option<Url>, + }, + + /// Open a selected project in it's Firefox profile. + /// + /// This will use rofi's dmenu mode to select one project from the list of all registered + /// projects. + Select { + /// The URL to open. + url: Option<Url>, + }, + + /// List all open tabs in the project. + ListTabs { + /// The project to open. + #[arg(value_parser = task::Project::from_project_string, add = ArgValueCompleter::new(complete_project))] + project: Option<task::Project>, + }, +} + +#[derive(Subcommand, Debug)] +pub enum InputCommand { + /// Add URLs as inputs to be categorized. + Add { inputs: Vec<Input> }, + /// Remove URLs + Remove { + #[arg(add = ArgValueCompleter::new(complete_input_url))] + inputs: Vec<Input>, + }, + + /// Add all URLs in the file as inputs to be categorized. + /// + /// This expects each line to contain one URL. + File { file: PathBuf }, + + /// Like 'review', but for the inputs that have previously been added. + /// It takes a project in which to open the URLs. + Review { + /// Opens all the URLs in this project. + #[arg(value_parser = task::Project::from_project_string, add = ArgValueCompleter::new(complete_project))] + project: task::Project, + }, + + /// List all the previously added inputs. + List, +} + +fn complete_task_id(current: &OsStr) -> Vec<CompletionCandidate> { + fn format_task( + task: task::Task, + current: &str, + state: &mut state::State, + ) -> Option<CompletionCandidate> { + let id = { + let Ok(base) = task.working_set_id(state) else { + return None; + }; + base.to_string() + }; + + if !id.starts_with(current) { + return None; + } + + let description = { + let Ok(base) = task.description(state) else { + return None; + }; + StyledStr::from(base) + }; + + Some(CompletionCandidate::new(id).help(Some(description))) + } + + let mut output = vec![]; + + let Some(current) = current.to_str() else { + return output; + }; + + let Ok(mut state) = state::State::new_ro() else { + return output; + }; + + let Ok(pending) = state.replica().pending_tasks() else { + return output; + }; + + let Ok(current_project) = task::Project::get_current() else { + return output; + }; + + if let Some(current_project) = current_project { + for t in pending { + let task = task::Task::from(&t); + if let Ok(project) = task.project(&mut state) { + if project == current_project { + if let Some(out) = format_task(task, current, &mut state) { + output.push(out); + } else { + continue; + } + } + } + } + } else { + for t in pending { + let task = task::Task::from(&t); + if let Some(out) = format_task(task, current, &mut state) { + output.push(out); + } + } + } + + output +} +fn complete_project(current: &OsStr) -> Vec<CompletionCandidate> { + let mut output = vec![]; + + let Some(current) = current.to_str() else { + return output; + }; + + let Ok(all) = task::Project::all() else { + return output; + }; + + for a in all { + if a.to_project_display().starts_with(current) { + output.push(CompletionCandidate::new(a.to_project_display())); + } + } + + output +} +fn complete_input_url(current: &OsStr) -> Vec<CompletionCandidate> { + let mut output = vec![]; + + let Some(current) = current.to_str() else { + return output; + }; + + let Ok(all) = Input::all() else { + return output; + }; + + for a in all { + if a.to_string().starts_with(current) { + output.push(CompletionCandidate::new(a.to_string())); + } + } + + output +} diff --git a/pkgs/by-name/ts/tskm/src/interface/input/handle.rs b/pkgs/by-name/ts/tskm/src/interface/input/handle.rs new file mode 100644 index 00000000..0ff0e56e --- /dev/null +++ b/pkgs/by-name/ts/tskm/src/interface/input/handle.rs @@ -0,0 +1,112 @@ +use std::{ + fs, process, + str::FromStr, + thread::{self, sleep}, + time::Duration, +}; + +use anyhow::{Context, Result}; +use log::{error, info}; + +use crate::cli::InputCommand; + +use super::Input; + +/// # Errors +/// When command handling fails. +/// +/// # Panics +/// When internal assertions fail. +pub fn handle(command: InputCommand) -> Result<()> { + match command { + InputCommand::Add { inputs } => { + for input in inputs { + input.commit().with_context(|| { + format!("Failed to add input ('{input}') to the input storage.") + })?; + } + } + InputCommand::Remove { inputs } => { + for input in inputs { + input.remove().with_context(|| { + format!("Failed to remove input ('{input}') from the input storage.") + })?; + } + } + InputCommand::File { file } => { + let file = fs::read_to_string(file)?; + for line in file.lines() { + let input = Input::from_str(line)?; + input.commit().with_context(|| { + format!("Failed to add input ('{input}') to the input storage.") + })?; + } + } + InputCommand::Review { project } => { + let project = project.to_project_display(); + + let local_project = project.clone(); + let handle = thread::spawn(move || { + // We assume that the project is not yet open. + let mut firefox = process::Command::new("firefox") + .args(["-P", local_project.as_str(), "about:newtab"]) + .spawn()?; + + Ok::<_, anyhow::Error>(firefox.wait()?) + }); + // Give Firefox some time to start. + info!("Waiting on firefox to start"); + sleep(Duration::from_secs(4)); + + let project_str = project.as_str(); + 'outer: for all in Input::all()?.chunks(100) { + info!("Starting review for the first hundred URLs."); + + for input in all { + info!("-> '{input}'"); + let status = process::Command::new("firefox") + .args(["-P", project_str, input.url().to_string().as_str()]) + .status()?; + + if status.success() { + input.remove()?; + } else { + error!("Adding `{input}` to Firefox failed!"); + } + } + + { + use std::io::{stdin, stdout, Write}; + + let mut s = String::new(); + eprint!("Continue? (y/N) "); + stdout().flush()?; + + stdin() + .read_line(&mut s) + .expect("Did not enter a correct string"); + + if let Some('\n') = s.chars().next_back() { + s.pop(); + } + if let Some('\r') = s.chars().next_back() { + s.pop(); + } + + if s != "y" { + break 'outer; + } + } + } + + info!("Waiting for firefox to stop"); + handle.join().expect("Should be joinable")?; + } + InputCommand::List => { + for url in Input::all()? { + println!("{url}"); + } + } + } + Ok(()) +} diff --git a/pkgs/by-name/ts/tskm/src/interface/input/mod.rs b/pkgs/by-name/ts/tskm/src/interface/input/mod.rs new file mode 100644 index 00000000..9ece7a3a --- /dev/null +++ b/pkgs/by-name/ts/tskm/src/interface/input/mod.rs @@ -0,0 +1,257 @@ +use std::{ + collections::HashSet, + fmt::Display, + fs::{self, read_to_string, File}, + io::Write, + path::PathBuf, + process::Command, + str::FromStr, +}; + +use anyhow::{bail, Context, Result}; +use url::Url; +use walkdir::WalkDir; + +pub mod handle; +pub use handle::handle; + +#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] +pub struct NoWhitespaceString(String); + +impl NoWhitespaceString { + /// # Panics + /// If the input contains whitespace. + #[must_use] + pub fn new(input: String) -> Self { + if input.contains(' ') { + panic!("Your input '{input}' contains whitespace. I did not expect that.") + } else { + Self(input) + } + } +} + +impl Display for NoWhitespaceString { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + self.0.fmt(f) + } +} + +impl NoWhitespaceString { + #[must_use] + pub fn as_str(&self) -> &str { + &self.0 + } +} + +#[derive(Debug, Clone)] +pub struct Input { + url: Url, + tags: HashSet<NoWhitespaceString>, +} + +impl FromStr for Input { + type Err = anyhow::Error; + + fn from_str(s: &str) -> std::result::Result<Self, Self::Err> { + if s.contains(' ') { + let (url, tags) = s.split_once(' ').expect("Should work"); + Ok(Self { + url: Url::from_str(url)?, + tags: { + tags.trim() + .split(' ') + .map(|tag| { + if let Some(tag) = tag.strip_prefix('+') { + Ok(NoWhitespaceString::new(tag.to_owned())) + } else { + bail!("Your tag '{tag}' does not start with the required '+'"); + } + }) + .collect::<Result<_, _>>()? + }, + }) + } else { + Ok(Self { + url: Url::from_str(s)?, + tags: HashSet::new(), + }) + } + } +} + +impl Display for Input { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + if self.tags.is_empty() { + self.url.fmt(f) + } else { + write!( + f, + "{} {}", + self.url, + self.tags + .iter() + .fold(String::new(), |mut acc, tag| { + acc.push('+'); + acc.push_str(tag.as_str()); + acc.push(' '); + acc + }) + .trim() + ) + } + } +} + +impl Input { + fn base_path() -> PathBuf { + dirs::data_local_dir() + .expect("This should be set") + .join("tskm/inputs") + } + + fn url_path(url: &Url) -> Result<PathBuf> { + let base_path = Self::base_path(); + + let url_path = base_path.join(url.to_string()); + fs::create_dir_all(&url_path) + .with_context(|| format!("Failed to open file: '{}'", url_path.display()))?; + + Ok(url_path.join("url_value")) + } + + #[must_use] + pub fn url(&self) -> &Url { + &self.url + } + + /// Commit this constructed [`Input`] to storage. + /// + /// # Errors + /// If IO operations fail. + pub fn commit(&self) -> Result<()> { + let url_path = Self::url_path(&self.url)?; + + let url_content = { + if url_path.exists() { + read_to_string(&url_path)? + } else { + String::new() + } + }; + + let mut file = File::create(&url_path) + .with_context(|| format!("Failed to open file: '{}'", url_path.display()))?; + writeln!(file, "{url_content}{self}")?; + + Self::git_commit(&format!("Add new url: '{self}'"))?; + + Ok(()) + } + + /// Remove this constructed [`Input`] to storage. + /// + /// Beware that this does not take tags into account. + /// + /// # Errors + /// If IO operations fail. + pub fn remove(&self) -> Result<()> { + let url_path = Self::url_path(&self.url)?; + + fs::remove_file(&url_path) + .with_context(|| format!("Failed to remove file: '{}'", url_path.display()))?; + + let mut url_path = url_path.as_path(); + while let Some(parent) = url_path.parent() { + if fs::read_dir(parent)?.count() == 0 { + fs::remove_dir(parent)?; + } + url_path = parent; + } + + Self::git_commit(&format!("Remove url: '{self}'"))?; + Ok(()) + } + + /// Commit your changes + fn git_commit(message: &str) -> Result<()> { + let status = Command::new("git") + .args(["add", "."]) + .current_dir(Self::base_path()) + .status()?; + if !status.success() { + bail!("Git add . failed!"); + } + + let status = Command::new("git") + .args(["commit", "--message", message, "--no-gpg-sign"]) + .current_dir(Self::base_path()) + .status()?; + if !status.success() { + bail!("Git commit failed!"); + } + + Ok(()) + } + + /// Get all previously [`Self::commit`]ed inputs. + /// + /// # Errors + /// When IO handling fails. + /// + /// # Panics + /// If internal assertions fail. + pub fn all() -> Result<Vec<Self>> { + let mut output = vec![]; + for entry in WalkDir::new(Self::base_path()) + .min_depth(1) + .into_iter() + .filter_entry(|e| { + let s = e.file_name().to_str(); + s != Some(".git") + }) + { + let entry = entry?; + + if !entry.file_type().is_file() { + continue; + } + + let url_value_file = entry + .path() + .to_str() + .expect("All of these should be URLs and thus valid strings"); + assert!(url_value_file.ends_with("/url_value")); + + let url = { + let base = url_value_file + .strip_prefix(&format!("{}/", Self::base_path().display())) + .expect("This will exist"); + + let (proto, path) = base.split_once(':').expect("This will countain a :"); + + let path = path.strip_suffix("/url_value").expect("Will exist"); + + Url::from_str(&format!("{proto}:/{path}")) + .expect("This was a URL, it should still be one") + }; + let tags = { + let url_values = read_to_string(PathBuf::from(url_value_file))?; + url_values + .lines() + .map(|line| { + let input = Self::from_str(line)?; + Ok::<_, anyhow::Error>(input.tags) + }) + .collect::<Result<Vec<HashSet<NoWhitespaceString>>, _>>()? + .into_iter() + .flatten() + .collect() + }; + + output.push(Self { url, tags }); + } + + Ok(output) + } +} diff --git a/pkgs/by-name/ts/tskm/src/interface/mod.rs b/pkgs/by-name/ts/tskm/src/interface/mod.rs new file mode 100644 index 00000000..1a0d934c --- /dev/null +++ b/pkgs/by-name/ts/tskm/src/interface/mod.rs @@ -0,0 +1,4 @@ +pub mod input; +pub mod neorg; +pub mod open; +pub mod project; diff --git a/pkgs/by-name/ts/tskm/src/interface/neorg/handle.rs b/pkgs/by-name/ts/tskm/src/interface/neorg/handle.rs new file mode 100644 index 00000000..d904b12e --- /dev/null +++ b/pkgs/by-name/ts/tskm/src/interface/neorg/handle.rs @@ -0,0 +1,88 @@ +use std::{ + env, + fs::{self, read_to_string, File, OpenOptions}, + io::Write, + process::Command, +}; + +use anyhow::{bail, Context, Result}; + +use crate::{cli::NeorgCommand, state::State}; + +pub fn handle(command: NeorgCommand, state: &mut State) -> Result<()> { + match command { + NeorgCommand::Task { id } => { + let project = id.project(state)?; + let base = dirs::data_local_dir() + .expect("This should exists") + .join("tskm/notes"); + let path = base.join(project.get_neorg_path()?); + + fs::create_dir_all(path.parent().expect("This should exist"))?; + + { + let contents = if path.exists() { + read_to_string(&path) + .with_context(|| format!("Failed to read file: '{}'", path.display()))? + } else { + File::create(&path) + .with_context(|| format!("Failed to create file: '{}'", path.display()))?; + String::new() + }; + + if !contents.contains(format!("% {}", id.uuid()).as_str()) { + let mut options = OpenOptions::new(); + options.append(true).create(false); + + let mut file = options.open(&path)?; + file.write_all(format!("* TITLE (% {})", id.uuid()).as_bytes()) + .with_context(|| { + format!("Failed to write task uuid to file: '{}'", path.display()) + })?; + file.flush() + .with_context(|| format!("Failed to flush file: '{}'", path.display()))?; + } + } + + let editor = env::var("EDITOR").unwrap_or("nvim".to_owned()); + let status = Command::new(editor) + .args([ + path.to_str().expect("Should be a utf-8 str"), + "-c", + format!("/% {}", id.uuid()).as_str(), + ]) + .status()?; + if !status.success() { + bail!("$EDITOR fail with error code: {status}"); + } + + { + let status = Command::new("git") + .args(["add", "."]) + .current_dir(path.parent().expect("Will exist")) + .status()?; + if !status.success() { + bail!("Git add . failed!"); + } + + let status = Command::new("git") + .args([ + "commit", + "--message", + format!("chore({}): Update", project.get_neorg_path()?.display()).as_str(), + "--no-gpg-sign", + ]) + .current_dir(path.parent().expect("Will exist")) + .status()?; + if !status.success() { + bail!("Git commit failed!"); + } + } + + { + id.mark_neorg_data(state)?; + } + } + } + Ok(()) +} diff --git a/pkgs/by-name/ts/tskm/src/interface/neorg/mod.rs b/pkgs/by-name/ts/tskm/src/interface/neorg/mod.rs new file mode 100644 index 00000000..51d58ab3 --- /dev/null +++ b/pkgs/by-name/ts/tskm/src/interface/neorg/mod.rs @@ -0,0 +1,25 @@ +use std::path::PathBuf; + +use anyhow::Result; + +use crate::task::{run_task, Project}; + +pub mod handle; +pub use handle::handle; + +impl Project { + /// Return the stored neorg path of this project. + /// The returned path will never start with a slash (/). + pub(super) fn get_neorg_path(&self) -> Result<PathBuf> { + let project_path = run_task(&[ + "_get", + format!("rc.context.{}.rc.neorg_path", self.to_context_display()).as_str(), + ])?; + + let final_path = project_path + .strip_prefix('/') + .unwrap_or(project_path.as_str()); + + Ok(PathBuf::from(final_path)) + } +} diff --git a/pkgs/by-name/ts/tskm/src/interface/open/handle.rs b/pkgs/by-name/ts/tskm/src/interface/open/handle.rs new file mode 100644 index 00000000..4d7341b2 --- /dev/null +++ b/pkgs/by-name/ts/tskm/src/interface/open/handle.rs @@ -0,0 +1,232 @@ +use std::{ + fs, + net::{IpAddr, Ipv4Addr}, + path::PathBuf, + process, +}; + +use anyhow::{bail, Context, Result}; +use log::{error, info, warn}; +use url::Url; + +use crate::{cli::OpenCommand, rofi, state::State, task}; + +pub fn handle(command: OpenCommand, state: &mut State) -> Result<()> { + match command { + OpenCommand::Review => { + for project in task::Project::all().context("Failed to get all project files")? { + if project.is_touched() { + info!("Reviewing project: '{}'", project.to_project_display()); + open_in_browser(project, state, None).with_context(|| { + format!( + "Failed to open project ('{}') in Firefox", + project.to_project_display() + ) + })?; + project.untouch().with_context(|| { + format!( + "Failed to untouch project ('{}')", + project.to_project_display() + ) + })?; + } + } + } + OpenCommand::Project { project, url } => { + project.touch().context("Failed to touch project")?; + open_in_browser(&project, state, url).with_context(|| { + format!("Failed to open project: {}", project.to_project_display()) + })?; + } + OpenCommand::Select { url } => { + let selected_project: task::Project = task::Project::from_project_string( + &rofi::select( + task::Project::all() + .context("Failed to get all registered projects")? + .iter() + .map(task::Project::to_project_display) + .collect::<Vec<_>>() + .as_slice(), + ) + .context("Failed to get selected project")?, + ) + .expect("This should work, as we send only projects in"); + + selected_project + .touch() + .context("Failed to touch project")?; + + open_in_browser(&selected_project, state, url).context("Failed to open project")?; + } + OpenCommand::ListTabs { project } => { + let project = if let Some(p) = project { + p + } else if let Some(p) = + task::Project::get_current().context("Failed to get currently focused project")? + { + p + } else { + bail!("You need to either supply a project or have a project active!"); + }; + + let session_store = project.get_sessionstore().with_context(|| { + format!( + "Failed to get session store for project: '{}'", + project.to_project_display() + ) + })?; + + let selected = session_store + .windows + .iter() + .map(|w| w.selected) + .collect::<Vec<_>>(); + + let tabs = session_store + .windows + .iter() + .flat_map(|window| window.tabs.iter()) + .map(|tab| tab.entries.get(tab.index - 1).expect("This should be Some")) + .collect::<Vec<_>>(); + + for (index, entry) in tabs.iter().enumerate() { + let index = index + 1; + let is_selected = { + if selected.contains(&index) { + "🔻 " + } else { + " " + } + }; + println!("{}{}", is_selected, entry.url); + } + } + } + Ok(()) +} + +fn open_in_browser( + selected_project: &task::Project, + state: &mut State, + url: Option<Url>, +) -> Result<()> { + let old_project: Option<task::Project> = + task::Project::get_current().context("Failed to get currently active project")?; + let old_task: Option<task::Task> = + task::Task::get_current(state).context("Failed to get currently active task")?; + + selected_project.activate().with_context(|| { + format!( + "Failed to active project: '{}'", + selected_project.to_project_display() + ) + })?; + + let tracking_task = { + let all_tasks = selected_project.get_tasks(state).with_context(|| { + format!( + "Failed to get assoctiated tasks for project: '{}'", + selected_project.to_project_display() + ) + })?; + + let tracking_task = all_tasks.into_iter().find(|t| { + let maybe_desc = t.description(state); + if let Ok(desc) = maybe_desc { + desc == "tracking" + } else { + error!( + "Getting task description returned error: {}", + maybe_desc.expect_err("We already check for Ok") + ); + false + } + }); + + if let Some(task) = tracking_task { + info!( + "Starting task {} -> tracking", + selected_project.to_project_display() + ); + task.start(state) + .with_context(|| format!("Failed to start task {task}"))?; + } + tracking_task + }; + + let status = { + let mut args = vec!["-P".to_owned(), selected_project.to_project_display()]; + if let Some(url) = url { + args.push(url.to_string()); + } else { + let lock_file = dirs::home_dir() + .expect("Exists") + .join(".mozilla/firefox") + .join(selected_project.to_project_display()) + .join("lock"); + + if lock_file.exists() { + let (ip, pid): (IpAddr, u32) = { + let link = fs::read_link(&lock_file).with_context(|| { + format!("Failed to readlink lock at '{}'", lock_file.display()) + })?; + + let (ip, pid) = link + .to_str() + .expect("Should work") + .split_once(':') + .expect("The split works"); + + ( + ip.parse().expect("Should be a valid ip address"), + pid.parse().expect("Should be a valid pid"), + ) + }; + + if ip != Ipv4Addr::new(127, 0, 0, 2) { + warn!("Your ip is weird.."); + } + + if PathBuf::from("/proc").join(pid.to_string()).exists() { + // Another Firefox instance has already been started for this project + // Add a buffer URL to force Firefox to open it in the already open instance + args.push("about:newtab".to_owned()); + } else { + // This project does not yet have another Firefox instance + // We do not need to add anything to the arguments, Firefox will open a new + // instance. + } + } else { + // There is no lock file and thus no instance already open. + } + }; + + process::Command::new("firefox") + .args(args) + .status() + .context("Failed to start firefox")? + }; + + if !status.success() { + error!("Firefox run exited with error."); + } + + if let Some(task) = tracking_task { + task.stop(state) + .with_context(|| format!("Failed to stop task {task}"))?; + } + if let Some(task) = old_task { + task.start(state) + .with_context(|| format!("Failed to start task {task}"))?; + } + + if let Some(project) = old_project { + project.activate().with_context(|| { + format!("Failed to active project {}", project.to_project_display()) + })?; + } else { + task::Project::clear().context("Failed to clear currently focused project")?; + } + + Ok(()) +} diff --git a/pkgs/by-name/ts/tskm/src/interface/open/mod.rs b/pkgs/by-name/ts/tskm/src/interface/open/mod.rs new file mode 100644 index 00000000..2dc75957 --- /dev/null +++ b/pkgs/by-name/ts/tskm/src/interface/open/mod.rs @@ -0,0 +1,106 @@ +use std::{collections::HashMap, fs::File, io}; + +use anyhow::{Context, Result}; +use lz4_flex::decompress_size_prepended; +use serde::Deserialize; +use serde_json::Value; +use url::Url; + +use crate::task::Project; + +pub mod handle; +pub use handle::handle; + +impl Project { + pub(super) fn get_sessionstore(&self) -> Result<SessionStore> { + let path = dirs::home_dir() + .expect("Will exist") + .join(".mozilla/firefox") + .join(self.to_project_display()) + .join("sessionstore-backups/recovery.jsonlz4"); + let file = decompress_mozlz4( + File::open(&path) + .with_context(|| format!("Failed to open path '{}'", path.display()))?, + ) + .with_context(|| format!("Failed to decompress file as mozlzh '{}'", path.display()))?; + + let contents: SessionStore = serde_json::from_str(&file).with_context(|| { + format!( + "Failed to deserialize file ('{}') as session store.", + path.display() + ) + })?; + Ok(contents) + } +} + +fn decompress_mozlz4<P: io::Read>(mut file: P) -> Result<String> { + const MOZLZ4_MAGIC_NUMBER: &[u8] = b"mozLz40\0"; + + let mut buf = [0u8; 8]; + file.read_exact(&mut buf) + .context("Failed to read the mozlz40 header.")?; + + assert_eq!(buf, MOZLZ4_MAGIC_NUMBER); + + let mut buf = vec![]; + file.read_to_end(&mut buf).context("Failed to read file")?; + + let uncompressed = decompress_size_prepended(&buf).context("Failed to decompress file")?; + + Ok(String::from_utf8(uncompressed).expect("This should be valid json and thus utf8")) +} + +#[derive(Deserialize, Debug)] +pub struct SessionStore { + pub windows: Vec<Window>, +} + +#[derive(Deserialize, Debug)] +pub struct Window { + pub tabs: Vec<Tab>, + pub selected: usize, +} + +#[derive(Deserialize, Debug)] +pub struct Tab { + pub entries: Vec<TabEntry>, + #[serde(rename = "lastAccessed")] + pub last_accessed: u64, + pub hidden: bool, + #[serde(rename = "searchMode")] + pub search_mode: Option<Value>, + #[serde(rename = "userContextId")] + pub user_context_id: u32, + pub attributes: TabAttributes, + #[serde(rename = "extData")] + pub ext_data: Option<HashMap<String, Value>>, + pub index: usize, + #[serde(rename = "requestedIndex")] + pub requested_index: Option<u32>, + pub image: Option<Url>, +} + +#[derive(Deserialize, Debug)] +pub struct TabEntry { + pub url: Url, + pub title: String, + #[serde(rename = "cacheKey")] + pub cache_key: u32, + #[serde(rename = "ID")] + pub id: u32, + #[serde(rename = "docshellUUID")] + pub docshell_uuid: Value, + #[serde(rename = "resultPrincipalURI")] + pub result_principal_uri: Option<Url>, + #[serde(rename = "hasUserInteraction")] + pub has_user_interaction: bool, + #[serde(rename = "triggeringPrincipal_base64")] + pub triggering_principal_base64: Value, + #[serde(rename = "docIdentifier")] + pub doc_identifier: u32, + pub persist: bool, +} + +#[derive(Deserialize, Debug, Clone, Copy)] +pub struct TabAttributes {} diff --git a/pkgs/by-name/ts/tskm/src/interface/project/handle.rs b/pkgs/by-name/ts/tskm/src/interface/project/handle.rs new file mode 100644 index 00000000..2b01f5d1 --- /dev/null +++ b/pkgs/by-name/ts/tskm/src/interface/project/handle.rs @@ -0,0 +1,87 @@ +use std::{env, fs::File, io::Write}; + +use anyhow::{anyhow, Context, Result}; +use log::trace; + +use crate::{cli::ProjectCommand, task}; + +use super::{ProjectDefinition, ProjectList, SortAlphabetically}; + +/// # Panics +/// If internal expectations fail. +/// +/// # Errors +/// If IO operations fail. +pub fn handle(command: ProjectCommand) -> Result<()> { + match command { + ProjectCommand::List => { + for project in task::Project::all()? { + println!("{}", project.to_project_display()); + } + } + ProjectCommand::Add { + mut new_project_name, + } => { + let project_file = env::var("TSKM_PROJECT_FILE") + .map_err(|err| anyhow!("The `TSKM_PROJECT_FILE` env var is unset: {err}"))?; + + let mut projects_content: ProjectList = + serde_json::from_reader(File::open(&project_file).with_context(|| { + format!("Failed to open project file ('{project_file:?}') for reading") + })?)?; + + let first = new_project_name.project_segments.remove(0); + if let Some(mut definition) = projects_content.0.get_mut(&first) { + for segment in new_project_name.project_segments { + if definition.subprojects.contains_key(&segment) { + definition = definition + .subprojects + .get_mut(&segment) + .expect("We checked"); + } else { + let new_definition = ProjectDefinition::default(); + let output = definition + .subprojects + .insert(segment.clone(), new_definition); + + assert_eq!(output, None); + + definition = definition + .subprojects + .get_mut(&segment) + .expect("Was just inserted"); + } + } + } else { + let mut orig_definition = ProjectDefinition::default(); + let mut definition = &mut orig_definition; + for segment in new_project_name.project_segments { + trace!("Adding segment: {segment}"); + + let new_definition = ProjectDefinition::default(); + + assert!(definition + .subprojects + .insert(segment.clone(), new_definition) + .is_none()); + + definition = definition + .subprojects + .get_mut(&segment) + .expect("Was just inserted"); + } + assert!(projects_content.0.insert(first, orig_definition).is_none()); + }; + + let mut file = File::create(&project_file).with_context(|| { + format!("Failed to open project file ('{project_file:?}') for writing") + })?; + serde_json::to_writer_pretty( + &file, + &SortAlphabetically::<ProjectList>(projects_content), + )?; + writeln!(file)?; + } + } + Ok(()) +} diff --git a/pkgs/by-name/ts/tskm/src/interface/project/mod.rs b/pkgs/by-name/ts/tskm/src/interface/project/mod.rs new file mode 100644 index 00000000..62069746 --- /dev/null +++ b/pkgs/by-name/ts/tskm/src/interface/project/mod.rs @@ -0,0 +1,73 @@ +use std::collections::HashMap; + +use anyhow::Result; +use serde::{Deserialize, Serialize}; + +pub mod handle; +pub use handle::handle; + +#[derive(Deserialize, Serialize)] +struct ProjectList(HashMap<String, ProjectDefinition>); + +#[derive(Debug, Clone, PartialEq, Eq, Deserialize, Serialize, Default)] +struct ProjectDefinition { + #[serde(default)] + #[serde(skip_serializing_if = "is_default")] + name: String, + + #[serde(default)] + #[serde(skip_serializing_if = "is_default")] + prefix: String, + + #[serde(default)] + #[serde(skip_serializing_if = "is_default")] + subprojects: HashMap<String, ProjectDefinition>, +} + +fn is_default<T: Default + PartialEq>(input: &T) -> bool { + input == &T::default() +} + +#[derive(Debug, Clone)] +pub struct ProjectName { + project_segments: Vec<String>, +} + +impl ProjectName { + #[must_use] + pub fn segments(&self) -> &[String] { + &self.project_segments + } + + /// # Errors + /// Never. + pub fn try_from_project(s: &str) -> Result<Self> { + Ok(Self::from_project(s)) + } + pub fn from_project(s: &str) -> Self { + let me = Self { + project_segments: s.split('.').map(ToOwned::to_owned).collect(), + }; + me + } + pub fn from_context(s: &str) -> Self { + let me = Self { + project_segments: s.split('_').map(ToOwned::to_owned).collect(), + }; + me + } +} + +// Source: https://stackoverflow.com/a/67792465 +fn sort_alphabetically<T: Serialize, S: serde::Serializer>( + value: &T, + serializer: S, +) -> Result<S::Ok, S::Error> { + let value = serde_json::to_value(value).map_err(serde::ser::Error::custom)?; + value.serialize(serializer) +} + +#[derive(Serialize)] +pub(super) struct SortAlphabetically<T: Serialize>( + #[serde(serialize_with = "sort_alphabetically")] T, +); diff --git a/pkgs/by-name/ts/tskm/src/main.rs b/pkgs/by-name/ts/tskm/src/main.rs new file mode 100644 index 00000000..77f2dcca --- /dev/null +++ b/pkgs/by-name/ts/tskm/src/main.rs @@ -0,0 +1,41 @@ +use anyhow::Result; +use clap::{CommandFactory, Parser}; + +use crate::{ + cli::{CliArgs, Command}, + interface::{input, neorg, open, project}, + state::State, +}; + +pub mod cli; +pub mod interface; +pub mod rofi; +pub mod state; +pub mod task; + +fn main() -> Result<(), anyhow::Error> { + clap_complete::CompleteEnv::with_factory(CliArgs::command).complete(); + + let args = CliArgs::parse(); + + stderrlog::new() + .module(module_path!()) + .quiet(args.quiet) + .show_module_names(true) + .color(stderrlog::ColorChoice::Auto) + .verbosity(usize::from(args.verbosity)) + .timestamp(stderrlog::Timestamp::Off) + .init() + .expect("Let's just hope that this does not panic"); + + let mut state = State::new_rw()?; + + match args.command { + Command::Inputs { command } => input::handle(command)?, + Command::Neorg { command } => neorg::handle(command, &mut state)?, + Command::Open { command } => open::handle(command, &mut state)?, + Command::Projects { command } => project::handle(command)?, + } + + Ok(()) +} diff --git a/pkgs/by-name/ts/tskm/src/rofi/mod.rs b/pkgs/by-name/ts/tskm/src/rofi/mod.rs new file mode 100644 index 00000000..a0591b7f --- /dev/null +++ b/pkgs/by-name/ts/tskm/src/rofi/mod.rs @@ -0,0 +1,37 @@ +use std::{ + io::Write, + process::{Command, Stdio}, +}; + +use anyhow::{Context, Result}; + +pub fn select(options: &[String]) -> Result<String> { + let mut child = Command::new("rofi") + .args(["-sep", "\n", "-dmenu"]) + .stdin(Stdio::piped()) + .stdout(Stdio::piped()) + .spawn() + .context("Failed to spawn rofi")?; + + let mut stdin = child + .stdin + .take() + .expect("We piped this, so should be available"); + + stdin + .write_all(options.join("\n").as_bytes()) + .context("Failed to write to rofi's stdin")?; + + let output = child + .wait_with_output() + .context("Failed to wait for rofi's output")?; + + let selected = String::from_utf8(output.stdout.clone()).with_context(|| { + format!( + "Failed to decode '{}' as utf8", + String::from_utf8_lossy(&output.stdout) + ) + })?; + + Ok(selected.trim_end().to_owned()) +} diff --git a/pkgs/by-name/ts/tskm/src/state.rs b/pkgs/by-name/ts/tskm/src/state.rs new file mode 100644 index 00000000..175a7f03 --- /dev/null +++ b/pkgs/by-name/ts/tskm/src/state.rs @@ -0,0 +1,45 @@ +use std::path::PathBuf; + +use anyhow::Result; +use taskchampion::{storage::AccessMode, Replica, StorageConfig}; + +pub struct State { + replica: Replica, +} + +impl std::fmt::Debug for State { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "State") + } +} + +impl State { + fn taskdb_dir() -> PathBuf { + dirs::data_local_dir().expect("Should exist").join("task") + } + + fn new(taskdb_dir: PathBuf, access_mode: AccessMode) -> Result<Self> { + let storage = StorageConfig::OnDisk { + taskdb_dir, + create_if_missing: false, + access_mode, + } + .into_storage()?; + + let replica = Replica::new(storage); + + Ok(Self { replica }) + } + + pub fn new_ro() -> Result<Self> { + Self::new(Self::taskdb_dir(), AccessMode::ReadOnly) + } + pub fn new_rw() -> Result<Self> { + Self::new(Self::taskdb_dir(), AccessMode::ReadWrite) + } + + #[must_use] + pub fn replica(&mut self) -> &mut Replica { + &mut self.replica + } +} diff --git a/pkgs/by-name/ts/tskm/src/task/mod.rs b/pkgs/by-name/ts/tskm/src/task/mod.rs new file mode 100644 index 00000000..989f273a --- /dev/null +++ b/pkgs/by-name/ts/tskm/src/task/mod.rs @@ -0,0 +1,350 @@ +use std::{ + fmt::Display, + fs::{self, read_to_string, File}, + path::PathBuf, + process::Command, + str::FromStr, + sync::OnceLock, +}; + +use anyhow::{bail, Context, Result}; +use log::{debug, info, trace}; +use taskchampion::Tag; + +use crate::{interface::project::ProjectName, state::State}; + +/// The `taskwarrior` id of a task. +#[derive(Debug, Clone, Copy, PartialEq, PartialOrd, Ord, Eq)] +pub struct Task { + uuid: taskchampion::Uuid, +} + +impl From<&taskchampion::Task> for Task { + fn from(value: &taskchampion::Task) -> Self { + Self { + uuid: value.get_uuid(), + } + } +} +impl From<&taskchampion::TaskData> for Task { + fn from(value: &taskchampion::TaskData) -> Self { + Self { + uuid: value.get_uuid(), + } + } +} + +impl Task { + pub fn from_working_set(id: usize, state: &mut State) -> Result<Option<Self>> { + Ok(state + .replica() + .working_set()? + .by_index(id) + .map(|uuid| Self { uuid })) + } + + pub fn get_current(state: &mut State) -> Result<Option<Self>> { + let tasks = state + .replica() + .pending_tasks()? + .into_iter() + .filter(taskchampion::Task::is_active) + .collect::<Vec<_>>(); + + assert!( + tasks.len() <= 1, + "We have ensured that only one task may be active, via a hook" + ); + if let Some(active) = tasks.first() { + Ok(Some(Self::from(active))) + } else { + Ok(None) + } + } + + #[must_use] + pub fn uuid(&self) -> &taskchampion::Uuid { + &self.uuid + } + #[must_use] + pub fn working_set_id(&self, state: &mut State) -> Result<usize> { + Ok(state + .replica() + .working_set()? + .by_uuid(self.uuid) + .expect("The task should be in the working set")) + } + + fn as_task(&self, state: &mut State) -> Result<taskchampion::Task> { + Ok(state + .replica() + .get_task(self.uuid)? + .expect("We have the task from this replica, it should still be in it")) + } + + /// Adds a tag to the task, to show the user that it has additional neorg data. + pub fn mark_neorg_data(&self, state: &mut State) -> Result<()> { + let mut ops = vec![]; + self.as_task(state)? + .add_tag(&Tag::from_str("neorg_data").expect("Is valid"), &mut ops)?; + state.replica().commit_operations(ops)?; + Ok(()) + } + + /// Try to start this task. + /// It will stop previously active tasks. + pub fn start(&self, state: &mut State) -> Result<()> { + info!("Activating {self}"); + + if let Some(active) = Self::get_current(state)? { + active.stop(state)?; + } + + let mut ops = vec![]; + self.as_task(state)?.start(&mut ops)?; + state.replica().commit_operations(ops)?; + Ok(()) + } + + /// Stops this task. + pub fn stop(&self, state: &mut State) -> Result<()> { + info!("Stopping {self}"); + + let mut ops = vec![]; + self.as_task(state)?.stop(&mut ops)?; + state.replica().commit_operations(ops)?; + Ok(()) + } + + pub fn description(&self, state: &mut State) -> Result<String> { + Ok(self.as_task(state)?.get_description().to_owned()) + } + + pub fn project(&self, state: &mut State) -> Result<Project> { + let output = { + let task = self.as_task(state)?; + let task_data = task.into_task_data(); + task_data + .get("project") + .expect("Every task should have a project") + .to_owned() + }; + let project = Project::from_project_string(output.as_str().trim()) + .expect("This comes from tw, it should be valid"); + Ok(project) + } +} + +impl Display for Task { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + self.uuid.fmt(f) + } +} + +impl FromStr for Task { + type Err = anyhow::Error; + + fn from_str(s: &str) -> Result<Self, Self::Err> { + let uuid = taskchampion::Uuid::from_str(s)?; + Ok(Self { uuid }) + } +} + +/// A registered task Project +#[derive(Debug, Clone, PartialEq)] +pub struct Project { + /// The project name. + /// For example: + /// ```no_run + /// &["trinitrix", "testing", "infra"] + /// ``` + name: Vec<String>, +} + +static ALL_CACHE: OnceLock<Vec<Project>> = OnceLock::new(); +impl Project { + #[must_use] + pub fn to_project_display(&self) -> String { + self.name.join(".") + } + #[must_use] + pub fn to_context_display(&self) -> String { + self.name.join("_") + } + + /// # Errors + /// - When the string does not encode a previously registered project. + /// - When the string does not adhere to the project syntax. + pub fn from_project_string(s: &str) -> Result<Self> { + Self::from_input(s, ProjectName::from_project) + } + + /// # Errors + /// - When the string does not encode a previously registered project. + /// - When the string does not adhere to the context syntax. + pub fn from_context_string(s: &str) -> Result<Self> { + Self::from_input(s, ProjectName::from_context) + } + + fn from_input<F>(s: &str, f: F) -> Result<Self> + where + F: Fn(&str) -> ProjectName, + { + if s.is_empty() { + bail!("Your project is empty") + } + + let all = Self::all()?; + let me = Self::from_project_name_unchecked(&f(s)); + if all.contains(&me) { + Ok(me) + } else { + bail!( + "Your project '{}' is not registered!", + me.to_project_display() + ); + } + } + fn from_project_name_unchecked(pn: &ProjectName) -> Self { + Self { + name: pn.segments().to_owned(), + } + } + + /// Return all known valid projects. + /// + /// # Errors + /// When file operations fail. + /// + /// # Panics + /// Only when internal assertions fail. + pub fn all<'a>() -> Result<&'a [Project]> { + // Inlined from `OnceLock::get_or_try_init` + { + let this = &ALL_CACHE; + let f = || { + let file = dirs::config_local_dir() + .expect("Should be some") + .join("tskm/projects.list"); + let contents = read_to_string(&file) + .with_context(|| format!("Failed to read file: '{}'", file.display()))?; + + Ok::<_, anyhow::Error>( + contents + .lines() + .map(|s| Self::from_project_name_unchecked(&ProjectName::from_project(s))) + .collect::<Vec<_>>(), + ) + }; + + // Fast path check + // NOTE: We need to perform an acquire on the state in this method + // in order to correctly synchronize `LazyLock::force`. This is + // currently done by calling `self.get()`, which in turn calls + // `self.is_initialized()`, which in turn performs the acquire. + if let Some(value) = this.get() { + return Ok(value); + } + + this.set(f()?).expect( + "This should always be able to take our value, as we initialize only once.", + ); + + Ok(this.get().expect("This was initialized")) + } + } + + fn touch_dir(&self) -> PathBuf { + let lock_dir = dirs::data_dir() + .expect("Should be found") + .join("tskm/review"); + lock_dir.join(format!("{}.opened", self.to_project_display())) + } + + /// Mark this project as having been interacted with. + /// + /// # Errors + /// When IO operations fail. + pub fn touch(&self) -> Result<()> { + let lock_file = self.touch_dir(); + + File::create(&lock_file) + .with_context(|| format!("Failed to create lock_file at: {}", lock_file.display()))?; + + Ok(()) + } + /// Returns [`true`] if it was previously [`Self::touch`]ed. + #[must_use] + pub fn is_touched(&self) -> bool { + let lock_file = self.touch_dir(); + lock_file.exists() + } + /// Mark this project as having not been interacted with. + /// + /// # Errors + /// When IO operations fail. + pub fn untouch(&self) -> Result<()> { + let lock_file = self.touch_dir(); + + fs::remove_file(&lock_file) + .with_context(|| format!("Failed to create lock_file at: {}", lock_file.display()))?; + + Ok(()) + } + + /// # Errors + /// When `task` execution fails. + pub fn get_tasks(&self, state: &mut State) -> Result<Vec<Task>> { + Ok(state + .replica() + .pending_task_data()? + .into_iter() + .filter(|t| t.get("project").expect("Is set") == self.to_project_display()) + .map(|t| Task::from(&t)) + .collect()) + } + + /// # Errors + /// When `task` execution fails. + pub fn activate(&self) -> Result<()> { + debug!("Setting project {}", self.to_context_display()); + + run_task(&["context", self.to_context_display().as_str()]).map(|_| ()) + } + /// # Errors + /// When `task` execution fails. + pub fn clear() -> Result<()> { + debug!("Clearing active project"); + + run_task(&["context", "none"]).map(|_| ()) + } + + /// # Errors + /// When `task` execution fails. + pub fn get_current() -> Result<Option<Self>> { + let self_str = run_task(&["_get", "rc.context"])?; + + if self_str.is_empty() { + Ok(None) + } else { + Self::from_context_string(&self_str).map(Some) + } + } +} + +pub(crate) fn run_task(args: &[&str]) -> Result<String> { + debug!("Running task command: `task {}`", args.join(" ")); + + let output = Command::new("task") + .args(args) + .output() + .with_context(|| format!("Failed to run `task {}`", args.join(" ")))?; + + let stdout = String::from_utf8(output.stdout).context("Failed to read task output as utf8")?; + let stderr = String::from_utf8(output.stderr).context("Failed to read task output as utf8")?; + + trace!("Output (stdout): '{}'", stdout.trim()); + trace!("Output (stderr): '{}'", stderr.trim()); + + Ok(stdout.trim().to_owned()) +} diff --git a/pkgs/by-name/ts/tskm/update.sh b/pkgs/by-name/ts/tskm/update.sh new file mode 100755 index 00000000..9268caf2 --- /dev/null +++ b/pkgs/by-name/ts/tskm/update.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +cargo update && cargo upgrade diff --git a/pkgs/by-name/up/update-sys/update-sys.sh b/pkgs/by-name/up/update-sys/update-sys.sh deleted file mode 100755 index d28247f6..00000000 --- a/pkgs/by-name/up/update-sys/update-sys.sh +++ /dev/null @@ -1,85 +0,0 @@ -#!/usr/bin/env dash - -# shellcheck source=/dev/null -SHELL_LIBRARY_VERSION="2.1.2" . %SHELL_LIBRARY_PATH - -help() { - cat <<EOF -This is a NixOS System flake update manager. - -USAGE: - $NAME [--branch <branchname>] [--help] - -OPTIONS: - --branch | -b BRANCHNAME - select a branch to update from. - - --mode | -m MODE - select a mode to update with - - --help | -h - output this help. -ARGUMENTS: - BRANCHNAME := [[ git branch --list --format '%(refname:short)' ]] - The name of the branch to deploy the config from - - MODE := switch|boot|test|build|dry-build|dry-activate|edit|repl|build-vm|build-vm-with-bootloader - See the 'nixos-rebuild' manpage for more information about these modes. -EOF - exit "$1" -} -default_branch=$(mktmp) -BRANCH="" - -while [ "$#" -gt 0 ]; do - case "$1" in - "--help" | "-h") - help 0 - ;; - "--branch" | "-b") - if [ -n "$2" ]; then - BRANCH="$2" - else - error "$1 requires an argument" - help 1 - fi - shift 2 - ;; - "--mode" | "-m") - if [ -n "$2" ]; then - MODE="$2" - else - error "$1 requires an argument" - help 1 - fi - shift 2 - ;; - *) - error "the option $1 does not exist!" - help 1 - ;; - esac -done - -cd /etc/nixos || die "No /etc/nixos" -msg "Starting system update..." -git remote update origin --prune >/dev/null 2>&1 -if ! [ "$BRANCH" = "" ]; then - git switch "$BRANCH" >/dev/null 2>&1 && msg2 "Switched to branch '$BRANCH'" -fi -msg2 "Updating git repository..." -git pull --rebase - -git remote show origin | grep 'HEAD' | cut -d':' -f2 | sed -e 's/^ *//g' -e 's/ *$//g' >"$default_branch" & - -msg2 "Updating system..." -if [ -n "$MODE" ]; then - nixos-rebuild "$MODE" -else - nixos-rebuild switch -fi - -git switch "$(cat "$default_branch")" >/dev/null 2>&1 && msg2 "Switched to branch '$(cat "$default_branch")'" -msg "Finished Update!" - -# vim: ft=sh |