diff options
author | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2025-03-29 12:13:36 +0100 |
---|---|---|
committer | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2025-03-29 12:15:27 +0100 |
commit | 3d8beddc59f052dbd1e17323acf07a847d203bd4 (patch) | |
tree | e2f67478cf415a847a733ee8fcfe300c88713e97 | |
parent | fix(modules/legacy/conf/mail/git-credential-helper): Exit cleanly if password... (diff) | |
download | nixos-config-3d8beddc59f052dbd1e17323acf07a847d203bd4.zip |
refactor(pkgs/{yti,spodi,git-cleanup,nato,sort_song,virsh-del}): Remove
I have not used one of these commands in the last 8 months.
-rw-r--r-- | modules/home.legacy/pkgs/default.nix | 8 | ||||
-rwxr-xr-x | pkgs/by-name/gi/git-cleanup/git-cleanup.sh | 78 | ||||
-rw-r--r-- | pkgs/by-name/gi/git-cleanup/package.nix | 17 | ||||
-rwxr-xr-x | pkgs/by-name/na/nato/nato.py | 106 | ||||
-rw-r--r-- | pkgs/by-name/na/nato/package.nix | 34 | ||||
-rw-r--r-- | pkgs/by-name/so/sort_song/package.nix | 17 | ||||
-rwxr-xr-x | pkgs/by-name/so/sort_song/sort_song.sh | 34 | ||||
-rw-r--r-- | pkgs/by-name/sp/spodi/package.nix | 39 | ||||
-rwxr-xr-x | pkgs/by-name/sp/spodi/sh/download.sh | 58 | ||||
-rwxr-xr-x | pkgs/by-name/sp/spodi/sh/update.sh | 52 | ||||
-rwxr-xr-x | pkgs/by-name/sp/spodi/spodi.sh | 71 | ||||
-rw-r--r-- | pkgs/by-name/vi/virsh-del/package.nix | 13 | ||||
-rwxr-xr-x | pkgs/by-name/vi/virsh-del/virsh-del.sh | 10 | ||||
-rw-r--r-- | pkgs/by-name/yt/yti/package.nix | 17 | ||||
-rwxr-xr-x | pkgs/by-name/yt/yti/yti.sh | 33 |
15 files changed, 1 insertions, 586 deletions
diff --git a/modules/home.legacy/pkgs/default.nix b/modules/home.legacy/pkgs/default.nix index 1d77c7de..859aea36 100644 --- a/modules/home.legacy/pkgs/default.nix +++ b/modules/home.legacy/pkgs/default.nix @@ -55,8 +55,6 @@ with pkgs; let snap-sync-forked # A btrfs based backup solution bc # Smart calculator aumo # Automatic mount - nato # Encodes a string in the standardized spelling alphabet - virsh-del # Delete a libvirt virtual machine (not really used anymore). jq # Json parser ]; @@ -91,13 +89,10 @@ with pkgs; let ]; YouTube = [ - yti # Wrapper around `yt-dlp`. yt # A command line YouTube client ]; - Listen = [ - spodi # Wrapper around `spotdl`. - ]; + Listen = []; }; Hardware = { @@ -149,7 +144,6 @@ with pkgs; let git # the fast distributed version control system git-edit-index # Allows you to edit the indexed version of a file git-cm # A wrapper that re-adds the last commit's subject - git-cleanup # An automatic merged branch deleter glow # Command-line markdown renderer ]; }; diff --git a/pkgs/by-name/gi/git-cleanup/git-cleanup.sh b/pkgs/by-name/gi/git-cleanup/git-cleanup.sh deleted file mode 100755 index f423a9d2..00000000 --- a/pkgs/by-name/gi/git-cleanup/git-cleanup.sh +++ /dev/null @@ -1,78 +0,0 @@ -#!/usr/bin/env dash - -# shellcheck source=/dev/null -SHELL_LIBRARY_VERSION="2.1.2" . %SHELL_LIBRARY_PATH - -help() { - cat <<EOF -Automatically remove merged branches (remote and local) - -USAGE: - git-cleanup [OPTIONS] - -OPTIONS: - --remote | -r - Act on remote branches - - --help | -h - Display this help and exit. - - --version | -v - Display version and copyright information and exit. -EOF -} - -# This should always be the correct answer. -get_default_branch() { - # source: https://stackoverflow.com/a/50056710 - # We assume, that 'origin' is the remote in use - git remote show origin | sed -n '/HEAD branch/s|.*: ||p' -} - -cleanup() { - default_branch="$(get_default_branch)" - - merged_branches="$(git branch --merged "$default_branch" --no-contains "$default_branch" --format='%(refname:short)')" - - # shellcheck disable=2086 - # We expect the branches to not contain spaces and want git to deal with them - # separately - [ "$merged_branches" ] && git branch --delete $merged_branches -} -cleanup_remote() { - default_branch="$(get_default_branch)" - - merged_branches="$(git branch --remotes --merged "$default_branch" --no-contains "$default_branch" --format='%(refname:short)' | sed 's|origin/||')" - - # shellcheck disable=2086 - # We expect the branches to not contain spaces and want git to deal with them - # separately - [ "$merged_branches" ] && git push --delete origin $merged_branches -} - -remote=false -for arg in "$@"; do - case "$arg" in - "--help" | "-h") - help - exit 0 - ;; - "--version" | "-v") - version - exit 0 - ;; - "--remote" | "-r") - remote=true - ;; - esac -done - -if [ "$remote" = "true" ]; then - cleanup_remote -elif [ "$remote" = "false" ]; then - cleanup -else - die "BUG: 'remote' is not true or false but: '$remote'" -fi - -# vim: ft=sh diff --git a/pkgs/by-name/gi/git-cleanup/package.nix b/pkgs/by-name/gi/git-cleanup/package.nix deleted file mode 100644 index 54b3f2bd..00000000 --- a/pkgs/by-name/gi/git-cleanup/package.nix +++ /dev/null @@ -1,17 +0,0 @@ -{ - sysLib, - git, - gnused, - openssh, -}: -sysLib.writeShellScript { - name = "git-cleanup"; - src = ./git-cleanup.sh; - keepPath = false; - generateCompletions = true; - dependencies = [ - git - gnused - openssh - ]; -} diff --git a/pkgs/by-name/na/nato/nato.py b/pkgs/by-name/na/nato/nato.py deleted file mode 100755 index e9d15f56..00000000 --- a/pkgs/by-name/na/nato/nato.py +++ /dev/null @@ -1,106 +0,0 @@ -#!/usr/bin/env python3 -# originally from here: https://cgit.pacien.net/desktop-utilities/ - -import sys - -alphabet = { - "nato": { - "A": "Alfa", # No idea why this is not just 'Alpha' .. - "B": "Bravo", - "C": "Charlie", - "D": "Delta", - "E": "Echo", - "F": "Foxtrot", - "G": "Golf", - "H": "Hotel", - "I": "India", - "J": "Juliett", - "K": "Kilo", - "L": "Lima", - "M": "Mike", - "N": "November", - "O": "Oscar", - "P": "Papa", - "Q": "Quebec", - "R": "Romeo", - "S": "Sierra", - "T": "Tango", - "U": "Uniform", - "V": "Victor", - "W": "Whiskey", - "X": "X-ray", - "Y": "Yankee", - "Z": "Zulu", - "0": "Nadazero", - "1": "Unaone", - "2": "Bissotwo", - "3": "Terrathree", - "4": "Kartefour", - "5": "Pantafive", - "6": "Soxisix", - "7": "Setteseven", - "8": "Oktoeight", - "9": "Novenine", - ",": "Comma", - "/": "Forward slash", - ".": "Stop/Decimal", - }, - "german": { - "A": "Aachen", - "Ä": "Umlaut Aachen", - "B": "Berlin", - "C": "Chemnitz", - "D": "Düsseldorf", - "E": "Essen", - "F": "Frankfurt", - "G": "Goslar", - "H": "Hamburg", - "I": "Ingelheim", - "J": "Jena", - "K": "Köln", - "L": "Leipzig", - "M": "München", - "N": "Nürnberg", - "O": "Offenbach", - "Ö": "Umlaut Offenbach", - "P": "Potsdam", - "Q": "Quickborn", - "R": "Rostock", - "S": "Salzwedel", - "ẞ": "Eszett", - "T": "Tübingen", - "U": "Unna", - "Ü": "Umlaut Unna", - "V": "Völklingen", - "W": "Wuppertal", - "X": "Xanten", - "Y": "Ypsilon", - "Z": "Zwickau", - }, -} - - -def str_to_telephony(phrase, language): - language_alphabet = alphabet[language] - - return [ - language_alphabet[c] if c in language_alphabet else c for c in phrase.upper() - ] - - -language = sys.argv[1] -if language not in ["nato", "german"]: - print( - f"Langugae '{language}' is not a valid language, only 'nato' and 'german' are!", - file=sys.stderr, - ) - exit(1) - -print( - "\n".join( - str_to_telephony( - " ".join(sys.argv[2:]), - language, - ) - ) -) diff --git a/pkgs/by-name/na/nato/package.nix b/pkgs/by-name/na/nato/package.nix deleted file mode 100644 index 17fe7d1a..00000000 --- a/pkgs/by-name/na/nato/package.nix +++ /dev/null @@ -1,34 +0,0 @@ -{ - lib, - python3, - runCommandLocal, - makeWrapper, -}: let - write_python = { - name, - dependencies_system ? [], - dependencies_python ? _: [], - keepPath ? false, - }: let - src = ./${name}.py; - dependencies = - [(python3.withPackages dependencies_python)] - ++ dependencies_system; - path_setting = - if keepPath - then "--prefix PATH :" - else "--set PATH"; - in - runCommandLocal name { - nativeBuildInputs = [makeWrapper] ++ dependencies; - } - '' - install -m755 ${src} -D "$out/bin/${name}" - patchShebangs "$out/bin/${name}" - wrapProgram "$out/bin/${name}" ${path_setting} ${lib.makeBinPath dependencies}; - ''; -in - write_python { - name = "nato"; - dependencies_python = ps: []; - } diff --git a/pkgs/by-name/so/sort_song/package.nix b/pkgs/by-name/so/sort_song/package.nix deleted file mode 100644 index f74ba57f..00000000 --- a/pkgs/by-name/so/sort_song/package.nix +++ /dev/null @@ -1,17 +0,0 @@ -{ - sysLib, - mediainfo, - jq, - gawk, -}: -sysLib.writeShellScript { - name = "sort_song"; - src = ./sort_song.sh; - generateCompletions = false; - keepPath = false; - dependencies = [ - mediainfo - jq - gawk - ]; -} diff --git a/pkgs/by-name/so/sort_song/sort_song.sh b/pkgs/by-name/so/sort_song/sort_song.sh deleted file mode 100755 index e2978507..00000000 --- a/pkgs/by-name/so/sort_song/sort_song.sh +++ /dev/null @@ -1,34 +0,0 @@ -#!/usr/bin/env dash - -# shellcheck source=/dev/null -SHELL_LIBRARY_VERSION="2.1.2" . %SHELL_LIBRARY_PATH - -case "$("$1" | tr '[:upper:]' '[:lower:]')" in -"lyrics") - filter="LYRICS" - directory="lyrics" - ;; -"instrumental") - filter="INSTRUMENTAL" - directory="instrumental" - ;; -*) - die "Expected 'instrumental|lyrics' but got '$1'" - ;; -esac - -process() { - mediainfo --Output=JSON "$1" | jq '.media.track | map(.Lyrics) | join("")' -} - -mkdir "../$directory" - -fd . --extension=opus | while read -r file; do - if [ "$(process "$file")" = '""' ] || [ "$(process "$file")" = '"Instrumental"' ] || [ "$(process "$file")" = '"instrumental"' ]; then - echo "INSTRUMENTAL::$file" - else - echo "LYRICS::$file" - fi -done | grep "$filter" | awk 'BEGIN {FS="::"}{print $2}' | while read -r file; do ln -s "../all/$file" "../$directory/$file"; done - -# vim: ft=sh diff --git a/pkgs/by-name/sp/spodi/package.nix b/pkgs/by-name/sp/spodi/package.nix deleted file mode 100644 index 83540a21..00000000 --- a/pkgs/by-name/sp/spodi/package.nix +++ /dev/null @@ -1,39 +0,0 @@ -{ - sysLib, - # dependencies - gawk, - expect, - spotdl, - fd, - coreutils, - # config - xdgCacheHome ? builtins.getEnv "XDG_CACHE_HOME", - xdgUserDirsMusic ? builtins.getEnv "XDG_MUSIC_HOME", -}: -sysLib.writeShellScriptMultiPart { - name = "spodi"; - src = ./.; - - generateCompletions = true; - keepPath = false; - - baseName = "spodi.sh"; - cmdPrefix = "sh"; - cmdNames = [ - "download.sh" - "update.sh" - ]; - - dependencies = [ - gawk - expect - spotdl - fd - coreutils - ]; - - replacementStrings = { - XDG_CACHE_HOME = xdgCacheHome; - XDG_MUSIC_DIR = xdgUserDirsMusic; - }; -} diff --git a/pkgs/by-name/sp/spodi/sh/download.sh b/pkgs/by-name/sp/spodi/sh/download.sh deleted file mode 100755 index fe9746c8..00000000 --- a/pkgs/by-name/sp/spodi/sh/download.sh +++ /dev/null @@ -1,58 +0,0 @@ -#!/usr/bin/env dash - -download_to_down() { - DOWNLOAD_DIRECTORY="%XDG_MUSIC_DIR/down/spotify" - - already_downloaded_files="$(mktmp)" - fd . "$DOWNLOAD_DIRECTORY" --exclude spotdl.log --exclude spotdl-errors.log >"$already_downloaded_files" - if [ -z "$NO_CHECK" ] && [ "$(wc -l <"$already_downloaded_files")" -ne 0 ]; then - die "something is already downloaded" - fi - # [ -e "$DOWNLOAD_DIRECTORY/spotdl.log" ] && rm "$DOWNLOAD_DIRECTORY/spotdl.log" - - download "$1" "$DOWNLOAD_DIRECTORY" -} - -download() { - download_url="$1" - output_path="$2" - - config="$(mktmp)" - cat <<EOF | clean >"$config" -# Main options ---audio slider-kz bandcamp youtube-music piped youtube soundcloud ---lyrics genius musixmatch azlyrics synced - -# FFmpeg options ---ffmpeg ffmpeg ---threads 16 ---bitrate 256k - -# Spotify options ---cache-path %XDG_CACHE_HOME/spotdl/.spotipy - -# Output options ---preload ---format opus ---output {artists}_-_{title} ---print-errors ---save-errors $output_path/spotdl-errors.log -# TODO: Reactive whence spotdl support for these has improved <2023-12-19> -# --generate-lrc ---overwrite skip - -# Misc options ---log-level INFO -EOF - - cd "$output_path" || die "BUG: no $output_path" - touch "$output_path/spotdl-errors.log" - - # The sub shell needs to be unquoted, as the arguments may not be treated as one. - # shellcheck disable=2046 - unbuffer spotdl $(cat "$config") download "$download_url" | tee "$output_path/spotdl.log" - - [ -d ~/.spotdl ] && rm -r ~/.spotdl -} - -# vim: ft=sh diff --git a/pkgs/by-name/sp/spodi/sh/update.sh b/pkgs/by-name/sp/spodi/sh/update.sh deleted file mode 100755 index a289cf58..00000000 --- a/pkgs/by-name/sp/spodi/sh/update.sh +++ /dev/null @@ -1,52 +0,0 @@ -#!/usr/bin/env dash - -update() { - UPDATE_DIRECTORY="%XDG_MUSIC_DIR/artists" - UPDATE_CONFIG_FILE="%XDG_MUSIC_DIR/artists/update.conf" - - if ! [ -f "$UPDATE_CONFIG_FILE" ]; then - error="$( - cat <<EOF -Please provide an update config file at: '$UPDATE_CONFIG_FILE'. - -The 'update.conf' file should follow this pattern: -<path_to_artist>/<artist_name>|<spotify_url> - -All comments and empty lines are ignored -EOF - )" - die "$error" - fi - - config_file="$(mktmp)" - clean "$UPDATE_CONFIG_FILE" >"$config_file" - - while IFS="|" read -r artist url; do - full_artist="$UPDATE_DIRECTORY/$artist" - [ -d "$full_artist" ] || mkdir --parents "$full_artist" - [ -d "$full_artist/update" ] || mkdir --parents "$full_artist/update" - [ -d "$full_artist/all" ] || mkdir --parents "$full_artist/all" - [ -d "$full_artist/filtered" ] || mkdir --parents "$full_artist/filtered" - - while read -r file; do - ln --symbolic --relative "$file" "$full_artist/update/$(basename "$file")" - done <"$(tmp fd --type file --extension opus . "$full_artist/all")" - - msg2 "Updating $artist with url: '$url'" - download "$url" "$full_artist/update" - - while read -r file; do - mv "$file" "$full_artist/all" - ln --symbolic --relative "$full_artist/all/$(basename "$file")" "$full_artist/filtered/$(basename "$file")" - done <"$(tmp fd --type file --extension opus . "$full_artist/update")" - - while read -r file; do - rm "$file" - done <"$(tmp fd --type symlink --extension opus . "$full_artist/update")" - - cp "$full_artist/update/spotdl.log" "$full_artist/all/spotdl.$(date +%Y_%m_%d).log" - cp "$full_artist/update/spotdl-errors.log" "$full_artist/all/spotdl-errors.$(date +%Y_%m_%d).log" - done <"$config_file" -} - -# vim: ft=sh diff --git a/pkgs/by-name/sp/spodi/spodi.sh b/pkgs/by-name/sp/spodi/spodi.sh deleted file mode 100755 index 475fd48a..00000000 --- a/pkgs/by-name/sp/spodi/spodi.sh +++ /dev/null @@ -1,71 +0,0 @@ -#!/usr/bin/env dash - -# shellcheck source=/dev/null -SHELL_LIBRARY_VERSION="2.1.2" . %SHELL_LIBRARY_PATH - -# these are used in version() -# shellcheck disable=2034 -AUTHORS="Soispha" -# shellcheck disable=2034 -YEARS="2023" - -# load dependencies -. ./sh/update.sh -. ./sh/download.sh - -help() { - cat <<EOF -This is a small wrapper around downloading things from spotify - -USAGE: - $NAME [OPTIONS] COMMAND - -OPTIONS: - --help | -h - Display this help and exit. - - --version | -v - Display version and copyright information and exit. -COMMANDS: - update - Read the artist.conf file and download all newly released things - - download URL - Download a specific url to the DOWNLOAD_DIRECTORY -EOF -} - -for arg in "$@"; do - case "$arg" in - "--help" | "-h") - help - exit 0 - ;; - "--version" | "-v") - version - exit 0 - ;; - esac -done - -case "$1" in -"update") - shift 1 - update - exit 0 - ;; -"download") - shift 1 - download_url="$1" - [ -z "$download_url" ] && die "You need to provide a download url" - download_to_down "$download_url" - exit 0 - ;; -*) - die "Command '$1' is not know" - help - exit 1 - ;; -esac - -# vim: ft=sh diff --git a/pkgs/by-name/vi/virsh-del/package.nix b/pkgs/by-name/vi/virsh-del/package.nix deleted file mode 100644 index 3f27e2be..00000000 --- a/pkgs/by-name/vi/virsh-del/package.nix +++ /dev/null @@ -1,13 +0,0 @@ -{ - sysLib, - libvirt, -}: -sysLib.writeShellScript { - name = "virsh-del"; - src = ./virsh-del.sh; - generateCompletions = false; - keepPath = false; - dependencies = [ - libvirt - ]; -} diff --git a/pkgs/by-name/vi/virsh-del/virsh-del.sh b/pkgs/by-name/vi/virsh-del/virsh-del.sh deleted file mode 100755 index c3de5484..00000000 --- a/pkgs/by-name/vi/virsh-del/virsh-del.sh +++ /dev/null @@ -1,10 +0,0 @@ -#! /usr/bin/env dash - -# shellcheck source=/dev/null -SHELL_LIBRARY_VERSION="2.1.2" . %SHELL_LIBRARY_PATH - -virsh destroy "$1" -virsh undefine "$1" --nvram -virsh vol-delete --pool default "$1".qcow2 - -# vim: ft=sh diff --git a/pkgs/by-name/yt/yti/package.nix b/pkgs/by-name/yt/yti/package.nix deleted file mode 100644 index 5a39512a..00000000 --- a/pkgs/by-name/yt/yti/package.nix +++ /dev/null @@ -1,17 +0,0 @@ -{ - sysLib, - gawk, - expect, - yt-dlp, -}: -sysLib.writeShellScript { - name = "yti"; - src = ./yti.sh; - generateCompletions = false; - keepPath = false; - dependencies = [ - gawk - expect - yt-dlp - ]; -} diff --git a/pkgs/by-name/yt/yti/yti.sh b/pkgs/by-name/yt/yti/yti.sh deleted file mode 100755 index a69ffa74..00000000 --- a/pkgs/by-name/yt/yti/yti.sh +++ /dev/null @@ -1,33 +0,0 @@ -#! /usr/bin/env dash - -# shellcheck source=/dev/null -SHELL_LIBRARY_VERSION="2.1.2" . %SHELL_LIBRARY_PATH - -DOWN_DIR=/home/soispha/media/music/down/youtube - -tmp=$(mktmp) -config=$(mktmp) - -for e in "$DOWN_DIR"/*.opus; do echo "$e" >>"$tmp"; done -[ "$(wc -l "$tmp" | awk '{print $1}')" -gt 2 ] && die "something is already downloaded" - -cat <<EO >"$config" ---paths home:"$DOWN_DIR" -#--output %(fulltitle) ---restrict-filenames ---no-overwrites ---no-write-info-json ---clean-info-json ---prefer-free-formats -#--format mp3 ---extract-audio ---audio-quality 0 ---audio-format best -EO - -rm "$DOWN_DIR/yt-dlp.log" -cd "$DOWN_DIR" || die "BUG: no $DOWN_DIR" - -unbuffer yt-dlp --config-location "$config" "$1" | tee "$DOWN_DIR/yt-dlp.log" - -# vim: ft=sh |