nixos-config/nixos/system/desktop/packages.nix
2023-03-12 10:00:48 +01:00

336 lines
7.3 KiB
Nix

{ pkgs, config, lib, ... }:
with lib;
let
library = import ../../library { inherit pkgs lib; };
allLicenses =
let
licenses = builtins.map
(license: "echo '${license.shortName} : ${license.fullName}'")
(builtins.attrValues pkgs.lib.licenses);
in
pkgs.writers.writeBashBin "all-licenses"
(lib.concatStringsSep "\n" licenses);
#joplin = pkgs.joplin-desktop;
joplin = pkgs.unstable.joplin-desktop;
#joplin = pkgs.writers.writeBashBin "joplin" ''
# if [[ ! -x "$HOME/programs/Joplin.AppImage" ]]
# then
# echo "$HOME/programs/Joplin.AppImage does not exist or is not executable";
# exit 1
# fi
# exec ${pkgs.appimage-run}/bin/appimage-run "$HOME/programs/Joplin.AppImage"
#'';
parseUrl = pkgs.writers.writeBashBin "parseUrl" ''
echo "$@" | \
${pkgs.jq}/bin/jq --raw-input --raw-output '
def parseURL: capture( "^((?<scheme>[^:/?#]+):)?(//(?<authority>(?<domain>[^/?#:]*)(:(?<port>[0-9]*))?))?((?<path>[^?#]*)\\?)?((?<query>([^#]*)))?(#(?<fragment>(.*)))?");
parseURL
'
'';
parseAndCopyLink = pkgs.writers.writeBashBin "parseAndCopyLink" ''
${parseUrl}/bin/parseUrl "$@" | \
${pkgs.jq}/bin/jq --raw-output '"\(.scheme)://\(.domain)\(.path)"' | \
${pkgs.xclip}/bin/xclip
'';
replaceLinks = pkgs.writers.writeBashBin "replace-link-with-content" # sh
''
if [ ! -L "$1" ]
then
echo "$1 does not exist or is not a file"
exit 1
fi
cp -rL "$1" "$1.backup"
unlink "$1"
mv "$1.backup" "$1"
'';
pandocScript = { inputFormat, outputFormat }:
pkgs.writers.writeDashBin "pandoc-from-${inputFormat}-to-${outputFormat}" ''
${pkgs.pandoc}/bin/pandoc \
--from ${inputFormat} \
--to ${outputFormat} \
--standalone \
"$@"
'';
connectToSpeaker = name: id:
pkgs.writeShellScriptBin "connect-to-speaker-${name}" # sh
''
# hacky script because I have problems with
# automatically connecting to trusted bluetooth devices.
echo "Connect to Speaker ${name}"
bluetoothctl <<EOF
power on
agent on
scan on
connect ${id}
EOF
'';
disconnectToSpeaker = name: id:
pkgs.writeShellScriptBin "disconnect-from-speaker-${name}" # sh
''
# hacky script because I have problems with
# automatically connecting to trusted bluetooth devices.
echo "Disconnect from Speaker ${name}"
bluetoothctl <<EOF
disconnect ${id}
scan off
agent off
power off
EOF
'';
borrow = pkgs.writers.writeDashBin "borrow" # sh
''
TERM=xterm-mono ${pkgs.hledger-ui}/bin/hledger-ui --file ~/finance/.hledger-borrow "$@"
'';
bank-report = pkgs.writers.writeDashBin "bank-report" # sh
''
${pkgs.hledger}/bin/hledger --file ~/finance/hledger/all.journal balance -M -B date:$(date +%Y-%m -d 'last year')..
${pkgs.hledger}/bin/hledger --file ~/finance/hledger/all.journal balance -M -B date:$(date +%Y-%m -d 'last year').. --depth 1
'';
bank = pkgs.writers.writeDashBin "bank" # sh
''
${pkgs.hledger-ui}/bin/hledger-ui --color=never --file ~/finance/hledger/all.journal
'';
bank-old = year:
pkgs.writers.writeDashBin "bank-${year}" # sh
''
TERM=xterm-mono ${pkgs.hledger-ui}/bin/hledger-ui --color=never --file ~/finance/hledger/${year}.journal "$@"
'';
irc = pkgs.writers.writeDashBin "irc" # sh
''
${pkgs.mosh}/bin/mosh workhorse.private -- sudo -u weechat -- screen -rd
'';
insertCopyq = pkgs.writers.writeDashBin "insertCopyq" # sh
''
${pkgs.copyq}/bin/copyq read 0 | ${pkgs.xdotool}/bin/xdotool type -f -
'';
isoToUtf8 = pkgs.writers.writeBashBin "iso-to-utf8" ''
input="$1"
TMP=$(mktemp)
${pkgs.glibc.bin}/bin/iconv -f ISO-8859-1 "$input" -t UTF-8 -o "$TMP"
mv "$TMP" "$input"
'';
in
{
# ffmpeg scripts to encode movies
programs.custom.ffmpeg.enable = true;
# gnupg setup
programs.gnupg.agent.enable = true;
programs.gnupg.agent.enableSSHSupport = true;
programs.gnupg.agent.enableExtraSocket = true;
environment.systemPackages = with pkgs;
[
uget
joplin
(library.desktopFile joplin { longName = "Joplin"; })
zim
#antimony
#(library.desktopFile antimony { longName = "CAD Software"; command = "antimony"; })
parted
insertCopyq
(library.desktopFile insertCopyq {
longName = "type what is on top of the copyq";
command = "insertCopyq";
})
isoToUtf8
hledger
hledger-ui
borrow
bank
bank-report
(bank-old "2021")
(bank-old "2020")
irc
man-pages
emo
(library.desktopFile emo {
longName = "Emoji Inserter";
command = "emoticons";
})
bat
zlib # ???
cabal-install
ghc
cabal2nix
psmisc # contains killall
pmount
nix-prefetch-scripts
ipcalc
nmap
libreoffice
hunspell
hunspellDicts.de-de
hunspellDicts.en-us
aspell
aspellDicts.de
aspellDicts.en
aspellDicts.es
translate-shell
borgbackup
gpa
gnupg
sshuttle
sshfs
mosh
dosfstools
copyq
# radio-dj
cups
xfe # filemanager
evince
sxiv
(library.desktopFile sxiv {
longName = "Image Viewer";
command = "sxiv";
})
calibre
transmission-remote-gtk
mpv
# cantata
ncmpcpp
# dino # jabber client
nixos-generators
shellcheck
bind.dnsutils
usbutils
hexyl
testssl
trash-cli
nix-review
units
hub # for github
(writeShellScriptBin "ingdiba-security" ''
first=$1
second=$2
if [[ $# -ne 2 ]]
then
echo "need 2 arguments"
exit 1
fi
pass bank/ingdiba/security_key | cut -c$first,$second
'')
(writeShellScriptBin "ingdiba-tans" ''
first=$1
if [[ $# -ne 1 ]]
then
echo "need 1 arguments"
exit 1
fi
pass bank/ingdiba/tans-01 | cut -f$first -d '
'
'')
nix-index
nethogs
netsniff-ng
iftop
ffmpeg
(writeShellScriptBin "shrink-exports"
(fileContents ../../assets/shrink_exports))
(writeShellScriptBin "music-making"
(fileContents ../../assets/music-making.sh))
replaceLinks
youtube-dl
#cairo
#w3m
#links2
#lynx
# temperature
s-tui
(pkgs.writers.writeDashBin "temperature" ''
${pkgs.s-tui}/bin/s-tui
'')
powertop
(pkgs.writers.writeBashBin "youtube-download-music" ''
${pkgs.youtube-dl}/bin/youtube-dl \
--extract-audio \
--audio-format vorbis \
--audio-quality 0 \
"$@"
'')
allLicenses
dogdns
memo
nixfmt
dateutils
parseUrl
parseAndCopyLink
# needed for pycairo (in venv)
pkgconf
cairo
] ++ (map pandocScript (lib.cartesianProductOfSets {
inputFormat = [ "man" "markdown" "mediawiki" ];
outputFormat = [ "mediawiki" "docbook5" "html5" "man" "jira" ];
}));
}