diff options
author | tv <tv@krebsco.de> | 2016-06-30 16:31:05 +0200 |
---|---|---|
committer | tv <tv@krebsco.de> | 2016-06-30 16:31:05 +0200 |
commit | d81b068113325fb7604089c3647c365a41804978 (patch) | |
tree | 4c43ad2142825ac7c0a7045e5c48a039b25f6786 /lass/5pkgs | |
parent | 1542f9bbee823025f703e6abf3836905cee416fd (diff) | |
parent | f12578c66f8b7b829c0dec5255f358778c0d3366 (diff) |
Merge remote-tracking branch 'prism/master'
Diffstat (limited to 'lass/5pkgs')
-rw-r--r-- | lass/5pkgs/default.nix | 9 | ||||
-rw-r--r-- | lass/5pkgs/q/default.nix | 185 | ||||
-rw-r--r-- | lass/5pkgs/rs/default.nix | 6 | ||||
-rw-r--r-- | lass/5pkgs/xmonad-lass.nix (renamed from lass/5pkgs/xmonad-lass/Main.hs) | 17 | ||||
-rw-r--r-- | lass/5pkgs/xmonad-lass/.gitignore | 1 | ||||
-rw-r--r-- | lass/5pkgs/xmonad-lass/Makefile | 6 | ||||
-rw-r--r-- | lass/5pkgs/xmonad-lass/xmonad.cabal | 17 |
7 files changed, 214 insertions, 27 deletions
diff --git a/lass/5pkgs/default.nix b/lass/5pkgs/default.nix index 467867f63..c48188f9d 100644 --- a/lass/5pkgs/default.nix +++ b/lass/5pkgs/default.nix @@ -3,6 +3,9 @@ { nixpkgs.config.packageOverrides = rec { acronym = pkgs.callPackage ./acronym/default.nix {}; + ejabberd = pkgs.callPackage ./ejabberd { + erlang = pkgs.erlangR16; + }; firefoxPlugins = { noscript = pkgs.callPackage ./firefoxPlugins/noscript.nix {}; ublock = pkgs.callPackage ./firefoxPlugins/ublock.nix {}; @@ -10,11 +13,11 @@ }; mk_sql_pair = pkgs.callPackage ./mk_sql_pair/default.nix {}; mpv-poll = pkgs.callPackage ./mpv-poll/default.nix {}; + q = pkgs.callPackage ./q {}; + rs = pkgs.callPackage ./rs/default.nix {}; untilport = pkgs.callPackage ./untilport/default.nix {}; urban = pkgs.callPackage ./urban/default.nix {}; - xmonad-lass = - let src = pkgs.writeNixFromCabal "xmonad-lass.nix" ./xmonad-lass; in - pkgs.haskellPackages.callPackage src {}; + xmonad-lass = import ./xmonad-lass.nix { inherit pkgs; }; yt-next = pkgs.callPackage ./yt-next/default.nix {}; }; } diff --git a/lass/5pkgs/q/default.nix b/lass/5pkgs/q/default.nix new file mode 100644 index 000000000..644be0d17 --- /dev/null +++ b/lass/5pkgs/q/default.nix @@ -0,0 +1,185 @@ +{ pkgs, ... }: +let + q-cal = let + # XXX 23 is the longest line of cal's output + pad = ''{ + ${pkgs.gnused}/bin/sed ' + # rtrim + s/ *$// + + # delete last empty line + ''${/^$/d} + ' \ + | ${pkgs.gawk}/bin/awk '{printf "%-23s\n", $0}' \ + | ${pkgs.gnused}/bin/sed ' + # colorize header + 1,2s/.*/[38;5;238;1m&[39;22m/ + + # colorize week number + s/^[ 1-9][0-9]/[38;5;238;1m&[39;22m/ + ' + }''; + in '' + ${pkgs.coreutils}/bin/paste \ + <(${pkgs.utillinux}/bin/cal -mw \ + $(${pkgs.coreutils}/bin/date +'%m %Y' -d 'last month') \ + | ${pad} + ) \ + <(${pkgs.utillinux}/bin/cal -mw \ + | ${pkgs.gnused}/bin/sed ' + # colorize day of month + s/\(^\| \)'"$(${pkgs.coreutils}/bin/date +%e)"'\>/[31;1m&[39;22m/ + ' \ + | ${pad} + ) \ + <(${pkgs.utillinux}/bin/cal -mw \ + $(${pkgs.coreutils}/bin/date +'%m %Y' -d 'next month') \ + | ${pad} + ) \ + | ${pkgs.gnused}/bin/sed 's/\t/ /g' + ''; + + q-isodate = '' + ${pkgs.coreutils}/bin/date \ + '+[1m%Y-%m-%d[;30mT[;38;5;085m%H:%M[m:%S%:z' + ''; + + q-gitdir = '' + if test -d .git; then + #git status --porcelain + branch=$( + ${pkgs.git}/bin/git branch \ + | ${pkgs.gnused}/bin/sed -rn 's/^\* (.*)/\1/p' + ) + echo "± $LOGNAME@''${HOSTNAME-$(${pkgs.nettools}/bin/hostname)}:$PWD .git $branch" + fi + ''; + + q-power_supply = '' + for uevent in /sys/class/power_supply/*/uevent; do + if test -f $uevent; then + eval "$(${pkgs.gnused}/bin/sed -n ' + s/^\([A-Z_]\+=\)\(.*\)/\1'\'''\2'\'''/p + ' $uevent)" + + if test "x''${POWER_SUPPLY_CHARGE_NOW-}" = x; then + continue + fi + + charge_percentage=$(echo " + scale=2 + $POWER_SUPPLY_CHARGE_NOW / $POWER_SUPPLY_CHARGE_FULL + " | ${pkgs.bc}/bin/bc) + + lfc=$POWER_SUPPLY_CHARGE_FULL + rc=$POWER_SUPPLY_CHARGE_NOW + #rc=2800 + N=78; N=76 + N=10 + n=$(echo $N-1 | ${pkgs.bc}/bin/bc) + centi=$(echo "$rc*100/$lfc" | ${pkgs.bc}/bin/bc) + deci=$(echo "$rc*$N/$lfc" | ${pkgs.bc}/bin/bc) + energy_evel=$( + echo -n '☳ ' # TRIGRAM FOR THUNDER + if test $centi -ge 42; then echo -n '[1;32m' + elif test $centi -ge 23; then echo -n '[1;33m' + elif test $centi -ge 11; then echo -n '[1;31m' + else echo -n '[5;1;31m'; fi + for i in $(${pkgs.coreutils}/bin/seq 1 $deci); do + echo -n ■ + done + echo -n '[;30m' + for i in $(${pkgs.coreutils}/bin/seq $deci $n); do + echo -n ■ + done + echo '[m' $rc #/ $lfc + ) + echo "$energy_evel $charge_percentage" + fi + done + ''; + + q-virtualization = '' + echo "VT: $(${pkgs.systemd}/bin/systemd-detect-virt)" + ''; + + q-wireless = '' + for dev in $( + ${pkgs.iw}/bin/iw dev \ + | ${pkgs.gnused}/bin/sed -n 's/^\s*Interface\s\+\([0-9a-z]\+\)$/\1/p' + ); do + inet=$(${pkgs.iproute}/bin/ip addr show $dev \ + | ${pkgs.gnused}/bin/sed -n ' + s/.*inet \([0-9]\+\.[0-9]\+\.[0-9]\+\.[0-9]\+\).*/\1/p + ') \ + || unset inet + ssid=$(${pkgs.iw}/bin/iw dev $dev link \ + | ${pkgs.gnused}/bin/sed -n ' + s/.*\tSSID: \(.*\)/\1/p + ') \ + || unset ssid + echo "$dev''${inet+ $inet}''${ssid+ $ssid}" + done + ''; + + q-online = '' + if ${pkgs.curl.bin}/bin/curl -s google.com >/dev/null; then + echo '[32;1monline[m' + else + echo offline + fi + ''; + + q-thermal_zone = '' + for i in /sys/class/thermal/thermal_zone*; do + type=$(${pkgs.coreutils}/bin/cat $i/type) + temp=$(${pkgs.coreutils}/bin/cat $i/temp) + printf '%s %s°C\n' $type $(echo $temp / 1000 | ${pkgs.bc}/bin/bc) + done + ''; + + q-todo = '' + TODO_file=$HOME/TODO + if test -e "$TODO_file"; then + ${pkgs.coreutils}/bin/cat "$TODO_file" \ + | ${pkgs.gawk}/bin/gawk -v now=$(${pkgs.coreutils}/bin/date +%s) ' + BEGIN { print "remind=0" } + /^[0-9]/{ + x = $1 + gsub(".", "\\\\&", x) + rest = substr($0, index($0, " ")) + rest = $0 + sub(" *", "", rest) + gsub(".", "\\\\&", rest) + print "test $(${pkgs.coreutils}/bin/date +%s -d"x") -lt "now" && \ + echo \"\x1b[38;5;208m\""rest esc "\"\x1b[m\" && \ + (( remind++ ))" + } + END { print "test $remind = 0 && echo \"nothing to remind\"" } + ' \ + | { + # bash needed for (( ... )) + ${pkgs.bash}/bin/bash + } + else + echo "$TODO_file: no such file or directory" + fi + ''; + +in +# bash needed for <(...) +pkgs.writeBashBin "q" '' + set -eu + export PATH=/var/empty + ${q-cal} + echo + ${q-isodate} + (${q-gitdir}) & + (${q-power_supply}) & + (${q-virtualization}) & + (${q-wireless}) & + (${q-online}) & + (${q-thermal_zone}) & + wait + ${q-todo} +'' diff --git a/lass/5pkgs/rs/default.nix b/lass/5pkgs/rs/default.nix new file mode 100644 index 000000000..6b27908fb --- /dev/null +++ b/lass/5pkgs/rs/default.nix @@ -0,0 +1,6 @@ +{ pkgs, ... }: + +#TODO: get tab-completion working again +pkgs.writeBashBin "rs" '' + rsync -vaP --append-verify "$@" +'' diff --git a/lass/5pkgs/xmonad-lass/Main.hs b/lass/5pkgs/xmonad-lass.nix index d7c66bf4d..841821a7a 100644 --- a/lass/5pkgs/xmonad-lass/Main.hs +++ b/lass/5pkgs/xmonad-lass.nix @@ -1,3 +1,15 @@ +{ pkgs, ... }: +pkgs.writeHaskell "xmonad-lass" { + executables.xmonad = { + extra-depends = [ + "containers" + "unix" + "X11" + "xmonad" + "xmonad-contrib" + "xmonad-stockholm" + ]; + text = '' {-# LANGUAGE DeriveDataTypeable #-} -- for XS {-# LANGUAGE FlexibleContexts #-} -- for xmonad' {-# LANGUAGE LambdaCase #-} @@ -147,3 +159,8 @@ gridConfig = def , gs_navigate = navNSearch , gs_font = myFont } + + ''; + }; +} + diff --git a/lass/5pkgs/xmonad-lass/.gitignore b/lass/5pkgs/xmonad-lass/.gitignore deleted file mode 100644 index 616204547..000000000 --- a/lass/5pkgs/xmonad-lass/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/shell.nix diff --git a/lass/5pkgs/xmonad-lass/Makefile b/lass/5pkgs/xmonad-lass/Makefile deleted file mode 100644 index cbb0776e6..000000000 --- a/lass/5pkgs/xmonad-lass/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -.PHONY: ghci -ghci: shell.nix - nix-shell --command 'exec ghci -Wall' - -shell.nix: xmonad.cabal - cabal2nix --shell . > $@ diff --git a/lass/5pkgs/xmonad-lass/xmonad.cabal b/lass/5pkgs/xmonad-lass/xmonad.cabal deleted file mode 100644 index 37809b599..000000000 --- a/lass/5pkgs/xmonad-lass/xmonad.cabal +++ /dev/null @@ -1,17 +0,0 @@ -Author: lass -Build-Type: Simple -Cabal-Version: >= 1.2 -License: MIT -Name: xmonad-lass -Version: 0 - -Executable xmonad - Build-Depends: - base, - containers, - unix, - xmonad, - xmonad-contrib, - xmonad-stockholm - GHC-Options: -Wall -O3 -threaded -rtsopts - Main-Is: Main.hs |