add some scripts

This commit is contained in:
Ingolf Wagner 2021-04-19 07:43:55 +02:00
parent fcb6a5b05f
commit 49b51a01b6
No known key found for this signature in database
GPG key ID: 76BF5F1928B9618B
2 changed files with 34 additions and 18 deletions

View file

@ -2,25 +2,22 @@
let
pastebin = pkgs.writers.writeDashBin "pastebin" # sh
''
exec ${pkgs.bepasty-client-cli}/bin/bepasty-cli \
--lifetime 1m \
--url http://workhorse.private:8000 \
--pass ${lib.fileContents <common_secrets/bepasty/admin-password>} \
"$@" | sed -e s/workhorse.private:8000/paste.ingolf-wagner.de/
'';
pastebin = pkgs.writers.writeDashBin "pastebin" ''
exec ${pkgs.bepasty-client-cli}/bin/bepasty-cli \
--lifetime 1m \
--url http://workhorse.private:8000 \
--pass ${lib.fileContents <common_secrets/bepasty/admin-password>} \
"$@" | sed -e s/workhorse.private:8000/paste.ingolf-wagner.de/
'';
memoryUsage = pkgs.writers.writeDashBin "memory-total-usage" # sh
''
echo " %CPU %MEM MEM : PROCESS"
echo "------- ------- ------------- -------"
ps aux | awk '{mem[$11]+=int($6/1024)}; {cpuper[$11]+=$3};{memper[$11]+=$4}; END {for (i in mem) {printf "%6.2f%% %6.2f%% %10.2f MB : %s\n", cpuper[i],memper[i],mem[i],i}}' | sort -k3nr | head -n 5
'';
memoryUsage = pkgs.writers.writeDashBin "memory-total-usage" ''
echo " %CPU %MEM MEM : PROCESS"
echo "------- ------- ------------- -------"
ps aux | awk '{mem[$11]+=int($6/1024)}; {cpuper[$11]+=$3};{memper[$11]+=$4}; END {for (i in mem) {printf "%6.2f%% %6.2f%% %10.2f MB : %s\n", cpuper[i],memper[i],mem[i],i}}' | sort -k3nr | head -n 5
'';
prefetch-git-rendered =
pkgs.writeShellScriptBin "nix-prefetch-git-rendered" # sh
''
pkgs.writeShellScriptBin "nix-prefetch-git-rendered" ''
${pkgs.nix-prefetch-scripts}/bin/nix-prefetch-git "$@" \
| ${pkgs.jq}/bin/jq --raw-output '"pkgs.fetchgit{
url = \"\(.url)\";
@ -30,8 +27,7 @@ let
'';
prefetch-url-rendered =
pkgs.writeShellScriptBin "nix-prefetch-url-rendered" # sh
''
pkgs.writeShellScriptBin "nix-prefetch-url-rendered" ''
HASH=$( ${pkgs.nix}/bin/nix-prefetch-url "$1" )
cat <<EOF
pkgs.fetchurl {
@ -41,6 +37,13 @@ let
EOF
'';
storepath = let
dirname = "${pkgs.coreutils-full}/bin/dirname";
readlink = "${pkgs.coreutils-full}/bin/readlink";
in pkgs.writers.writeBashBin "storepath" ''
${dirname} $( ${readlink} $( type -p "$1" ) )
'';
in {
#imports = [ ./packages/llvm-config-dummy.nix ];
@ -54,6 +57,8 @@ in {
environment.systemPackages = with pkgs; [
storepath
prefetch-git-rendered
prefetch-url-rendered

View file

@ -149,6 +149,14 @@ let
-d '{ "weight" : '$weight', "date": "'$( ${pkgs.coreutils}/bin/date -Iseconds )'" }'
'';
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
@ -197,6 +205,9 @@ in {
command = "insertCopyq";
})
isoToUtf8
hledger
hledger-ui
bank
(bank-old "2021")
(bank-old "2020")