From 1e915baafbc56c4c626a3c3d042ac0e7d6276561 Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 17 Mar 2020 20:51:18 +0100 Subject: irc-announce cat2: use awk --- krebs/5pkgs/simple/irc-announce/default.nix | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/krebs/5pkgs/simple/irc-announce/default.nix b/krebs/5pkgs/simple/irc-announce/default.nix index a90814aa9..52cf12862 100644 --- a/krebs/5pkgs/simple/irc-announce/default.nix +++ b/krebs/5pkgs/simple/irc-announce/default.nix @@ -25,10 +25,10 @@ pkgs.writeDashBin "irc-announce" '' # This is used to see what we send to the irc server. (debug output) echo2() { echo "$*"; echo "$*" >&2; } cat2() { - while read -r line; do - echo "$line" - echo "$line" >&2 - done + awk '{ + print $0 + print $0 > "/dev/stderr" + }' } # privmsg_cat transforms stdin to a privmsg -- cgit v1.2.3 From c12407200df12ef7397bf4fa0f96bb33ac96e0b7 Mon Sep 17 00:00:00 2001 From: lassulus Date: Sun, 22 Mar 2020 12:37:50 +0100 Subject: nixpkgs: b7bbc6d -> bf7c0f0 --- krebs/nixpkgs.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/krebs/nixpkgs.json b/krebs/nixpkgs.json index e0b37d1fc..c5665a70a 100644 --- a/krebs/nixpkgs.json +++ b/krebs/nixpkgs.json @@ -1,7 +1,7 @@ { "url": "https://github.com/NixOS/nixpkgs-channels", - "rev": "b7bbc6d37878ed00b6467b574b02e840279f7d3d", - "date": "2020-02-26T11:51:29+01:00", - "sha256": "02q10jgi6m0vak3amb50ifw1pj82i17hs0npdkig7lsp8w3is7jq", + "rev": "bf7c0f0461e047bec108a5c5d5d1b144289a65ba", + "date": "2020-03-17T13:04:05+00:00", + "sha256": "01dsh9932x6xcba2p0xg4n563b85i3p7s2sakj7yf2ws8pgmwhq9", "fetchSubmodules": false } -- cgit v1.2.3 From 29263a2941b87d34883839f3368a1f1c5c3f687a Mon Sep 17 00:00:00 2001 From: lassulus Date: Sun, 22 Mar 2020 13:18:59 +0100 Subject: nixpkgs-unstable: 55beed9 -> d96bd33 --- krebs/nixpkgs-unstable.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/krebs/nixpkgs-unstable.json b/krebs/nixpkgs-unstable.json index 1600d6f4a..847e3c61e 100644 --- a/krebs/nixpkgs-unstable.json +++ b/krebs/nixpkgs-unstable.json @@ -1,7 +1,7 @@ { "url": "https://github.com/NixOS/nixpkgs-channels", - "rev": "55beed9922c2f6b030af61ca7e33bd47850c68f2", - "date": "2020-02-26T03:53:16-05:00", - "sha256": "0jxkb3bl7axa6vmfsfdfx4mxv6wx0pc8iiwgrw2qh8wxhlhbylks", + "rev": "d96bd3394b734487d1c3bfbac0e8f17465e03afe", + "date": "2020-03-19T15:32:34+01:00", + "sha256": "05n27wz5ln9ni5cy5rhjcy612i44gmblkq5m0g827v8pd0nk00da", "fetchSubmodules": false } -- cgit v1.2.3 From ee59d7d72a29cc2b6c69a0d68a815eacfd980263 Mon Sep 17 00:00:00 2001 From: lassulus Date: Mon, 23 Mar 2020 09:55:43 +0100 Subject: grib2json: init --- krebs/5pkgs/simple/grib2json/default.nix | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 krebs/5pkgs/simple/grib2json/default.nix diff --git a/krebs/5pkgs/simple/grib2json/default.nix b/krebs/5pkgs/simple/grib2json/default.nix new file mode 100644 index 000000000..2a7959a75 --- /dev/null +++ b/krebs/5pkgs/simple/grib2json/default.nix @@ -0,0 +1,19 @@ +{ stdenv, fetchzip, makeWrapper, jre }: + +stdenv.mkDerivation { + name = "grib2json"; + src = fetchzip { + url = "https://github.com/krebs/grib2json-bin/archive/31efe677b40fe491c988d50f96b59b1b7e2d46f7.zip"; + sha256 = "1h3yxg270bvac7kaqsbsv4f8nln1i03rfz4cm8cp7llhjj3s6a6b"; + }; + installPhase = '' + mkdir -p $out/bin + cp -r lib $out/ + cat > $out/bin/grib2json << EOF + #!/bin/sh + set -x + ${jre}/bin/java -jar $out/lib/grib2json-0.8.0-SNAPSHOT.jar "\$@" + EOF + chmod +x $out/bin/grib2json + ''; +} -- cgit v1.2.3 From 539f783a7eba249f4221c4013032a05839ac3282 Mon Sep 17 00:00:00 2001 From: lassulus Date: Mon, 23 Mar 2020 09:55:58 +0100 Subject: nomads-cloud: init --- krebs/5pkgs/simple/nomads-cloud/default.nix | 43 +++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 krebs/5pkgs/simple/nomads-cloud/default.nix diff --git a/krebs/5pkgs/simple/nomads-cloud/default.nix b/krebs/5pkgs/simple/nomads-cloud/default.nix new file mode 100644 index 000000000..2af74dc44 --- /dev/null +++ b/krebs/5pkgs/simple/nomads-cloud/default.nix @@ -0,0 +1,43 @@ +{ writers, coreutils, grib2json, curl, jq, findutils, imagemagick }: +writers.writeDashBin "nomads-cloud" '' + prefix=$(mktemp -d) + grib_path=$prefix.grib + json_path=$prefix.json + pgm_path=$prefix.pgm + png_path="$1" + + mkdir -p "$prefix" + + date=$(${coreutils}/bin/date +%Y%m%d) + for hour in 18 12 06 00; do + url="https://nomads.ncep.noaa.gov/cgi-bin/filter_gfs_0p25_1hr.pl?file=gfs.t''${hour}z.pgrb2.0p25.anl&lev_entire_atmosphere_%5C%28considered_as_a_single_layer%5C%29=on&var_CWAT=on&leftlon=-180&rightlon=180&toplat=90&bottomlat=-90&dir=%2Fgfs.$date%2F$hour" + ${curl}/bin/curl -fsS "$url" > "$grib_path" + if [ "$?" -eq 0 ]; then + break + fi + done + ${grib2json}/bin/grib2json --data "$grib_path" > "$json_path" + + width=$(${jq}/bin/jq '.[0].header.nx' < "$json_path") + height=$(${jq}/bin/jq '.[0].header.ny' < "$json_path") + + # The maximum gray value. Must be bigger than 0 and less than 65536. + maxval=256 + + # pgm - Netpbm grayscale image format + # http://netpbm.sourceforge.net/doc/pgm.html + { + echo P2 + echo "$width $height" + echo "$maxval" + cat "$json_path" | + ${jq}/bin/jq --argjson maxval "$maxval" -c ' + .[0].data[] * $maxval | round + ' | + ${findutils}/bin/xargs -n "$width" + } > "$pgm_path" + + ${imagemagick}/bin/convert -roll +50% "$pgm_path" "$png_path" + + rm -r "$prefix" +'' -- cgit v1.2.3 From 2552d6321c309291147e3d7cc53501480b69f295 Mon Sep 17 00:00:00 2001 From: lassulus Date: Mon, 23 Mar 2020 09:57:54 +0100 Subject: realwallpaper: add nomad-clouds as cloud provider --- krebs/5pkgs/simple/realwallpaper/default.nix | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/krebs/5pkgs/simple/realwallpaper/default.nix b/krebs/5pkgs/simple/realwallpaper/default.nix index ef83d2e59..3f75e9e1e 100644 --- a/krebs/5pkgs/simple/realwallpaper/default.nix +++ b/krebs/5pkgs/simple/realwallpaper/default.nix @@ -1,5 +1,5 @@ { pkgs, ... }: -pkgs.writeDashBin "generate-wallpaper" '' +pkgs.writers.writeDashBin "generate-wallpaper" '' set -euf # usage: getimg FILENAME URL @@ -68,15 +68,15 @@ pkgs.writeDashBin "generate-wallpaper" '' "$nightmap_url" & fetch daymap-raw.png \ "$daymap_url" & - fetch clouds-raw.jpg \ - "$cloudmap_url" & fetch marker.json \ "$marker_url" & wait + ${pkgs.nomads-cloud}/bin/nomads-cloud clouds-raw.png + check_type nightmap-raw.jpg image check_type daymap-raw.png image - check_type clouds-raw.jpg image + check_type clouds-raw.png image in_size=2048x1024 xplanet_out_size=1466x1200 @@ -87,7 +87,7 @@ pkgs.writeDashBin "generate-wallpaper" '' for raw in \ nightmap-raw.jpg \ daymap-raw.png \ - clouds-raw.jpg \ + clouds-raw.png \ ; do normal=''${raw%-raw.*}.png -- cgit v1.2.3 From cab3be8a19d445d3292454099dbc1ca97bca60c5 Mon Sep 17 00:00:00 2001 From: lassulus Date: Mon, 23 Mar 2020 09:58:10 +0100 Subject: realwallpaper: add subsolar/lunar points --- krebs/5pkgs/simple/realwallpaper/default.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/krebs/5pkgs/simple/realwallpaper/default.nix b/krebs/5pkgs/simple/realwallpaper/default.nix index 3f75e9e1e..b46cf08c1 100644 --- a/krebs/5pkgs/simple/realwallpaper/default.nix +++ b/krebs/5pkgs/simple/realwallpaper/default.nix @@ -128,6 +128,8 @@ pkgs.writers.writeDashBin "generate-wallpaper" '' # create marker file from json if [ -s marker.json ]; then jq -r 'to_entries[] | @json "\(.value.latitude) \(.value.longitude)"' marker.json > marker_file + echo 'position=sun image=subsolar.png transparent={255,255,255}' >> marker_file + echo 'position=moon image=sublunar.png transparent={255,255,255}' >> marker_file fi # make all unmodified files as final -- cgit v1.2.3 From e4816a16f9144f4267856f87aa2879fff277730d Mon Sep 17 00:00:00 2001 From: lassulus Date: Mon, 23 Mar 2020 13:05:43 +0100 Subject: realwallpaper: use new sun/moon icons --- krebs/5pkgs/simple/realwallpaper/default.nix | 30 ++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/krebs/5pkgs/simple/realwallpaper/default.nix b/krebs/5pkgs/simple/realwallpaper/default.nix index b46cf08c1..62d88e1e9 100644 --- a/krebs/5pkgs/simple/realwallpaper/default.nix +++ b/krebs/5pkgs/simple/realwallpaper/default.nix @@ -64,12 +64,17 @@ pkgs.writers.writeDashBin "generate-wallpaper" '' cd "$working_dir" # fetch source images in parallel - fetch nightmap-raw.jpg \ - "$nightmap_url" & - fetch daymap-raw.png \ - "$daymap_url" & - fetch marker.json \ - "$marker_url" & + # fetch basic images which should not change + test -e nightmap-raw.jpg || fetch nightmap-raw.jpg "$nightmap_url" & + test -e sun-raw.png || fetch sun-raw.png \ + "http://simpleicon.com/wp-content/uploads/sun-64x64.png" & + + test -e moon-raw.png || fetch moon-raw.png \ + "http://simpleicon.com/wp-content/uploads/moon__star-64x64.png" & + + # regular fetches + fetch daymap-raw.png "$daymap_url" & + fetch marker.json "$marker_url" & wait ${pkgs.nomads-cloud}/bin/nomads-cloud clouds-raw.png @@ -112,6 +117,14 @@ pkgs.writers.writeDashBin "generate-wallpaper" '' convert nightmap.png -threshold 25% nightmap-lightmask.png fi + if needs_rebuild sun.png sun-raw.png; then + convert sun-raw.png -fill gold -opaque black -resize 50% PNG64:sun.png + fi + + if needs_rebuild moon.png moon-raw.png; then + convert moon-raw.png -fill royalblue -opaque black -resize 50% PNG64:moon.png + fi + # create layers make_layer nightmap-snowlayer.png nightmap-fullsnow.png daymap-snowmask.png make_layer nightmap-lightlayer.png nightmap.png nightmap-lightmask.png @@ -125,11 +138,12 @@ pkgs.writers.writeDashBin "generate-wallpaper" '' nightmap-lightsnowlayer.png \ nightmap.png + # create marker file from json if [ -s marker.json ]; then jq -r 'to_entries[] | @json "\(.value.latitude) \(.value.longitude)"' marker.json > marker_file - echo 'position=sun image=subsolar.png transparent={255,255,255}' >> marker_file - echo 'position=moon image=sublunar.png transparent={255,255,255}' >> marker_file + echo 'position=sun image=sun.png' >> marker_file + echo 'position=moon image=moon.png' >> marker_file fi # make all unmodified files as final -- cgit v1.2.3 From e2ef8aba938fb39f826014de919471c7ce751d83 Mon Sep 17 00:00:00 2001 From: lassulus Date: Mon, 23 Mar 2020 13:05:55 +0100 Subject: fetch clouds only every 3h --- krebs/5pkgs/simple/realwallpaper/default.nix | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/krebs/5pkgs/simple/realwallpaper/default.nix b/krebs/5pkgs/simple/realwallpaper/default.nix index 62d88e1e9..f81f96efe 100644 --- a/krebs/5pkgs/simple/realwallpaper/default.nix +++ b/krebs/5pkgs/simple/realwallpaper/default.nix @@ -77,7 +77,10 @@ pkgs.writers.writeDashBin "generate-wallpaper" '' fetch marker.json "$marker_url" & wait - ${pkgs.nomads-cloud}/bin/nomads-cloud clouds-raw.png + # fetch clouds if they are older than 3h + if ! test "$(find clouds-raw.png -mmin -180)"; then + ${pkgs.nomads-cloud}/bin/nomads-cloud clouds-raw.png + fi check_type nightmap-raw.jpg image check_type daymap-raw.png image -- cgit v1.2.3 From 119b56956c8bcb992c86ca8d0e854884e7c44695 Mon Sep 17 00:00:00 2001 From: lassulus Date: Mon, 23 Mar 2020 18:47:23 +0100 Subject: nomads-cloud: double sqrt for better clouds --- krebs/5pkgs/simple/nomads-cloud/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/krebs/5pkgs/simple/nomads-cloud/default.nix b/krebs/5pkgs/simple/nomads-cloud/default.nix index 2af74dc44..9c39de891 100644 --- a/krebs/5pkgs/simple/nomads-cloud/default.nix +++ b/krebs/5pkgs/simple/nomads-cloud/default.nix @@ -22,7 +22,7 @@ writers.writeDashBin "nomads-cloud" '' height=$(${jq}/bin/jq '.[0].header.ny' < "$json_path") # The maximum gray value. Must be bigger than 0 and less than 65536. - maxval=256 + maxval=1000 # pgm - Netpbm grayscale image format # http://netpbm.sourceforge.net/doc/pgm.html @@ -32,7 +32,7 @@ writers.writeDashBin "nomads-cloud" '' echo "$maxval" cat "$json_path" | ${jq}/bin/jq --argjson maxval "$maxval" -c ' - .[0].data[] * $maxval | round + ((.[0].data[] | sqrt | sqrt) * $maxval | round) ' | ${findutils}/bin/xargs -n "$width" } > "$pgm_path" -- cgit v1.2.3 From e5cbe0cbe17a63854efc0271c1ae0d922a23572d Mon Sep 17 00:00:00 2001 From: lassulus Date: Mon, 23 Mar 2020 20:28:29 +0100 Subject: realwallpaper: use cloud_gamme instead of sqrt hack --- krebs/5pkgs/simple/nomads-cloud/default.nix | 2 +- krebs/5pkgs/simple/realwallpaper/default.nix | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/krebs/5pkgs/simple/nomads-cloud/default.nix b/krebs/5pkgs/simple/nomads-cloud/default.nix index 9c39de891..6e4ace484 100644 --- a/krebs/5pkgs/simple/nomads-cloud/default.nix +++ b/krebs/5pkgs/simple/nomads-cloud/default.nix @@ -32,7 +32,7 @@ writers.writeDashBin "nomads-cloud" '' echo "$maxval" cat "$json_path" | ${jq}/bin/jq --argjson maxval "$maxval" -c ' - ((.[0].data[] | sqrt | sqrt) * $maxval | round) + ((.[0].data[]) * $maxval | round) ' | ${findutils}/bin/xargs -n "$width" } > "$pgm_path" diff --git a/krebs/5pkgs/simple/realwallpaper/default.nix b/krebs/5pkgs/simple/realwallpaper/default.nix index f81f96efe..d28f20cb6 100644 --- a/krebs/5pkgs/simple/realwallpaper/default.nix +++ b/krebs/5pkgs/simple/realwallpaper/default.nix @@ -169,7 +169,8 @@ pkgs.writers.writeDashBin "generate-wallpaper" '' map=daymap-final.png night_map=nightmap-final.png cloud_map=clouds-final.png - cloud_threshold=10 + cloud_threshold=1 + cloud_gamma=2.5 shade=15 ''} @@ -181,7 +182,8 @@ pkgs.writers.writeDashBin "generate-wallpaper" '' map=daymap-final.png night_map=nightmap-final.png cloud_map=clouds-final.png - cloud_threshold=10 + cloud_threshold=1 + cloud_gamma=2.5 marker_file=marker_file shade=15 ''} -- cgit v1.2.3 From 4337f9dbce769cf64eba0c9ade8097145e782a83 Mon Sep 17 00:00:00 2001 From: lassulus Date: Tue, 24 Mar 2020 10:12:23 +0100 Subject: realwallpaper: add chlora water layer --- krebs/5pkgs/simple/realwallpaper/default.nix | 49 +++++++++++++++++++++------- 1 file changed, 37 insertions(+), 12 deletions(-) diff --git a/krebs/5pkgs/simple/realwallpaper/default.nix b/krebs/5pkgs/simple/realwallpaper/default.nix index d28f20cb6..9be8f7c7c 100644 --- a/krebs/5pkgs/simple/realwallpaper/default.nix +++ b/krebs/5pkgs/simple/realwallpaper/default.nix @@ -73,8 +73,22 @@ pkgs.writers.writeDashBin "generate-wallpaper" '' "http://simpleicon.com/wp-content/uploads/moon__star-64x64.png" & # regular fetches - fetch daymap-raw.png "$daymap_url" & fetch marker.json "$marker_url" & + + # fetch daymap twice daily + if ! test "$(find daymap-raw.png -mmin -720)"; then + fetch daymap-raw.png "$daymap_url" & + fi + + # fetch cholrophyl once every week + chlora_url=$(curl -Ss \ + 'https://neo.sci.gsfc.nasa.gov/view.php?datasetId=MY1DMM_CHLORA&date=2999-12-31' \ + | grep '3600 x 1800' | sed 's/.*href="\([^"]*\)".*/\1/') + + if ! test "$(find chlora-raw.jpg -mtime -7)"; then + fetch chlora-raw.jpg "$chlora_url" & + fi + wait # fetch clouds if they are older than 3h @@ -96,6 +110,7 @@ pkgs.writers.writeDashBin "generate-wallpaper" '' nightmap-raw.jpg \ daymap-raw.png \ clouds-raw.png \ + chlora-raw.jpg \ ; do normal=''${raw%-raw.*}.png @@ -105,7 +120,26 @@ pkgs.writers.writeDashBin "generate-wallpaper" '' fi done - # create nightmap-fullsnow + if needs_rebuild sun.png sun-raw.png; then + convert sun-raw.png -fill gold -opaque black -resize 50% PNG64:sun.png + fi + + if needs_rebuild moon.png moon-raw.png; then + convert moon-raw.png -fill royalblue -opaque black -resize 50% PNG64:moon.png + fi + + # -- Daymap -- + + # merge with water chlora layer + convert daymap.png chlora.png -compose lighten -composite daymap-final.png + + # -- Nightmap -- + + # merge with water chlora layer + convert nightmap.png \( -fill black -colorize 70% chlora.png \) \ + -compose lighten -composite nightmap-chlora.png + + # create nightmap-fullsnow, a big blue picture if needs_rebuild nightmap-fullsnow.png; then convert -size $in_size xc:$nightsnow_color nightmap-fullsnow.png fi @@ -120,14 +154,6 @@ pkgs.writers.writeDashBin "generate-wallpaper" '' convert nightmap.png -threshold 25% nightmap-lightmask.png fi - if needs_rebuild sun.png sun-raw.png; then - convert sun-raw.png -fill gold -opaque black -resize 50% PNG64:sun.png - fi - - if needs_rebuild moon.png moon-raw.png; then - convert moon-raw.png -fill royalblue -opaque black -resize 50% PNG64:moon.png - fi - # create layers make_layer nightmap-snowlayer.png nightmap-fullsnow.png daymap-snowmask.png make_layer nightmap-lightlayer.png nightmap.png nightmap-lightmask.png @@ -139,7 +165,7 @@ pkgs.writers.writeDashBin "generate-wallpaper" '' flatten nightmap-final.png \ nightmap-lightsnowlayer.png \ - nightmap.png + nightmap-chlora.png # create marker file from json @@ -151,7 +177,6 @@ pkgs.writers.writeDashBin "generate-wallpaper" '' # make all unmodified files as final for normal in \ - daymap.png \ clouds.png \ ; do -- cgit v1.2.3 From c76f1618940ff188258212a0988d3de7525f9e9e Mon Sep 17 00:00:00 2001 From: lassulus Date: Wed, 25 Mar 2020 15:39:25 +0100 Subject: realwallpaper: redesign with new image sources --- krebs/3modules/realwallpaper.nix | 18 --- krebs/5pkgs/simple/realwallpaper/default.nix | 164 ++++++++++++--------------- 2 files changed, 73 insertions(+), 109 deletions(-) diff --git a/krebs/3modules/realwallpaper.nix b/krebs/3modules/realwallpaper.nix index a83758ccd..7a0052a4f 100644 --- a/krebs/3modules/realwallpaper.nix +++ b/krebs/3modules/realwallpaper.nix @@ -17,21 +17,6 @@ let default = "/var/realwallpaper/"; }; - nightmap = mkOption { - type = types.str; - default = "http://eoimages.gsfc.nasa.gov/images/imagerecords/55000/55167/earth_lights_lrg.jpg"; - }; - - daymap = mkOption { - type = types.str; - default = "https://www.nnvl.noaa.gov/images/globaldata/SnowIceCover_Daily.png"; - }; - - cloudmap = mkOption { - type = types.str; - default = "http://home.megapass.co.kr/~holywatr/cloud_data/clouds_2048.jpg"; - }; - marker = mkOption { type = types.str; default = "http://graph.r/marker.json"; @@ -67,9 +52,6 @@ let environment = { working_dir = cfg.workingDir; - nightmap_url = cfg.nightmap; - daymap_url = cfg.daymap; - cloudmap_url = cfg.cloudmap; marker_url = cfg.marker; }; diff --git a/krebs/5pkgs/simple/realwallpaper/default.nix b/krebs/5pkgs/simple/realwallpaper/default.nix index 9be8f7c7c..dfe03ff35 100644 --- a/krebs/5pkgs/simple/realwallpaper/default.nix +++ b/krebs/5pkgs/simple/realwallpaper/default.nix @@ -17,24 +17,28 @@ pkgs.writers.writeDashBin "generate-wallpaper" '' fi } - # usage: image_size FILENAME - image_size() { - identify "$1" | awk '{print$3}' + # check if file exists and fetch only if missing + fetch_once() { + name=$1 + url=$2 + test -e "$name" || fetch "$name" "$url" } - # usage: make_mask DST SRC MASK - make_layer() { - if needs_rebuild "$@"; then - echo "make $1 (apply mask)" >&2 - convert "$2" "$3" -alpha off -compose copy_opacity -composite "$1" + fetch_older_min() { + min=$1 + name=$2 + url=$3 + if ! test "$(find $name -mmin -$min)"; then + fetch "$name" "$url" fi } - # usage: flatten DST HILAYER LOLAYER - flatten() { - if needs_rebuild "$@"; then - echo "make $1 (flatten)" >&2 - composite "$2" "$3" "$1" + fetch_older_days() { + days=$1 + name=$2 + url=$3 + if ! test "$(find $name -mmin -$days)"; then + fetch "$name" "$url" fi } @@ -60,35 +64,36 @@ pkgs.writers.writeDashBin "generate-wallpaper" '' return $result } + get_neo_url() { + url=$1 + curl -Ss "$url" | grep '3600 x 1800' | sed 's/.*href="\([^"]*\)".*/\1/' + } + main() { cd "$working_dir" # fetch source images in parallel - # fetch basic images which should not change - test -e nightmap-raw.jpg || fetch nightmap-raw.jpg "$nightmap_url" & - test -e sun-raw.png || fetch sun-raw.png \ - "http://simpleicon.com/wp-content/uploads/sun-64x64.png" & - - test -e moon-raw.png || fetch moon-raw.png \ - "http://simpleicon.com/wp-content/uploads/moon__star-64x64.png" & + fetch_once sun-raw.png \ + 'http://simpleicon.com/wp-content/uploads/sun-64x64.png' & + fetch_once moon-raw.png \ + 'http://simpleicon.com/wp-content/uploads/moon__star-64x64.png' & + fetch_once nightmap-raw.jpg \ + 'https://eoimages.gsfc.nasa.gov/images/imagerecords/144000/144898/BlackMarble_2016_3km.jpg' & + fetch_once daymap-raw.tif \ + 'https://eoimages.gsfc.nasa.gov/images/imagerecords/57000/57752/land_shallow_topo_8192.tif' & + + fetch_older_min 720 ice-raw.jpg $(get_neo_url \ + 'https://neo.sci.gsfc.nasa.gov/view.php?datasetId=NISE_D') & + fetch_older_days 3 snow-raw.jpg $(get_neo_url \ + 'https://neo.sci.gsfc.nasa.gov/view.php?datasetId=MOD10C1_E_SNOW') & + fetch_older_days 7 chlora-raw.jpg $(get_neo_url \ + 'https://neo.sci.gsfc.nasa.gov/view.php?datasetId=MY1DMM_CHLORA') & + fetch_older_days 3 fire-raw.jpg $(get_neo_url \ + 'https://neo.sci.gsfc.nasa.gov/view.php?datasetId=MOD14A1_E_FIRE') & # regular fetches fetch marker.json "$marker_url" & - # fetch daymap twice daily - if ! test "$(find daymap-raw.png -mmin -720)"; then - fetch daymap-raw.png "$daymap_url" & - fi - - # fetch cholrophyl once every week - chlora_url=$(curl -Ss \ - 'https://neo.sci.gsfc.nasa.gov/view.php?datasetId=MY1DMM_CHLORA&date=2999-12-31' \ - | grep '3600 x 1800' | sed 's/.*href="\([^"]*\)".*/\1/') - - if ! test "$(find chlora-raw.jpg -mtime -7)"; then - fetch chlora-raw.jpg "$chlora_url" & - fi - wait # fetch clouds if they are older than 3h @@ -96,21 +101,26 @@ pkgs.writers.writeDashBin "generate-wallpaper" '' ${pkgs.nomads-cloud}/bin/nomads-cloud clouds-raw.png fi + check_type sun-raw.png image + check_type moon-raw.png image check_type nightmap-raw.jpg image - check_type daymap-raw.png image + check_type daymap-raw.tif image + check_type ice-raw.jpg image + check_type snow-raw.jpg image + check_type chlora-raw.jpg image + check_type fire-raw.jpg image check_type clouds-raw.png image - in_size=2048x1024 + in_size=3600x1800 xplanet_out_size=1466x1200 out_geometry=1366x768+100+160 - nightsnow_color='#0c1a49' # nightmap - for raw in \ nightmap-raw.jpg \ - daymap-raw.png \ - clouds-raw.png \ + daymap-raw.tif \ + snow-raw.jpg \ chlora-raw.jpg \ + clouds-raw.png \ ; do normal=''${raw%-raw.*}.png @@ -120,6 +130,16 @@ pkgs.writers.writeDashBin "generate-wallpaper" '' fi done + # remove snow from ice map + if needs_rebuild ice.png ice-raw.jpg; then + convert ice-raw.jpg -fuzz 20% -fill black -opaque white -scale "$in_size" ice.png + fi + + # make fire more red + if needs_rebuild fire.png fire-raw.jpg; then + convert fire-raw.jpg -fuzz 20% -fill '#ef840c' -opaque white -scale "$in_size" fire.png + fi + if needs_rebuild sun.png sun-raw.png; then convert sun-raw.png -fill gold -opaque black -resize 50% PNG64:sun.png fi @@ -131,60 +151,22 @@ pkgs.writers.writeDashBin "generate-wallpaper" '' # -- Daymap -- # merge with water chlora layer - convert daymap.png chlora.png -compose lighten -composite daymap-final.png - - # -- Nightmap -- - - # merge with water chlora layer - convert nightmap.png \( -fill black -colorize 70% chlora.png \) \ - -compose lighten -composite nightmap-chlora.png - - # create nightmap-fullsnow, a big blue picture - if needs_rebuild nightmap-fullsnow.png; then - convert -size $in_size xc:$nightsnow_color nightmap-fullsnow.png - fi - - # extract daymap-snowmask from daymap-final - if needs_rebuild daymap-snowmask.png daymap.png; then - convert daymap.png -threshold 95% daymap-snowmask.png - fi - - # extract nightmap-lightmask from nightmap - if needs_rebuild nightmap-lightmask.png nightmap.png; then - convert nightmap.png -threshold 25% nightmap-lightmask.png + if needs_rebuild daymap-final.png daymap.png fire.png snow.png ice.png chlora.png; then + convert daymap.png fire.png -compose lighten -composite daymap-1.png + convert daymap-1.png ice.png -compose lighten -composite daymap-2.png + convert daymap-2.png snow.png -compose lighten -composite daymap-3.png + convert daymap-3.png chlora.png -compose lighten -composite daymap-final.png fi - # create layers - make_layer nightmap-snowlayer.png nightmap-fullsnow.png daymap-snowmask.png - make_layer nightmap-lightlayer.png nightmap.png nightmap-lightmask.png - - # apply layers - flatten nightmap-lightsnowlayer.png \ - nightmap-lightlayer.png \ - nightmap-snowlayer.png - - flatten nightmap-final.png \ - nightmap-lightsnowlayer.png \ - nightmap-chlora.png - + # -- Nightmap -- - # create marker file from json - if [ -s marker.json ]; then - jq -r 'to_entries[] | @json "\(.value.latitude) \(.value.longitude)"' marker.json > marker_file - echo 'position=sun image=sun.png' >> marker_file - echo 'position=moon image=moon.png' >> marker_file + if needs_rebuild nightmap-final.png nightmap.png fire.png snow.png ice.png chlora.png; then + convert nightmap.png fire.png -compose lighten -composite nightmap-1.png + convert nightmap-1.png \( -fill black -colorize 70% ice.png \) -compose lighten -composite nightmap-2.png + convert nightmap-2.png \( -fill black -colorize 70% snow.png \) -compose lighten -composite nightmap-3.png + convert nightmap-3.png \( -fill black -colorize 70% chlora.png \) -compose lighten -composite nightmap-final.png fi - # make all unmodified files as final - for normal in \ - clouds.png \ - ; - do - final=''${normal%.png}-final.png - needs_rebuild $final && - ln $normal $final - done - # rebuild every time to update shadow xplanet --num_times 1 --geometry $xplanet_out_size \ --output xplanet-output.png --projection merc \ @@ -193,7 +175,7 @@ pkgs.writers.writeDashBin "generate-wallpaper" '' "Earth" map=daymap-final.png night_map=nightmap-final.png - cloud_map=clouds-final.png + cloud_map=clouds.png cloud_threshold=1 cloud_gamma=2.5 shade=15 @@ -206,7 +188,7 @@ pkgs.writers.writeDashBin "generate-wallpaper" '' "Earth" map=daymap-final.png night_map=nightmap-final.png - cloud_map=clouds-final.png + cloud_map=clouds.png cloud_threshold=1 cloud_gamma=2.5 marker_file=marker_file -- cgit v1.2.3 From a0347a6443ac07bbb986080dafe44af4a25e0f98 Mon Sep 17 00:00:00 2001 From: lassulus Date: Wed, 25 Mar 2020 18:14:04 +0100 Subject: realwallpaper: add HD version with planets and krebs --- krebs/3modules/realwallpaper.nix | 1 + krebs/5pkgs/simple/realwallpaper/default.nix | 90 ++++++++++++++++++++++++++-- 2 files changed, 87 insertions(+), 4 deletions(-) diff --git a/krebs/3modules/realwallpaper.nix b/krebs/3modules/realwallpaper.nix index 7a0052a4f..cfa8a65ba 100644 --- a/krebs/3modules/realwallpaper.nix +++ b/krebs/3modules/realwallpaper.nix @@ -45,6 +45,7 @@ let path = with pkgs; [ xplanet imagemagick + inkscape curl file jq diff --git a/krebs/5pkgs/simple/realwallpaper/default.nix b/krebs/5pkgs/simple/realwallpaper/default.nix index dfe03ff35..1dd5e00e8 100644 --- a/krebs/5pkgs/simple/realwallpaper/default.nix +++ b/krebs/5pkgs/simple/realwallpaper/default.nix @@ -82,6 +82,24 @@ pkgs.writers.writeDashBin "generate-wallpaper" '' fetch_once daymap-raw.tif \ 'https://eoimages.gsfc.nasa.gov/images/imagerecords/57000/57752/land_shallow_topo_8192.tif' & + fetch_once mercury-raw.svg \ + 'https://upload.wikimedia.org/wikipedia/commons/2/2e/Mercury_symbol.svg' & + fetch_once venus-raw.svg \ + 'https://upload.wikimedia.org/wikipedia/commons/6/66/Venus_symbol.svg' & + fetch_once mars-raw.svg \ + 'https://upload.wikimedia.org/wikipedia/commons/b/b7/Mars_symbol.svg' & + fetch_once jupiter-raw.svg \ + 'https://upload.wikimedia.org/wikipedia/commons/2/26/Jupiter_symbol.svg' & + fetch_once saturn-raw.svg \ + 'https://upload.wikimedia.org/wikipedia/commons/7/74/Saturn_symbol.svg' & + fetch_once uranus-raw.svg \ + 'https://upload.wikimedia.org/wikipedia/commons/f/f1/Uranus_symbol.svg' & + fetch_once neptune-raw.svg \ + 'https://upload.wikimedia.org/wikipedia/commons/4/47/Neptune_symbol.svg' & + + fetch_once krebs-raw.svg \ + 'https://raw.githubusercontent.com/krebs/painload/master/cholerab/bling/krebs_aquarium.svg' & + fetch_older_min 720 ice-raw.jpg $(get_neo_url \ 'https://neo.sci.gsfc.nasa.gov/view.php?datasetId=NISE_D') & fetch_older_days 3 snow-raw.jpg $(get_neo_url \ @@ -111,9 +129,19 @@ pkgs.writers.writeDashBin "generate-wallpaper" '' check_type fire-raw.jpg image check_type clouds-raw.png image + check_type mercury-raw.svg image + check_type venus-raw.svg image + check_type mars-raw.svg image + check_type jupiter-raw.svg image + check_type saturn-raw.svg image + check_type uranus-raw.svg image + check_type neptune-raw.svg image + + check_type krebs-raw.svg image + in_size=3600x1800 - xplanet_out_size=1466x1200 - out_geometry=1366x768+100+160 + xplanet_out_size=3600x2950 + out_geometry=3200x1800+300+400 for raw in \ nightmap-raw.jpg \ @@ -141,11 +169,52 @@ pkgs.writers.writeDashBin "generate-wallpaper" '' fi if needs_rebuild sun.png sun-raw.png; then - convert sun-raw.png -fill gold -opaque black -resize 50% PNG64:sun.png + convert sun-raw.png -fill gold -opaque black PNG64:sun.png fi if needs_rebuild moon.png moon-raw.png; then - convert moon-raw.png -fill royalblue -opaque black -resize 50% PNG64:moon.png + convert moon-raw.png -fill royalblue -opaque black PNG64:moon.png + fi + + # -- Planets -- + + if needs_rebuild mercury.png mercury-raw.svg; then + sed -i 's/#000/#A6A6A6/g' mercury-raw.svg + inkscape -z -e mercury.png -w 40 -h 40 mercury-raw.svg + fi + + if needs_rebuild venus.png venus-raw.svg; then + sed -i 's/#000/#C40B98/g' venus-raw.svg + inkscape -z -e venus.png -w 40 -h 40 venus-raw.svg + fi + + if needs_rebuild mars.png mars-raw.svg; then + sed -i 's/#000/#E35A5C/g' mars-raw.svg + inkscape -z -e mars.png -w 40 -h 40 mars-raw.svg + fi + + if needs_rebuild jupiter.png jupiter-raw.svg; then + sed -i 's/#000/#DEA182/g' jupiter-raw.svg + inkscape -z -e jupiter.png -w 40 -h 40 jupiter-raw.svg + fi + + if needs_rebuild saturn.png saturn-raw.svg; then + sed -i 's/#000/#E4C282/g' saturn-raw.svg + inkscape -z -e saturn.png -w 40 -h 40 saturn-raw.svg + fi + + if needs_rebuild uranus.png uranus-raw.svg; then + sed -i 's/#000/#97BCC2/g' uranus-raw.svg + inkscape -z -e uranus.png -w 40 -h 40 uranus-raw.svg + fi + + if needs_rebuild neptune.png neptune-raw.svg; then + sed -i 's/#000/#274687/g' neptune-raw.svg + inkscape -z -e neptune.png -w 40 -h 40 neptune-raw.svg + fi + + if needs_rebuild krebs.png krebs-raw.svg; then + inkscape -z -e krebs.png -w 16 -h 16 krebs-raw.svg fi # -- Daymap -- @@ -167,6 +236,19 @@ pkgs.writers.writeDashBin "generate-wallpaper" '' convert nightmap-3.png \( -fill black -colorize 70% chlora.png \) -compose lighten -composite nightmap-final.png fi + # create marker file from json + if [ -s marker.json ]; then + jq -r 'to_entries[] | @json "\(.value.latitude) \(.value.longitude) image=krebs.png"' marker.json > marker_file + echo 'position=sun image=sun.png' >> marker_file + echo 'position=moon image=moon.png' >> marker_file + echo 'position=mercury image=mercury.png' >> marker_file + echo 'position=venus image=venus.png' >> marker_file + echo 'position=mars image=mars.png' >> marker_file + echo 'position=jupiter image=jupiter.png' >> marker_file + echo 'position=uranus image=uranus.png' >> marker_file + echo 'position=neptune image=neptune.png' >> marker_file + fi + # rebuild every time to update shadow xplanet --num_times 1 --geometry $xplanet_out_size \ --output xplanet-output.png --projection merc \ -- cgit v1.2.3 From a998c96889dd314c8b58c39adac5747ae2cc0c72 Mon Sep 17 00:00:00 2001 From: lassulus Date: Wed, 25 Mar 2020 19:11:53 +0100 Subject: realwallpaper: fix fetch_older_days --- krebs/5pkgs/simple/realwallpaper/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/krebs/5pkgs/simple/realwallpaper/default.nix b/krebs/5pkgs/simple/realwallpaper/default.nix index 1dd5e00e8..ce0c6067e 100644 --- a/krebs/5pkgs/simple/realwallpaper/default.nix +++ b/krebs/5pkgs/simple/realwallpaper/default.nix @@ -37,7 +37,7 @@ pkgs.writers.writeDashBin "generate-wallpaper" '' days=$1 name=$2 url=$3 - if ! test "$(find $name -mmin -$days)"; then + if ! test "$(find $name -mtime -$days)"; then fetch "$name" "$url" fi } -- cgit v1.2.3 From 013fcd7d47c7526254963888fa6d4476d9e55d14 Mon Sep 17 00:00:00 2001 From: lassulus Date: Wed, 25 Mar 2020 19:12:18 +0100 Subject: realwallpaper: show more earth --- krebs/5pkgs/simple/realwallpaper/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/krebs/5pkgs/simple/realwallpaper/default.nix b/krebs/5pkgs/simple/realwallpaper/default.nix index ce0c6067e..c2ca0498b 100644 --- a/krebs/5pkgs/simple/realwallpaper/default.nix +++ b/krebs/5pkgs/simple/realwallpaper/default.nix @@ -140,8 +140,8 @@ pkgs.writers.writeDashBin "generate-wallpaper" '' check_type krebs-raw.svg image in_size=3600x1800 - xplanet_out_size=3600x2950 - out_geometry=3200x1800+300+400 + xplanet_out_size=3200x2500 + out_geometry=3200x1800+100+350 for raw in \ nightmap-raw.jpg \ -- cgit v1.2.3 From c08493708f789de9046f6fae00d89092b3786cf0 Mon Sep 17 00:00:00 2001 From: lassulus Date: Wed, 25 Mar 2020 19:12:31 +0100 Subject: realwallpaper: more clouds --- krebs/5pkgs/simple/realwallpaper/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/krebs/5pkgs/simple/realwallpaper/default.nix b/krebs/5pkgs/simple/realwallpaper/default.nix index c2ca0498b..d2e49fcaf 100644 --- a/krebs/5pkgs/simple/realwallpaper/default.nix +++ b/krebs/5pkgs/simple/realwallpaper/default.nix @@ -259,7 +259,7 @@ pkgs.writers.writeDashBin "generate-wallpaper" '' night_map=nightmap-final.png cloud_map=clouds.png cloud_threshold=1 - cloud_gamma=2.5 + cloud_gamma=6 shade=15 ''} @@ -272,7 +272,7 @@ pkgs.writers.writeDashBin "generate-wallpaper" '' night_map=nightmap-final.png cloud_map=clouds.png cloud_threshold=1 - cloud_gamma=2.5 + cloud_gamma=6 marker_file=marker_file shade=15 ''} -- cgit v1.2.3 From a91fff125a3b46533db667d45493e107e9d83eea Mon Sep 17 00:00:00 2001 From: lassulus Date: Wed, 25 Mar 2020 20:07:45 +0100 Subject: realwallpaper: show full horizontal size --- krebs/5pkgs/simple/realwallpaper/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/krebs/5pkgs/simple/realwallpaper/default.nix b/krebs/5pkgs/simple/realwallpaper/default.nix index d2e49fcaf..9298ef8ed 100644 --- a/krebs/5pkgs/simple/realwallpaper/default.nix +++ b/krebs/5pkgs/simple/realwallpaper/default.nix @@ -141,7 +141,7 @@ pkgs.writers.writeDashBin "generate-wallpaper" '' in_size=3600x1800 xplanet_out_size=3200x2500 - out_geometry=3200x1800+100+350 + out_geometry=3200x1800+0+350 for raw in \ nightmap-raw.jpg \ -- cgit v1.2.3 From 6b3c216571f75ab39653f2a2bad5bc20c83b5c27 Mon Sep 17 00:00:00 2001 From: lassulus Date: Wed, 25 Mar 2020 20:08:03 +0100 Subject: realwallpaper: darker snow --- krebs/5pkgs/simple/realwallpaper/default.nix | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/krebs/5pkgs/simple/realwallpaper/default.nix b/krebs/5pkgs/simple/realwallpaper/default.nix index 9298ef8ed..81c4c0f67 100644 --- a/krebs/5pkgs/simple/realwallpaper/default.nix +++ b/krebs/5pkgs/simple/realwallpaper/default.nix @@ -146,7 +146,6 @@ pkgs.writers.writeDashBin "generate-wallpaper" '' for raw in \ nightmap-raw.jpg \ daymap-raw.tif \ - snow-raw.jpg \ chlora-raw.jpg \ clouds-raw.png \ ; @@ -163,6 +162,10 @@ pkgs.writers.writeDashBin "generate-wallpaper" '' convert ice-raw.jpg -fuzz 20% -fill black -opaque white -scale "$in_size" ice.png fi + if needs_rebuild snow.png snow-raw.jpg; then + convert snow-raw.jpg -fuzz 20% -fill '#DEDEDE' -opaque white -scale "$in_size" snow.png + fi + # make fire more red if needs_rebuild fire.png fire-raw.jpg; then convert fire-raw.jpg -fuzz 20% -fill '#ef840c' -opaque white -scale "$in_size" fire.png -- cgit v1.2.3 From b7b84cd4c9b41b4452bffb988650f49abdd10a79 Mon Sep 17 00:00:00 2001 From: lassulus Date: Wed, 25 Mar 2020 20:08:18 +0100 Subject: realwallpaper: add missing saturn --- krebs/5pkgs/simple/realwallpaper/default.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/krebs/5pkgs/simple/realwallpaper/default.nix b/krebs/5pkgs/simple/realwallpaper/default.nix index 81c4c0f67..65493d18e 100644 --- a/krebs/5pkgs/simple/realwallpaper/default.nix +++ b/krebs/5pkgs/simple/realwallpaper/default.nix @@ -248,6 +248,7 @@ pkgs.writers.writeDashBin "generate-wallpaper" '' echo 'position=venus image=venus.png' >> marker_file echo 'position=mars image=mars.png' >> marker_file echo 'position=jupiter image=jupiter.png' >> marker_file + echo 'position=saturn image=saturn.png' >> marker_file echo 'position=uranus image=uranus.png' >> marker_file echo 'position=neptune image=neptune.png' >> marker_file fi -- cgit v1.2.3 From c9490c38abccb9ea085fb315d7a8d0085a61e495 Mon Sep 17 00:00:00 2001 From: lassulus Date: Thu, 26 Mar 2020 17:00:27 +0100 Subject: realwallpaper: even more clouds --- krebs/5pkgs/simple/realwallpaper/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/krebs/5pkgs/simple/realwallpaper/default.nix b/krebs/5pkgs/simple/realwallpaper/default.nix index 65493d18e..141e29117 100644 --- a/krebs/5pkgs/simple/realwallpaper/default.nix +++ b/krebs/5pkgs/simple/realwallpaper/default.nix @@ -263,7 +263,7 @@ pkgs.writers.writeDashBin "generate-wallpaper" '' night_map=nightmap-final.png cloud_map=clouds.png cloud_threshold=1 - cloud_gamma=6 + cloud_gamma=10 shade=15 ''} @@ -276,7 +276,7 @@ pkgs.writers.writeDashBin "generate-wallpaper" '' night_map=nightmap-final.png cloud_map=clouds.png cloud_threshold=1 - cloud_gamma=6 + cloud_gamma=10 marker_file=marker_file shade=15 ''} -- cgit v1.2.3 From 4e6981bc5ce17b9e9743f8c006375cec34609099 Mon Sep 17 00:00:00 2001 From: lassulus Date: Sat, 28 Mar 2020 18:51:43 +0100 Subject: nixpkgs: bf7c0f0 -> 598a9cb --- krebs/nixpkgs.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/krebs/nixpkgs.json b/krebs/nixpkgs.json index c5665a70a..123d624d8 100644 --- a/krebs/nixpkgs.json +++ b/krebs/nixpkgs.json @@ -1,7 +1,7 @@ { "url": "https://github.com/NixOS/nixpkgs-channels", - "rev": "bf7c0f0461e047bec108a5c5d5d1b144289a65ba", - "date": "2020-03-17T13:04:05+00:00", - "sha256": "01dsh9932x6xcba2p0xg4n563b85i3p7s2sakj7yf2ws8pgmwhq9", + "rev": "598a9cbed6348ebda43c6b1a9a3061e0206297e7", + "date": "2020-03-28T03:06:32+01:00", + "sha256": "12m910j2sfhm3a6skw4janxy010gzdxp15bn8v9w7w9hhjzvdw8c", "fetchSubmodules": false } -- cgit v1.2.3 From 897129926bf9c882831b76c331bc662cc170d0f6 Mon Sep 17 00:00:00 2001 From: lassulus Date: Sat, 28 Mar 2020 18:54:51 +0100 Subject: jeschli: pin emacs-overlay version --- jeschli/2configs/emacs.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jeschli/2configs/emacs.nix b/jeschli/2configs/emacs.nix index f866bbca9..1ede96232 100644 --- a/jeschli/2configs/emacs.nix +++ b/jeschli/2configs/emacs.nix @@ -4,7 +4,7 @@ let pkgsWithOverlay = import { overlays = [ (import (builtins.fetchTarball { - url = https://github.com/nix-community/emacs-overlay/archive/master.tar.gz; + url = https://github.com/nix-community/emacs-overlay/archive/403c14c23be188b58c0b1bc197b428041d8a0cea.tar.gz; })) ]; }; -- cgit v1.2.3 From a29d406c681dcc95230db76cc6f0038b98b8adbd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Sun, 2 Feb 2020 12:48:15 +0000 Subject: m: drop idontcare, add herbert --- krebs/3modules/external/mic92.nix | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/krebs/3modules/external/mic92.nix b/krebs/3modules/external/mic92.nix index a748b1454..23ab4f684 100644 --- a/krebs/3modules/external/mic92.nix +++ b/krebs/3modules/external/mic92.nix @@ -144,24 +144,24 @@ in { }; }; }; - idontcare = { + herbert = { owner = config.krebs.users.Mic92; nets = rec { retiolum = { addrs = [ - config.krebs.hosts.idontcare.nets.retiolum.ip4.addr - config.krebs.hosts.idontcare.nets.retiolum.ip6.addr + config.krebs.hosts.herbert.nets.retiolum.ip4.addr + config.krebs.hosts.herbert.nets.retiolum.ip6.addr ]; ip4.addr = "10.243.29.177"; - aliases = [ "idontcare.r" ]; + aliases = [ "herbert.r" ]; tinc.pubkey = '' -----BEGIN RSA PUBLIC KEY----- - MIIBCgKCAQEAxmmbQLVXcnCU9Vg9TCoJxfq/RyNfzaTj8XJsn4Kpo3CvQOwFzL6O - qZnbG55WjPjPumuFgtUdHA/G8mgtrTVaIRbVE9ck2l2wWFzMWxORzuvDbMh5xP8A - OW2Z2qjlH6O9GTBCzpYyHuyBWCjtiN4x9zEqxkIsBARKOylAoy3zQIiiQF0d72An - lqKFi9vYUU90zo9rP8BTzx2ZsEWb28xhHUlwf1+vgaOHI1jI99gnr12dVYl/i/Hb - O28gDUogfpP/5pWFAHJ+53ZscHo8/Y7imjiKgGXmOHywoXOsKQ67M6ROEU/0xPnw - jKmq2p7zTJk2mDhphjePi5idd5yKNX5Q3wIDAQAB + MIIBCgKCAQEA7ZINr8YxVwHtcOR+ySpc9UjnJWsFXlOyu3CnrJ8IrY+mPA25UmNZ + stXd8QbJuxpad9HyPs294uW8UmXttEZzIwAlikVHasM5IQHVltudTTFvv7s3YFWd + /lgpHbo8zOA2mafx+Sr02Fy/lHjk6BTf8IOzdJIpUHZL/P+FUl9baBwGLmtbEvPh + fbvtf5QryBjJ9nRnb+wsPVpeFE/LncIMK/bYQsyE01T5QDu/muAaeYPbgm6FqaQH + OJ4oEHsarWBvU1qzgz/IRz0BHHeTrbbP3AG/glTwL02Z1mtTXSjME7cfk7ZRM5Cj + jXAqnqu2m1B08Kii+zYp4BPZDmPLT5gq+QIDAQAB -----END RSA PUBLIC KEY----- ''; }; -- cgit v1.2.3 From 274424528464d7f09e65df27a255c2a88af8547f Mon Sep 17 00:00:00 2001 From: lassulus Date: Mon, 30 Mar 2020 18:45:28 +0200 Subject: realwallpaper: render moon.png with xplanet --- krebs/5pkgs/simple/realwallpaper/default.nix | 60 ++++++++-------------------- 1 file changed, 16 insertions(+), 44 deletions(-) diff --git a/krebs/5pkgs/simple/realwallpaper/default.nix b/krebs/5pkgs/simple/realwallpaper/default.nix index 141e29117..a900a849b 100644 --- a/krebs/5pkgs/simple/realwallpaper/default.nix +++ b/krebs/5pkgs/simple/realwallpaper/default.nix @@ -75,8 +75,6 @@ pkgs.writers.writeDashBin "generate-wallpaper" '' # fetch source images in parallel fetch_once sun-raw.png \ 'http://simpleicon.com/wp-content/uploads/sun-64x64.png' & - fetch_once moon-raw.png \ - 'http://simpleicon.com/wp-content/uploads/moon__star-64x64.png' & fetch_once nightmap-raw.jpg \ 'https://eoimages.gsfc.nasa.gov/images/imagerecords/144000/144898/BlackMarble_2016_3km.jpg' & fetch_once daymap-raw.tif \ @@ -120,7 +118,6 @@ pkgs.writers.writeDashBin "generate-wallpaper" '' fi check_type sun-raw.png image - check_type moon-raw.png image check_type nightmap-raw.jpg image check_type daymap-raw.tif image check_type ice-raw.jpg image @@ -175,51 +172,18 @@ pkgs.writers.writeDashBin "generate-wallpaper" '' convert sun-raw.png -fill gold -opaque black PNG64:sun.png fi - if needs_rebuild moon.png moon-raw.png; then - convert moon-raw.png -fill royalblue -opaque black PNG64:moon.png - fi - - # -- Planets -- - - if needs_rebuild mercury.png mercury-raw.svg; then - sed -i 's/#000/#A6A6A6/g' mercury-raw.svg - inkscape -z -e mercury.png -w 40 -h 40 mercury-raw.svg - fi - - if needs_rebuild venus.png venus-raw.svg; then - sed -i 's/#000/#C40B98/g' venus-raw.svg - inkscape -z -e venus.png -w 40 -h 40 venus-raw.svg - fi - - if needs_rebuild mars.png mars-raw.svg; then - sed -i 's/#000/#E35A5C/g' mars-raw.svg - inkscape -z -e mars.png -w 40 -h 40 mars-raw.svg - fi - - if needs_rebuild jupiter.png jupiter-raw.svg; then - sed -i 's/#000/#DEA182/g' jupiter-raw.svg - inkscape -z -e jupiter.png -w 40 -h 40 jupiter-raw.svg - fi - - if needs_rebuild saturn.png saturn-raw.svg; then - sed -i 's/#000/#E4C282/g' saturn-raw.svg - inkscape -z -e saturn.png -w 40 -h 40 saturn-raw.svg - fi - - if needs_rebuild uranus.png uranus-raw.svg; then - sed -i 's/#000/#97BCC2/g' uranus-raw.svg - inkscape -z -e uranus.png -w 40 -h 40 uranus-raw.svg - fi - - if needs_rebuild neptune.png neptune-raw.svg; then - sed -i 's/#000/#274687/g' neptune-raw.svg - inkscape -z -e neptune.png -w 40 -h 40 neptune-raw.svg - fi - if needs_rebuild krebs.png krebs-raw.svg; then inkscape -z -e krebs.png -w 16 -h 16 krebs-raw.svg fi + # -- Planets -- + for planet in mercury venus mars jupiter saturn uranus neptune; do + if needs_rebuild "$planet".png "$planet"-raw.svg; then + sed -i 's/#000/#FFFF00/g' "$planet"-raw.svg + inkscape -z -e "$planet".png -w 40 -h 40 "$planet"-raw.svg + fi + done + # -- Daymap -- # merge with water chlora layer @@ -253,6 +217,14 @@ pkgs.writers.writeDashBin "generate-wallpaper" '' echo 'position=neptune image=neptune.png' >> marker_file fi + # generate moon + xplanet -body moon --num_times 1 -origin earth \ + --transpng moon.png --geometry 50x50 \ + -config ${pkgs.writeText "moon.config" '' + [moon] + shade=10 + ''} + # rebuild every time to update shadow xplanet --num_times 1 --geometry $xplanet_out_size \ --output xplanet-output.png --projection merc \ -- cgit v1.2.3 From 07592647d1c19ce4997be05b882f63fb6b562f47 Mon Sep 17 00:00:00 2001 From: lassulus Date: Tue, 31 Mar 2020 17:26:09 +0200 Subject: realwallpaper: get sun image from sdo --- krebs/5pkgs/simple/realwallpaper/default.nix | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/krebs/5pkgs/simple/realwallpaper/default.nix b/krebs/5pkgs/simple/realwallpaper/default.nix index a900a849b..00c185391 100644 --- a/krebs/5pkgs/simple/realwallpaper/default.nix +++ b/krebs/5pkgs/simple/realwallpaper/default.nix @@ -73,8 +73,6 @@ pkgs.writers.writeDashBin "generate-wallpaper" '' cd "$working_dir" # fetch source images in parallel - fetch_once sun-raw.png \ - 'http://simpleicon.com/wp-content/uploads/sun-64x64.png' & fetch_once nightmap-raw.jpg \ 'https://eoimages.gsfc.nasa.gov/images/imagerecords/144000/144898/BlackMarble_2016_3km.jpg' & fetch_once daymap-raw.tif \ @@ -109,6 +107,7 @@ pkgs.writers.writeDashBin "generate-wallpaper" '' # regular fetches fetch marker.json "$marker_url" & + fetch sun-raw.jpg 'https://sdo.gsfc.nasa.gov/assets/img/latest/latest_512_0171.jpg' & wait @@ -117,7 +116,7 @@ pkgs.writers.writeDashBin "generate-wallpaper" '' ${pkgs.nomads-cloud}/bin/nomads-cloud clouds-raw.png fi - check_type sun-raw.png image + check_type sun-raw.jpg image check_type nightmap-raw.jpg image check_type daymap-raw.tif image check_type ice-raw.jpg image @@ -168,8 +167,11 @@ pkgs.writers.writeDashBin "generate-wallpaper" '' convert fire-raw.jpg -fuzz 20% -fill '#ef840c' -opaque white -scale "$in_size" fire.png fi - if needs_rebuild sun.png sun-raw.png; then - convert sun-raw.png -fill gold -opaque black PNG64:sun.png + # cut out sun with alpha transparency + if needs_rebuild sun.png sun-raw.jpg; then + convert sun-raw.jpg \ + \( +clone -colorspace HSB -fill white -draw "circle 256,256 256,54" -separate -delete 0,1 \) \ + -compose copyopacity -composite -crop 512x472+0+20 -scale "100x100" sun.png fi if needs_rebuild krebs.png krebs-raw.svg; then @@ -179,7 +181,7 @@ pkgs.writers.writeDashBin "generate-wallpaper" '' # -- Planets -- for planet in mercury venus mars jupiter saturn uranus neptune; do if needs_rebuild "$planet".png "$planet"-raw.svg; then - sed -i 's/#000/#FFFF00/g' "$planet"-raw.svg + sed -i 's/#000/#FE8019/g' "$planet"-raw.svg inkscape -z -e "$planet".png -w 40 -h 40 "$planet"-raw.svg fi done -- cgit v1.2.3 From 5c6e007dbeb691cdadafa6615c5b23b40b6b77af Mon Sep 17 00:00:00 2001 From: lassulus Date: Tue, 31 Mar 2020 17:26:28 +0200 Subject: realwallpaper: archive old wallpapers --- krebs/5pkgs/simple/realwallpaper/default.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/krebs/5pkgs/simple/realwallpaper/default.nix b/krebs/5pkgs/simple/realwallpaper/default.nix index 00c185391..2b0f4bd53 100644 --- a/krebs/5pkgs/simple/realwallpaper/default.nix +++ b/krebs/5pkgs/simple/realwallpaper/default.nix @@ -266,6 +266,8 @@ pkgs.writers.writeDashBin "generate-wallpaper" '' convert xplanet-krebs-output.png -crop $out_geometry \ realwallpaper-krebs-tmp.png mv realwallpaper-krebs-tmp.png realwallpaper-krebs.png + mkdir -p archive + convert realwallpaper-krebs.png archive/"$(date -Is)".jpg fi } -- cgit v1.2.3 From c7bc2cb7c28c2542e549c76195eb9a9d9cbb8e96 Mon Sep 17 00:00:00 2001 From: lassulus Date: Sun, 5 Apr 2020 11:46:38 +0200 Subject: l radio: kill skipped tracks --- lass/2configs/radio.nix | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/lass/2configs/radio.nix b/lass/2configs/radio.nix index b24d7af3e..639caa178 100644 --- a/lass/2configs/radio.nix +++ b/lass/2configs/radio.nix @@ -9,13 +9,25 @@ let admin-password = import ; source-password = import ; + music_dir = "/home/radio/music"; + add_random = pkgs.writeDashBin "add_random" '' ${pkgs.mpc_cli}/bin/mpc add "$(${pkgs.mpc_cli}/bin/mpc ls the_playlist/music | grep '\.ogg$' | shuf -n1)" ''; skip_track = pkgs.writeDashBin "skip_track" '' ${add_random}/bin/add_random - echo skipping: "$(${print_current}/bin/print_current)" + current_track=$(${pkgs.mpc_cli}/bin/mpc current -f %file%) + track_infos=$(${print_current}/bin/print_current) + skip_count=$(${pkgs.attr}/bin/getfattr -n user.skip_count --only-values "$current_track" || echo 0) + if [ "$skip_count" -gt 2 ]; then + mv "$music_dir"/"$current_track" "$music_dir"/.graveyard/ + echo killing: "$track_infos" + else + skip_count=$((skip_count+1)) + ${pkgs.attr}/bin/setfattr -n user.skip_count -v "$skip_count" "$music_dir"/"$current_track" + echo skipping: "$track_infos" skip_count: "$skip_count" + fi ${pkgs.mpc_cli}/bin/mpc -q next ''; @@ -57,7 +69,7 @@ in { services.mpd = { enable = true; group = "radio"; - musicDirectory = "/home/radio/music"; + musicDirectory = "${music_dir}"; extraConfig = '' log_level "default" auto_update "yes" -- cgit v1.2.3 From e6b18f0f178fa47ddb46952de6d103e2904d519a Mon Sep 17 00:00:00 2001 From: lassulus Date: Sun, 5 Apr 2020 12:24:12 +0200 Subject: l radio skip_track: set music_dir --- lass/2configs/radio.nix | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lass/2configs/radio.nix b/lass/2configs/radio.nix index 639caa178..c89dc91e5 100644 --- a/lass/2configs/radio.nix +++ b/lass/2configs/radio.nix @@ -16,7 +16,10 @@ let ''; skip_track = pkgs.writeDashBin "skip_track" '' + set -eu + ${add_random}/bin/add_random + music_dir=${escapeShellArg music_dir} current_track=$(${pkgs.mpc_cli}/bin/mpc current -f %file%) track_infos=$(${print_current}/bin/print_current) skip_count=$(${pkgs.attr}/bin/getfattr -n user.skip_count --only-values "$current_track" || echo 0) -- cgit v1.2.3 From 0a9aa4bc575364ec7a4d477ea98325a8282fde56 Mon Sep 17 00:00:00 2001 From: lassulus Date: Wed, 8 Apr 2020 11:13:54 +0200 Subject: l radio: prefix commands with the_playlist: --- lass/2configs/radio.nix | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lass/2configs/radio.nix b/lass/2configs/radio.nix index c89dc91e5..1a5aadeba 100644 --- a/lass/2configs/radio.nix +++ b/lass/2configs/radio.nix @@ -22,7 +22,7 @@ let music_dir=${escapeShellArg music_dir} current_track=$(${pkgs.mpc_cli}/bin/mpc current -f %file%) track_infos=$(${print_current}/bin/print_current) - skip_count=$(${pkgs.attr}/bin/getfattr -n user.skip_count --only-values "$current_track" || echo 0) + skip_count=$(${pkgs.attr}/bin/getfattr -n user.skip_count --only-values "$music_dir"/"$current_track" || echo 0) if [ "$skip_count" -gt 2 ]; then mv "$music_dir"/"$current_track" "$music_dir"/.graveyard/ echo killing: "$track_infos" @@ -193,11 +193,15 @@ in { }; }; + # allow reaktor2 to modify files + systemd.services."reaktor2-the_playlist".serviceConfig.DynamicUser = mkForce false; + krebs.reaktor2.the_playlist = { hostname = "irc.freenode.org"; port = "6697"; useTLS = true; nick = "the_playlist"; + username = "radio"; plugins = [ { plugin = "register"; @@ -214,8 +218,8 @@ in { workdir = config.krebs.reaktor2.the_playlist.stateDir; hooks.PRIVMSG = [ { - #activate = "match"; - pattern = "^\\s*([0-9A-Za-z._][0-9A-Za-z._-]*)(?:\\s+(.*\\S))?\\s*$"; + activate = "match"; + pattern = "^(?:.*\\s)?\\s*the_playlist:\\s*([0-9A-Za-z._][0-9A-Za-z._-]*)(?:\\s+(.*\\S))?\\s*$"; command = 1; arguments = [2]; commands = { -- cgit v1.2.3 From 0578d851885e59b317d653982b7b74f10739b9f3 Mon Sep 17 00:00:00 2001 From: lassulus Date: Wed, 8 Apr 2020 12:33:08 +0200 Subject: syncthing: use upstream module --- krebs/3modules/default.nix | 1 - krebs/3modules/syncthing.nix | 206 -------------------------------------- lass/1systems/mors/config.nix | 8 +- lass/1systems/xerxes/config.nix | 4 +- lass/2configs/green-host.nix | 2 +- lass/2configs/radio.nix | 4 +- lass/2configs/sync/decsync.nix | 4 +- lass/2configs/sync/weechat.nix | 2 +- lass/2configs/syncthing.nix | 16 +-- lass/2configs/websites/domsen.nix | 6 +- 10 files changed, 24 insertions(+), 229 deletions(-) delete mode 100644 krebs/3modules/syncthing.nix diff --git a/krebs/3modules/default.nix b/krebs/3modules/default.nix index 6f06f4510..aa06a883d 100644 --- a/krebs/3modules/default.nix +++ b/krebs/3modules/default.nix @@ -50,7 +50,6 @@ let ./secret.nix ./setuid.nix ./shadow.nix - ./syncthing.nix ./tinc.nix ./tinc_graphs.nix ./urlwatch.nix diff --git a/krebs/3modules/syncthing.nix b/krebs/3modules/syncthing.nix deleted file mode 100644 index 799ed7eda..000000000 --- a/krebs/3modules/syncthing.nix +++ /dev/null @@ -1,206 +0,0 @@ -{ config, pkgs, ... }: with import ; - -let - - kcfg = config.krebs.syncthing; - scfg = config.services.syncthing; - - devices = mapAttrsToList (name: peer: { - name = name; - deviceID = peer.id; - addresses = peer.addresses; - }) kcfg.peers; - - folders = mapAttrsToList ( _: folder: { - inherit (folder) path id type; - devices = map (peer: { deviceId = kcfg.peers.${peer}.id; }) folder.peers; - rescanIntervalS = folder.rescanInterval; - fsWatcherEnabled = folder.watch; - fsWatcherDelayS = folder.watchDelay; - ignoreDelete = folder.ignoreDelete; - ignorePerms = folder.ignorePerms; - }) kcfg.folders; - - getApiKey = pkgs.writeDash "getAPIKey" '' - ${pkgs.libxml2}/bin/xmllint \ - --xpath 'string(configuration/gui/apikey)'\ - ${scfg.configDir}/config.xml - ''; - - updateConfig = pkgs.writeDash "merge-syncthing-config" '' - set -efu - - # XXX this assumes the GUI address to be "IPv4 address and port" - host=${shell.escape (elemAt (splitString ":" scfg.guiAddress) 0)} - port=${shell.escape (elemAt (splitString ":" scfg.guiAddress) 1)} - - # wait for service to restart - ${pkgs.untilport}/bin/untilport "$host" "$port" - - API_KEY=$(${getApiKey}) - - _curl() { - ${pkgs.curl}/bin/curl \ - -Ss \ - -H "X-API-Key: $API_KEY" \ - "http://$host:$port/rest""$@" - } - - old_config=$(_curl /system/config) - new_config=${shell.escape (toJSON { - inherit devices folders; - })} - new_config=$(${pkgs.jq}/bin/jq -en \ - --argjson old_config "$old_config" \ - --argjson new_config "$new_config" \ - ' - $old_config * $new_config - ${optionalString (!kcfg.overridePeers) '' - * { devices: $old_config.devices } - ''} - ${optionalString (!kcfg.overrideFolders) '' - * { folders: $old_config.folders } - ''} - ' - ) - echo $new_config | _curl /system/config -d @- - _curl /system/restart -X POST - ''; - -in - -{ - options.krebs.syncthing = { - - enable = mkEnableOption "syncthing-init"; - - cert = mkOption { - type = types.nullOr types.absolute-pathname; - default = null; - }; - - key = mkOption { - type = types.nullOr types.absolute-pathname; - default = null; - }; - - overridePeers = mkOption { - type = types.bool; - default = true; - description = '' - Whether to delete the peers which are not configured via the peers option - ''; - }; - peers = mkOption { - default = {}; - type = types.attrsOf (types.submodule ({ - options = { - - # TODO make into addr + port submodule - addresses = mkOption { - type = types.listOf types.str; - default = []; - }; - - #TODO check - id = mkOption { - type = types.str; - }; - - }; - })); - }; - - overrideFolders = mkOption { - type = types.bool; - default = true; - description = '' - Whether to delete the folders which are not configured via the peers option - ''; - }; - folders = mkOption { - default = {}; - type = types.attrsOf (types.submodule ({ config, ... }: { - options = { - - path = mkOption { - type = types.absolute-pathname; - default = config._module.args.name; - }; - - id = mkOption { - type = types.str; - default = config._module.args.name; - }; - - peers = mkOption { - type = types.listOf types.str; - default = []; - }; - - rescanInterval = mkOption { - type = types.int; - default = 3600; - }; - - type = mkOption { - type = types.enum [ "sendreceive" "sendonly" "receiveonly" ]; - default = "sendreceive"; - }; - - watch = mkOption { - type = types.bool; - default = true; - }; - - watchDelay = mkOption { - type = types.int; - default = 10; - }; - - ignoreDelete = mkOption { - type = types.bool; - default = false; - }; - - ignorePerms = mkOption { - type = types.bool; - default = true; - }; - - }; - })); - }; - }; - - config = mkIf kcfg.enable { - - systemd.services.syncthing = mkIf (kcfg.cert != null || kcfg.key != null) { - serviceConfig.PermissionsStartOnly = mkDefault true; - preStart = '' - ${optionalString (kcfg.cert != null) '' - cp ${toString kcfg.cert} ${scfg.configDir}/cert.pem - chown ${scfg.user}:${scfg.group} ${scfg.configDir}/cert.pem - chmod 400 ${scfg.configDir}/cert.pem - ''} - ${optionalString (kcfg.key != null) '' - cp ${toString kcfg.key} ${scfg.configDir}/key.pem - chown ${scfg.user}:${scfg.group} ${scfg.configDir}/key.pem - chmod 400 ${scfg.configDir}/key.pem - ''} - ''; - }; - - systemd.services.syncthing-init = { - after = [ "syncthing.service" ]; - wantedBy = [ "multi-user.target" ]; - - serviceConfig = { - User = scfg.user; - RemainAfterExit = true; - Type = "oneshot"; - ExecStart = updateConfig; - }; - }; - }; -} diff --git a/lass/1systems/mors/config.nix b/lass/1systems/mors/config.nix index 03ff42132..fe0b6d85b 100644 --- a/lass/1systems/mors/config.nix +++ b/lass/1systems/mors/config.nix @@ -49,17 +49,17 @@ with import ; ]; } { - krebs.syncthing = { - peers.schasch.addresses = [ "schasch.r:22000" ]; + services.syncthing.declarative = { + devices.schasch.addresses = [ "schasch.r:22000" ]; folders = { the_playlist = { path = "/home/lass/tmp/the_playlist"; - peers = [ "mors" "phone" "prism" "xerxes" ]; + devices = [ "mors" "phone" "prism" "xerxes" ]; }; free_music = { id = "mu9mn-zgvsw"; path = "/home/lass/tmp/free_music"; - peers = [ "mors" "schasch" ]; + devices = [ "mors" "schasch" ]; }; }; }; diff --git a/lass/1systems/xerxes/config.nix b/lass/1systems/xerxes/config.nix index 8630d0f4b..e4a4fb505 100644 --- a/lass/1systems/xerxes/config.nix +++ b/lass/1systems/xerxes/config.nix @@ -41,11 +41,11 @@ displayManager.lightdm.autoLogin.user = "lass"; }; - krebs.syncthing = { + services.syncthing.declarative = { folders = { the_playlist = { path = "/home/lass/tmp/the_playlist"; - peers = [ "mors" "phone" "prism" "xerxes" ]; + devices = [ "mors" "phone" "prism" "xerxes" ]; }; }; }; diff --git a/lass/2configs/green-host.nix b/lass/2configs/green-host.nix index 1421eede7..0cccbc30e 100644 --- a/lass/2configs/green-host.nix +++ b/lass/2configs/green-host.nix @@ -20,7 +20,7 @@ with import ; } ]; - krebs.syncthing.folders."/var/lib/sync-containers".peers = [ "icarus" "skynet" "littleT" "shodan" ]; + services.syncthing.declarative.folders."/var/lib/sync-containers".devices = [ "icarus" "skynet" "littleT" "shodan" ]; krebs.permown."/var/lib/sync-containers" = { owner = "root"; group = "syncthing"; diff --git a/lass/2configs/radio.nix b/lass/2configs/radio.nix index 1a5aadeba..74b15a0ab 100644 --- a/lass/2configs/radio.nix +++ b/lass/2configs/radio.nix @@ -277,9 +277,9 @@ in { alias ${html}; ''; }; - krebs.syncthing.folders."the_playlist" = { + services.syncthing.declarative.folders."the_playlist" = { path = "/home/radio/music/the_playlist"; - peers = [ "mors" "phone" "prism" "xerxes" ]; + devices = [ "mors" "phone" "prism" "xerxes" ]; }; krebs.permown."/home/radio/music/the_playlist" = { owner = "radio"; diff --git a/lass/2configs/sync/decsync.nix b/lass/2configs/sync/decsync.nix index c3f6511c2..9caefdd2d 100644 --- a/lass/2configs/sync/decsync.nix +++ b/lass/2configs/sync/decsync.nix @@ -1,7 +1,7 @@ { - krebs.syncthing.folders.decsync = { + services.syncthing.declarative.folders.decsync = { path = "/home/lass/decsync"; - peers = [ "mors" "blue" "green" "phone" ]; + devices = [ "mors" "blue" "green" "phone" ]; }; krebs.permown."/home/lass/decsync" = { owner = "lass"; diff --git a/lass/2configs/sync/weechat.nix b/lass/2configs/sync/weechat.nix index 30c7b262b..ccbfc75a1 100644 --- a/lass/2configs/sync/weechat.nix +++ b/lass/2configs/sync/weechat.nix @@ -1,5 +1,5 @@ { - krebs.syncthing.folders."/home/lass/.weechat".peers = [ "blue" "green" "mors" ]; + services.syncthing.declarative.folders."/home/lass/.weechat".devices = [ "blue" "green" "mors" ]; krebs.permown."/home/lass/.weechat" = { owner = "lass"; group = "syncthing"; diff --git a/lass/2configs/syncthing.nix b/lass/2configs/syncthing.nix index d4df17b9a..5397c2ca6 100644 --- a/lass/2configs/syncthing.nix +++ b/lass/2configs/syncthing.nix @@ -7,18 +7,20 @@ in { enable = true; group = "syncthing"; configDir = "/var/lib/syncthing"; + declarative = { + key = toString ; + cert = toString ; + devices = mk_peers all_peers; + folders."/home/lass/sync" = { + devices = attrNames (filterAttrs (n: v: n != "phone") own_peers); + # ignorePerms = false; + }; + }; }; krebs.iptables.tables.filter.INPUT.rules = [ { predicate = "-p tcp --dport 22000"; target = "ACCEPT";} { predicate = "-p udp --dport 21027"; target = "ACCEPT";} ]; - krebs.syncthing = { - enable = true; - cert = toString ; - key = toString ; - peers = mk_peers all_peers; - folders."/home/lass/sync".peers = attrNames (filterAttrs (n: v: n != "phone") own_peers); - }; system.activationScripts.syncthing-home = '' ${pkgs.coreutils}/bin/chmod a+x /home/lass diff --git a/lass/2configs/websites/domsen.nix b/lass/2configs/websites/domsen.nix index 80ed12edc..bd113567f 100644 --- a/lass/2configs/websites/domsen.nix +++ b/lass/2configs/websites/domsen.nix @@ -270,14 +270,14 @@ in { }; boot.kernel.sysctl."fs.inotify.max_user_watches" = "1048576"; - krebs.syncthing.folders = { + services.syncthing.declarative.folders = { domsen-backups = { path = "/backups/domsen"; - peers = [ "domsen-backup" ]; + devices = [ "domsen-backup" ]; }; domsen-backup-srv-http = { path = "/srv/http"; - peers = [ "domsen-backup" ]; + devices = [ "domsen-backup" ]; }; }; -- cgit v1.2.3 From 11bdfdbcb6e2a63b120335e242f340a310418f02 Mon Sep 17 00:00:00 2001 From: lassulus Date: Sat, 11 Apr 2020 10:32:51 +0200 Subject: buildbot-stockholm: don't fetch repos from palo --- krebs/2configs/buildbot-stockholm.nix | 2 -- 1 file changed, 2 deletions(-) diff --git a/krebs/2configs/buildbot-stockholm.nix b/krebs/2configs/buildbot-stockholm.nix index ca6e0922a..43dd96919 100644 --- a/krebs/2configs/buildbot-stockholm.nix +++ b/krebs/2configs/buildbot-stockholm.nix @@ -26,14 +26,12 @@ "http://cgit.hotdog.r/krops" "http://cgit.ni.r/krops" "http://cgit.prism.r/krops" - "https://git.ingolf-wagner.de/krebs/krops.git" "https://github.com/krebs/krops.git" ]; nix_writers.urls = [ "http://cgit.hotdog.r/nix-writers" "http://cgit.ni.r/nix-writers" "http://cgit.prism.r/nix-writers" - "https://git.ingolf-wagner.de/krebs/nix-writers.git" ]; stockholm.urls = [ "http://cgit.enklave.r/stockholm" -- cgit v1.2.3 From 7b72fc3de26431c0b739b9572984f5be768030b3 Mon Sep 17 00:00:00 2001 From: lassulus Date: Sat, 11 Apr 2020 10:34:27 +0200 Subject: ci: fetch every 100s --- krebs/3modules/ci.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/krebs/3modules/ci.nix b/krebs/3modules/ci.nix index 7695667fd..50db0b971 100644 --- a/krebs/3modules/ci.nix +++ b/krebs/3modules/ci.nix @@ -52,7 +52,7 @@ let "${url}", workdir='${name}-${elemAt(splitString "." url) 1}', branches=True, project='${name}', - pollinterval=10 + pollinterval=100 ) ) '') repo.urls) -- cgit v1.2.3 From 0cb8ab061a8aa5691e6fc78c8552c18ab035fe53 Mon Sep 17 00:00:00 2001 From: lassulus Date: Sat, 11 Apr 2020 17:06:24 +0200 Subject: hidden-ssh: add message option --- krebs/3modules/hidden-ssh.nix | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/krebs/3modules/hidden-ssh.nix b/krebs/3modules/hidden-ssh.nix index 2d697e497..f497de451 100644 --- a/krebs/3modules/hidden-ssh.nix +++ b/krebs/3modules/hidden-ssh.nix @@ -19,6 +19,10 @@ let type = types.str; default = "irc.freenode.org"; }; + message = mkOption { + type = types.str; + default = "SSH Hidden Service at "; + }; }; imp = let @@ -50,7 +54,7 @@ let ${pkgs.irc-announce}/bin/irc-announce \ ${cfg.server} 6667 ${config.krebs.build.host.name}-ssh \ \${cfg.channel} \ - "SSH Hidden Service at $(cat ${hiddenServiceDir}/hostname)" + "${cfg.message}$(cat ${hiddenServiceDir}/hostname)" ''; PrivateTmp = "true"; User = "tor"; -- cgit v1.2.3 From 05cc4b81bb2a2571ff4486fe9149f465a2b54c0e Mon Sep 17 00:00:00 2001 From: lassulus Date: Sat, 11 Apr 2020 17:07:30 +0200 Subject: realwallpaper: check_type via needs_rebuild --- krebs/5pkgs/simple/realwallpaper/default.nix | 27 +++++---------------------- 1 file changed, 5 insertions(+), 22 deletions(-) diff --git a/krebs/5pkgs/simple/realwallpaper/default.nix b/krebs/5pkgs/simple/realwallpaper/default.nix index 2b0f4bd53..c511458f9 100644 --- a/krebs/5pkgs/simple/realwallpaper/default.nix +++ b/krebs/5pkgs/simple/realwallpaper/default.nix @@ -52,9 +52,11 @@ pkgs.writers.writeDashBin "generate-wallpaper" '' else result=1 for b; do - if test "$b" -nt "$a"; then - #echo " $b is newer than $a" >&2 - result=0 + if check_type "$b" image; then + if test "$b" -nt "$a"; then + #echo " $b is newer than $a" >&2 + result=0 + fi fi done fi @@ -116,25 +118,6 @@ pkgs.writers.writeDashBin "generate-wallpaper" '' ${pkgs.nomads-cloud}/bin/nomads-cloud clouds-raw.png fi - check_type sun-raw.jpg image - check_type nightmap-raw.jpg image - check_type daymap-raw.tif image - check_type ice-raw.jpg image - check_type snow-raw.jpg image - check_type chlora-raw.jpg image - check_type fire-raw.jpg image - check_type clouds-raw.png image - - check_type mercury-raw.svg image - check_type venus-raw.svg image - check_type mars-raw.svg image - check_type jupiter-raw.svg image - check_type saturn-raw.svg image - check_type uranus-raw.svg image - check_type neptune-raw.svg image - - check_type krebs-raw.svg image - in_size=3600x1800 xplanet_out_size=3200x2500 out_geometry=3200x1800+0+350 -- cgit v1.2.3 From 36a28828c713b06783b883ab7eef8d18cbe53a6c Mon Sep 17 00:00:00 2001 From: lassulus Date: Sat, 11 Apr 2020 17:10:10 +0200 Subject: l hilum.r: /tmp on tmpfs --- lass/1systems/hilum/config.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lass/1systems/hilum/config.nix b/lass/1systems/hilum/config.nix index 7a506591b..3f25991d9 100644 --- a/lass/1systems/hilum/config.nix +++ b/lass/1systems/hilum/config.nix @@ -33,4 +33,6 @@ services.logind.lidSwitch = "ignore"; services.logind.lidSwitchDocked = "ignore"; + + boot.tmpOnTmpfs = true; } -- cgit v1.2.3 From 3fd3b191177862e0e0044737fd8f382ae30aceee Mon Sep 17 00:00:00 2001 From: lassulus Date: Sat, 11 Apr 2020 17:13:08 +0200 Subject: l yellow.r: add shoutbox to /flix --- lass/1systems/prism/config.nix | 54 +++++++++++---------- lass/1systems/yellow/config.nix | 101 ++++++++++++++++++++++++++++++++++++++-- 2 files changed, 128 insertions(+), 27 deletions(-) diff --git a/lass/1systems/prism/config.nix b/lass/1systems/prism/config.nix index cde65ea6c..c6e0400bf 100644 --- a/lass/1systems/prism/config.nix +++ b/lass/1systems/prism/config.nix @@ -338,30 +338,36 @@ with import ; localAddress = "10.233.2.14"; }; - services.nginx.virtualHosts."lassul.us".locations."^~ /flix/".extraConfig = '' - if ($scheme != "https") { - rewrite ^ https://$host$request_uri permanent; - } - auth_basic "Restricted Content"; - auth_basic_user_file ${pkgs.writeText "flix-user-pass" '' - krebs:$apr1$1Fwt/4T0$YwcUn3OBmtmsGiEPlYWyq0 - ''}; - proxy_pass http://10.233.2.14:80/; - proxy_set_header Accept-Encoding ""; - sub_filter "https://lassul.us/" "https://lassul.us/flix/"; - sub_filter_once off; - ''; - services.nginx.virtualHosts."lassul.us".locations."^~ /transmission".extraConfig = '' - if ($scheme != "https") { - rewrite ^ https://$host$request_uri permanent; - } - auth_basic "Restricted Content"; - auth_basic_user_file ${pkgs.writeText "transmission-user-pass" '' - krebs:$apr1$1Fwt/4T0$YwcUn3OBmtmsGiEPlYWyq0 - ''}; - proxy_pass_header X-Transmission-Session-Id; - proxy_pass http://10.233.2.14:9091; - ''; + services.nginx.virtualHosts."lassul.us" = { + locations."^~ /flix/".extraConfig = '' + if ($scheme != "https") { + rewrite ^ https://$host$request_uri permanent; + } + auth_basic "Restricted Content"; + auth_basic_user_file ${pkgs.writeText "flix-user-pass" '' + krebs:$apr1$1Fwt/4T0$YwcUn3OBmtmsGiEPlYWyq0 + ''}; + proxy_pass http://10.233.2.14:80/; + proxy_set_header Accept-Encoding ""; + sub_filter "https://lassul.us/" "https://lassul.us/flix/"; + sub_filter_once off; + ''; + locations."^~ /chatty/".extraConfig = '' + rewrite ^ https://$host/flix/$request_uri permanent; + ''; + #locations."^~ /transmission".return = "301 https://$host/transmission/web/"; + locations."^~ /transmission/".extraConfig = '' + if ($scheme != "https") { + rewrite ^ https://$host$request_uri permanent; + } + auth_basic "Restricted Content"; + auth_basic_user_file ${pkgs.writeText "transmission-user-pass" '' + krebs:$apr1$1Fwt/4T0$YwcUn3OBmtmsGiEPlYWyq0 + ''}; + proxy_pass_header X-Transmission-Session-Id; + proxy_pass http://10.233.2.14:9091; + ''; + }; users.groups.download = {}; users.users = { diff --git a/lass/1systems/yellow/config.nix b/lass/1systems/yellow/config.nix index abbc0045b..82fe3fac5 100644 --- a/lass/1systems/yellow/config.nix +++ b/lass/1systems/yellow/config.nix @@ -54,12 +54,107 @@ with import ; root = "/var/download/finished"; extraConfig = '' fancyindex on; - dav_methods PUT DELETE MKCOL COPY MOVE; - + fancyindex_footer "/fancy.html"; + include ${pkgs.nginx}/conf/mime.types; + include ${pkgs.writeText "extrMime" '' + types { + video/webm mkv; + } + ''}; create_full_put_path on; - dav_access all:r; ''; }; + locations."/chatty" = { + proxyPass = "http://localhost:3000"; + extraConfig = '' + rewrite /chatty/(.*) /$1 break; + proxy_set_header Host $host; + ''; + }; + locations."= /fancy.html".extraConfig = '' + alias ${pkgs.writeText "nginx_footer" '' +
+ +
Click here to move
+ +
+ + + ''}; + ''; + }; + }; + + systemd.services.bruellwuerfel = { + wantedBy = [ "multi-user.target" ]; + environment = { + IRC_CHANNEL = "#flix"; + IRC_NICK = "bruelli"; + IRC_SERVER = "irc.r"; + IRC_HISTORY_FILE = "/tmp/bruelli.history"; + }; + serviceConfig = { + ExecStart = "${pkgs.bruellwuerfel}/bin/bruellwuerfel"; }; }; -- cgit v1.2.3 From 47b379a4680b21f982bfc0822601baa1c8425540 Mon Sep 17 00:00:00 2001 From: lassulus Date: Sat, 11 Apr 2020 17:29:55 +0200 Subject: l: add more mail addresses --- lass/2configs/exim-smarthost.nix | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lass/2configs/exim-smarthost.nix b/lass/2configs/exim-smarthost.nix index 565608633..08a226e6d 100644 --- a/lass/2configs/exim-smarthost.nix +++ b/lass/2configs/exim-smarthost.nix @@ -102,6 +102,14 @@ "microsoft@lassul.us" "stickers@lassul.us" "nextbike@lassul.us" + "mytello@lassul.us" + "camp@lassul.us" + "urlwatch@lassul.us" + "lidl@lassul.us" + "geizhals@lassul.us" + "auschein@lassul.us" + "tleech@lassul.us" + "durstexpress@lassul.us" ]; in { -- cgit v1.2.3 From 430cfa251f7e6d7f768b579cb01af9173e2e8bbc Mon Sep 17 00:00:00 2001 From: lassulus Date: Sat, 11 Apr 2020 17:31:13 +0200 Subject: l mpv: bind subtitle search to key --- lass/2configs/mpv.nix | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/lass/2configs/mpv.nix b/lass/2configs/mpv.nix index 7dc43a9ee..5d7bfed60 100644 --- a/lass/2configs/mpv.nix +++ b/lass/2configs/mpv.nix @@ -12,14 +12,17 @@ let video_filename = sys.argv[1] vid = scan_video(video_filename) - sub = download_best_subtitles([vid], {Language('eng')})[vid][0] + try: + sub = download_best_subtitles([vid], {Language('eng')})[vid][0] - filename = '/tmp/' + vid.title + '.srt' + filename = '/tmp/' + vid.title + '.srt' - with open(filename, 'wb+') as file: - file.write(sub.content) + with open(filename, 'wb+') as file: + file.write(sub.content) - print(filename) + print(filename) + except: # noqa + print("/dev/null") ''; autosub = pkgs.writeText "autosub.lua" '' @@ -70,7 +73,6 @@ let download() end - mp.register_event('file-loaded', control_download) mp.add_key_binding('S', "download_subs", download) ''; @@ -79,7 +81,6 @@ let paths = [ (pkgs.writeDashBin "mpv" '' exec ${pkgs.mpv}/bin/mpv --no-config --script=${autosub} "$@" - # exec ${pkgs.mpv}/bin/mpv --no-config "$@" '') pkgs.mpv ]; -- cgit v1.2.3 From 1ed6cb71685a9aee1cdb91bee661365d8ce4eba8 Mon Sep 17 00:00:00 2001 From: lassulus Date: Sat, 11 Apr 2020 17:37:26 +0200 Subject: l: init bruellwuerfel --- lass/5pkgs/bruellwuerfel/default.nix | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 lass/5pkgs/bruellwuerfel/default.nix diff --git a/lass/5pkgs/bruellwuerfel/default.nix b/lass/5pkgs/bruellwuerfel/default.nix new file mode 100644 index 000000000..cb8f08fa8 --- /dev/null +++ b/lass/5pkgs/bruellwuerfel/default.nix @@ -0,0 +1,26 @@ +{ yarn2nix-moretea, fetchFromGitHub, nodePackages, nodejs }: let + #src = ~/src/bruellwuerfel; + src = fetchFromGitHub { + owner = "krebs"; + repo = "bruellwuerfel"; + rev = "57e20e630f732ce4e15b495ec5f9bf72a121b959"; + sha256 = "08zwwl24sq21r497a03lqpy2x10az8frrsh6d38xm92snd1yf85b"; + }; + +in yarn2nix-moretea.mkYarnModules rec { + pname = "bruellwuerfel"; + version = "1.0"; + name = "${pname}-${version}"; + packageJSON = "${src}/package.json"; + yarnLock = "${src}/yarn.lock"; + postBuild = '' + cp -r ${src}/{src,tsconfig.json} $out/ + cd $out + ${nodePackages.typescript}/bin/tsc || : + mkdir -p $out/bin + echo '#!/bin/sh' > $out/bin/bruellwuerfel + echo "export NODE_PATH=$out/dist" >> $out/bin/bruellwuerfel + echo "${nodejs}/bin/node $out/dist/index.js" >> $out/bin/bruellwuerfel + chmod +x $out/bin/bruellwuerfel + ''; +} -- cgit v1.2.3 From 6ace0f7b6941c1c9476d84944cdba8bedf98d95d Mon Sep 17 00:00:00 2001 From: tv Date: Sun, 12 Apr 2020 09:45:06 +0200 Subject: tv xmonad: add pavucontrol --- tv/5pkgs/haskell/xmonad-tv/src/Paths.hs | 3 +++ tv/5pkgs/haskell/xmonad-tv/src/main.hs | 3 +++ 2 files changed, 6 insertions(+) diff --git a/tv/5pkgs/haskell/xmonad-tv/src/Paths.hs b/tv/5pkgs/haskell/xmonad-tv/src/Paths.hs index 3a879b5d0..dd21511b4 100644 --- a/tv/5pkgs/haskell/xmonad-tv/src/Paths.hs +++ b/tv/5pkgs/haskell/xmonad-tv/src/Paths.hs @@ -12,6 +12,9 @@ pactl = findExecutable "pactl" passmenu :: FilePath passmenu = findExecutable "passmenu" +pavucontrol :: FilePath +pavucontrol = findExecutable "pavucontrol" + slock :: FilePath slock = findExecutable "slock" diff --git a/tv/5pkgs/haskell/xmonad-tv/src/main.hs b/tv/5pkgs/haskell/xmonad-tv/src/main.hs index c528017d7..400c87ab9 100644 --- a/tv/5pkgs/haskell/xmonad-tv/src/main.hs +++ b/tv/5pkgs/haskell/xmonad-tv/src/main.hs @@ -160,6 +160,7 @@ myKeys conf = Map.fromList $ , ((0, xF86XK_AudioLowerVolume), audioLowerVolume) , ((0, xF86XK_AudioRaiseVolume), audioRaiseVolume) , ((0, xF86XK_AudioMute), audioMute) + , ((_4, xF86XK_AudioMute), pavucontrol []) , ((_4, xK_Prior), forkFile Paths.xcalib ["-invert", "-alter"] Nothing) ] @@ -175,6 +176,8 @@ myKeys conf = Map.fromList $ _4SM = _4 .|. _S .|. _M pactl args = forkFile Paths.pactl args Nothing + pavucontrol args = forkFile Paths.pavucontrol args Nothing + audioLowerVolume = pactl ["--", "set-sink-volume", "@DEFAULT_SINK@", "-5%"] audioRaiseVolume = pactl ["--", "set-sink-volume", "@DEFAULT_SINK@", "+5%"] audioMute = pactl ["--", "set-sink-mute", "@DEFAULT_SINK@", "toggle"] -- cgit v1.2.3 From 843a537bd7fbedd8eb5fd61a1172dd8229440606 Mon Sep 17 00:00:00 2001 From: lassulus Date: Tue, 14 Apr 2020 19:49:00 +0200 Subject: l fzfmenu: show query if no match --- lass/5pkgs/fzfmenu/default.nix | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/lass/5pkgs/fzfmenu/default.nix b/lass/5pkgs/fzfmenu/default.nix index bdae8ceed..a158eeaac 100644 --- a/lass/5pkgs/fzfmenu/default.nix +++ b/lass/5pkgs/fzfmenu/default.nix @@ -32,14 +32,24 @@ pkgs.writeDashBin "fzfmenu" '' done INPUT=$(${pkgs.coreutils}/bin/cat) OUTPUT="$(${pkgs.coreutils}/bin/mktemp)" - ${pkgs.rxvt_unicode}/bin/urxvt \ - -name fzfmenu -title fzfmenu \ - -e ${pkgs.dash}/bin/dash -c \ - "echo \"$INPUT\" | ${pkgs.fzf}/bin/fzf \ - --history=/dev/null \ - --print-query \ - --prompt=\"$PROMPT\" \ - > \"$OUTPUT\"" 2>/dev/null + if [ -z ''${TERM+x} ]; then #check if we can print fzf in the shell + ${pkgs.rxvt_unicode}/bin/urxvtc \ + -name fzfmenu -title fzfmenu \ + -e ${pkgs.dash}/bin/dash -c \ + "echo \"$INPUT\" | ${pkgs.fzf}/bin/fzf \ + --history=/dev/null \ + --print-query \ + --prompt=\"$PROMPT\" \ + --reverse \ + > \"$OUTPUT\"" 2>/dev/null + else + echo "$INPUT" | ${pkgs.fzf}/bin/fzf \ + --history=/dev/null \ + --print-query \ + --prompt="$PROMPT" \ + --reverse \ + > "$OUTPUT" + fi ${pkgs.coreutils}/bin/tail -1 "$OUTPUT" ${pkgs.coreutils}/bin/rm "$OUTPUT" '' -- cgit v1.2.3 From 4d9d0dcd98239237c2fecb37817832ed31e17d48 Mon Sep 17 00:00:00 2001 From: lassulus Date: Tue, 14 Apr 2020 20:50:48 +0200 Subject: l fzfmenu: use urxvt because of arg bug --- lass/5pkgs/fzfmenu/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lass/5pkgs/fzfmenu/default.nix b/lass/5pkgs/fzfmenu/default.nix index a158eeaac..64e95d233 100644 --- a/lass/5pkgs/fzfmenu/default.nix +++ b/lass/5pkgs/fzfmenu/default.nix @@ -33,7 +33,7 @@ pkgs.writeDashBin "fzfmenu" '' INPUT=$(${pkgs.coreutils}/bin/cat) OUTPUT="$(${pkgs.coreutils}/bin/mktemp)" if [ -z ''${TERM+x} ]; then #check if we can print fzf in the shell - ${pkgs.rxvt_unicode}/bin/urxvtc \ + ${pkgs.rxvt_unicode}/bin/urxvt \ -name fzfmenu -title fzfmenu \ -e ${pkgs.dash}/bin/dash -c \ "echo \"$INPUT\" | ${pkgs.fzf}/bin/fzf \ -- cgit v1.2.3 From fd178641b03886b1b732330f60226903011ccdc4 Mon Sep 17 00:00:00 2001 From: xkey <(xkey@freenode)> Date: Tue, 14 Apr 2020 20:43:39 +0200 Subject: external: add catalonia --- krebs/3modules/external/default.nix | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/krebs/3modules/external/default.nix b/krebs/3modules/external/default.nix index 1d73fade2..b437456ec 100644 --- a/krebs/3modules/external/default.nix +++ b/krebs/3modules/external/default.nix @@ -373,6 +373,30 @@ in { syncthing.id = "22NLFY5-QMRM3BH-76QIBYI-OPMKVGM-DU4FNZI-3KN2POF-V4WIC6M-2SFFUAC"; nets = {}; }; + catalonia = { + owner = config.krebs.users.xkey; + nets = { + retiolum = { + ip4.addr = "10.243.13.12"; + aliases = [ "catalonia.r" ]; + tinc.pubkey = '' + -----BEGIN RSA PUBLIC KEY----- + MIICCgKCAgEAug+nej8/spuRHdzcfBYAuzUVoiq4YufmJqXSshvgf4aqjeVEt91Y + gT6iBN8IKnMjYk3bAS7MxmgiyVE17MQlaQi0RSYY47M8I9TvCYtWX/FcXuP9e6CA + VcalDUNpy2qNB+yEE8gMa8vDA3smKk/iK47jTtpWoPtvejLK/SCi8RdlYjKlOErE + Yl9mCniGD1WEYgdrjf6Nl7av6uuGYNibivIMkB2JyGwGGmzvP+oBFi2Cwarw8K2e + FK2VGrAfkgiP5rTPACHseoeCsJtRLozgzYzmS5M9XhP5ZoPkbtR/pL5btCwoCTlZ + HotmLVg4DezbPjNOBB9gtJF4UuzQjSPNY6K1VvvLOhDwXdyln82LuNcm9l+cy9y3 + mGeSvqOouBugDqie6OpkF0KrRwlGQVwzwtnDohGd/5f7TbiPf1QjC+JP/m4mxZl3 + zE0BCOct9b4hUc/CFto71CPlytSbTsMhfJAn8JxttGvsWIAj+dQ0iuLXfLDflWt6 + sImmnOo28YInvFx6pKoxTwcV1AVrPWn5TSePhZM50dmzs0exltOISFECDhpPabU3 + ZymRCze8fH9Z3SHxfxTlTZV7IaW2kpyyBe1KsWpM46gLPk5icX+Xc6mdGwbdGBpf + vDZ+BoHCjq9FfQrAu1+E83yCYyu+3fWrLSgYyrqjg0gPcCcnb1g6hqECAwEAAQ== + -----END RSA PUBLIC KEY----- + ''; + }; + }; + }; }; users = { ciko = { @@ -421,6 +445,7 @@ in { mail = "xq@shackspace.de"; pubkey = ssh-for "xq"; }; + xkey = {}; miaoski = { }; filly = { -- cgit v1.2.3 From 993a8de856df192a172c25b5e9ededc3ece3e80d Mon Sep 17 00:00:00 2001 From: lassulus Date: Wed, 15 Apr 2020 17:20:28 +0200 Subject: l radio: listen to more experimental music --- lass/2configs/radio.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lass/2configs/radio.nix b/lass/2configs/radio.nix index 74b15a0ab..e8ce66d3e 100644 --- a/lass/2configs/radio.nix +++ b/lass/2configs/radio.nix @@ -12,7 +12,7 @@ let music_dir = "/home/radio/music"; add_random = pkgs.writeDashBin "add_random" '' - ${pkgs.mpc_cli}/bin/mpc add "$(${pkgs.mpc_cli}/bin/mpc ls the_playlist/music | grep '\.ogg$' | shuf -n1)" + ${pkgs.mpc_cli}/bin/mpc add "$(${pkgs.findutils}/bin/find "${music_dir}/the_playlist" | grep '\.ogg$' | shuf -n1 | sed 's,${music_dir}/,,')" ''; skip_track = pkgs.writeDashBin "skip_track" '' -- cgit v1.2.3 From 07f18d851a974ee594c92e3332f167ef3b1d259f Mon Sep 17 00:00:00 2001 From: lassulus Date: Wed, 15 Apr 2020 17:21:54 +0200 Subject: l radio: more complex track logic --- lass/2configs/radio.nix | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/lass/2configs/radio.nix b/lass/2configs/radio.nix index e8ce66d3e..c4c4b0abb 100644 --- a/lass/2configs/radio.nix +++ b/lass/2configs/radio.nix @@ -15,7 +15,7 @@ let ${pkgs.mpc_cli}/bin/mpc add "$(${pkgs.findutils}/bin/find "${music_dir}/the_playlist" | grep '\.ogg$' | shuf -n1 | sed 's,${music_dir}/,,')" ''; - skip_track = pkgs.writeDashBin "skip_track" '' + skip_track = pkgs.writeBashBin "skip_track" '' set -eu ${add_random}/bin/add_random @@ -23,17 +23,32 @@ let current_track=$(${pkgs.mpc_cli}/bin/mpc current -f %file%) track_infos=$(${print_current}/bin/print_current) skip_count=$(${pkgs.attr}/bin/getfattr -n user.skip_count --only-values "$music_dir"/"$current_track" || echo 0) - if [ "$skip_count" -gt 2 ]; then - mv "$music_dir"/"$current_track" "$music_dir"/.graveyard/ - echo killing: "$track_infos" - else + if [[ "$current_track" =~ ^the_playlist/music/.* ]] && [ "$skip_count" -le 2 ]; then skip_count=$((skip_count+1)) ${pkgs.attr}/bin/setfattr -n user.skip_count -v "$skip_count" "$music_dir"/"$current_track" echo skipping: "$track_infos" skip_count: "$skip_count" + else + mkdir -p "$music_dir"/.graveyard/ + mv "$music_dir"/"$current_track" "$music_dir"/.graveyard/ + echo killing: "$track_infos" fi ${pkgs.mpc_cli}/bin/mpc -q next ''; + good_track = pkgs.writeBashBin "good_track" '' + set -eu + + music_dir=${escapeShellArg music_dir} + current_track=$(${pkgs.mpc_cli}/bin/mpc current -f %file%) + track_infos=$(${print_current}/bin/print_current) + if [[ "$current_track" =~ ^the_playlist/music/.* ]]; then + ${pkgs.attr}/bin/setfattr -n user.skip_count -v 0 "$music_dir"/"$current_track" + else + mv "$music_dir"/"$current_track" "$music_dir"/the_playlist/music/ + fi + echo good: "$track_infos" + ''; + print_current = pkgs.writeDashBin "print_current" '' echo "$(${pkgs.mpc_cli}/bin/mpc current -f %file%) \ $(${pkgs.mpc_cli}/bin/mpc current -f %file% \ @@ -63,6 +78,7 @@ in { krebs.per-user.${name}.packages = with pkgs; [ add_random + good_track skip_track print_current ncmpcpp @@ -224,6 +240,13 @@ in { arguments = [2]; commands = { skip.filename = "${skip_track}/bin/skip_track"; + next.filename = "${skip_track}/bin/skip_track"; + bad.filename = "${skip_track}/bin/skip_track"; + + good.filename = "${good_track}/bin/good_track"; + nice.filename = "${good_track}/bin/good_track"; + like.filename = "${good_track}/bin/good_track"; + current.filename = "${print_current}/bin/print_current"; suggest.filename = pkgs.writeDash "suggest" '' echo "$@" >> playlist_suggest -- cgit v1.2.3 From 0715c3cba9fa860c49be1f665b5c7d4470e4098d Mon Sep 17 00:00:00 2001 From: lassulus Date: Wed, 15 Apr 2020 17:48:51 +0200 Subject: nixpkgs: 598a9cb -> f6c1d3b --- krebs/nixpkgs.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/krebs/nixpkgs.json b/krebs/nixpkgs.json index 123d624d8..43dc0ddfa 100644 --- a/krebs/nixpkgs.json +++ b/krebs/nixpkgs.json @@ -1,7 +1,7 @@ { "url": "https://github.com/NixOS/nixpkgs-channels", - "rev": "598a9cbed6348ebda43c6b1a9a3061e0206297e7", - "date": "2020-03-28T03:06:32+01:00", - "sha256": "12m910j2sfhm3a6skw4janxy010gzdxp15bn8v9w7w9hhjzvdw8c", + "rev": "f6c1d3b113ce9e7c908991df2e8eed02f03df1bc", + "date": "2020-04-14T08:34:46-04:00", + "sha256": "08z6qbjmx64bcil3cnvflb7bv9ibdizxcr63yvhgcqzsja7m51n5", "fetchSubmodules": false } -- cgit v1.2.3 From aa65c483ecedab18cec8f3db3de5742960f19385 Mon Sep 17 00:00:00 2001 From: tv Date: Fri, 17 Apr 2020 19:22:14 +0200 Subject: reaktor2: 0.2.2 -> 0.2.3-pre1 --- krebs/5pkgs/haskell/reaktor2.nix | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/krebs/5pkgs/haskell/reaktor2.nix b/krebs/5pkgs/haskell/reaktor2.nix index f06e79121..feaa55dcf 100644 --- a/krebs/5pkgs/haskell/reaktor2.nix +++ b/krebs/5pkgs/haskell/reaktor2.nix @@ -1,17 +1,18 @@ { mkDerivation, aeson, async, attoparsec, base, blessings , bytestring, containers, data-default, fetchgit, filepath , hashable, lens, lens-aeson, network, network-simple -, network-simple-tls, pcre-light, process, random, stdenv -, string-conversions, stringsearch, text, time, transformers -, unagi-chan, unix, unordered-containers, vector +, network-simple-tls, pcre-light, process, random, servant-server +, stdenv, string-conversions, stringsearch, text, time +, transformers, unagi-chan, unix, unordered-containers, vector, wai +, warp }: mkDerivation { pname = "reaktor2"; - version = "0.2.2"; + version = "0.2.3-pre1"; src = fetchgit { url = "https://cgit.krebsco.de/reaktor2"; - sha256 = "1kyr5i5zdzvc7fcyac1i1yvi88kcxafrgp8p79c1b9l4g9sjnv78"; - rev = "9f4e2644188f985d7cd806c13e2c0dee1688b9f0"; + sha256 = "0jg8yln1np5w3bg8jpkymfqi0x3a47pfsk20sz4lp3r2hfpw0zlk"; + rev = "56bb8aef0018650e14624e086bb8884bb7ecd4f7"; fetchSubmodules = true; }; isLibrary = false; @@ -20,8 +21,8 @@ mkDerivation { aeson async attoparsec base blessings bytestring containers data-default filepath hashable lens lens-aeson network network-simple network-simple-tls pcre-light process random - string-conversions stringsearch text time transformers unagi-chan - unix unordered-containers vector + servant-server string-conversions stringsearch text time + transformers unagi-chan unix unordered-containers vector wai warp ]; license = stdenv.lib.licenses.mit; } -- cgit v1.2.3 From b20942d07d10afa68a58f7a0690ad4397e90a57f Mon Sep 17 00:00:00 2001 From: tv Date: Fri, 17 Apr 2020 23:14:19 +0200 Subject: reaktor2: 0.2.3-pre1 -> 0.3.0 --- krebs/5pkgs/haskell/reaktor2.nix | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/krebs/5pkgs/haskell/reaktor2.nix b/krebs/5pkgs/haskell/reaktor2.nix index feaa55dcf..ae242efea 100644 --- a/krebs/5pkgs/haskell/reaktor2.nix +++ b/krebs/5pkgs/haskell/reaktor2.nix @@ -1,18 +1,18 @@ { mkDerivation, aeson, async, attoparsec, base, blessings , bytestring, containers, data-default, fetchgit, filepath , hashable, lens, lens-aeson, network, network-simple -, network-simple-tls, pcre-light, process, random, servant-server -, stdenv, string-conversions, stringsearch, text, time -, transformers, unagi-chan, unix, unordered-containers, vector, wai -, warp +, network-simple-tls, network-uri, pcre-light, process, random +, servant-server, stdenv, string-conversions, stringsearch, text +, time, transformers, unagi-chan, unix, unordered-containers +, vector, wai, warp }: mkDerivation { pname = "reaktor2"; - version = "0.2.3-pre1"; + version = "0.3.0"; src = fetchgit { url = "https://cgit.krebsco.de/reaktor2"; - sha256 = "0jg8yln1np5w3bg8jpkymfqi0x3a47pfsk20sz4lp3r2hfpw0zlk"; - rev = "56bb8aef0018650e14624e086bb8884bb7ecd4f7"; + sha256 = "02hqpq8wcfd6rvi8qk10zy3f3lrzzqnjwqal4cbvksjn3vahz36h"; + rev = "a6893c00f78a8acd0a4bfe7da87ab6889eabcf21"; fetchSubmodules = true; }; isLibrary = false; @@ -20,8 +20,8 @@ mkDerivation { executableHaskellDepends = [ aeson async attoparsec base blessings bytestring containers data-default filepath hashable lens lens-aeson network - network-simple network-simple-tls pcre-light process random - servant-server string-conversions stringsearch text time + network-simple network-simple-tls network-uri pcre-light process + random servant-server string-conversions stringsearch text time transformers unagi-chan unix unordered-containers vector wai warp ]; license = stdenv.lib.licenses.mit; -- cgit v1.2.3 From 8772a311a82040c187a04df3f5393c3083780db8 Mon Sep 17 00:00:00 2001 From: lassulus Date: Sat, 18 Apr 2020 09:32:38 +0200 Subject: l radio: filter other music out --- lass/2configs/radio.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lass/2configs/radio.nix b/lass/2configs/radio.nix index c4c4b0abb..60659d043 100644 --- a/lass/2configs/radio.nix +++ b/lass/2configs/radio.nix @@ -12,7 +12,7 @@ let music_dir = "/home/radio/music"; add_random = pkgs.writeDashBin "add_random" '' - ${pkgs.mpc_cli}/bin/mpc add "$(${pkgs.findutils}/bin/find "${music_dir}/the_playlist" | grep '\.ogg$' | shuf -n1 | sed 's,${music_dir}/,,')" + ${pkgs.mpc_cli}/bin/mpc add "$(${pkgs.findutils}/bin/find "${music_dir}/the_playlist" | grep -v '/other/' | grep '\.ogg$' | shuf -n1 | sed 's,${music_dir}/,,')" ''; skip_track = pkgs.writeBashBin "skip_track" '' -- cgit v1.2.3 From fae3c95c6c32c67c7d0c67bf466890a1ffee803d Mon Sep 17 00:00:00 2001 From: lassulus Date: Sat, 18 Apr 2020 09:32:52 +0200 Subject: l radio: add REST api --- lass/2configs/radio.nix | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/lass/2configs/radio.nix b/lass/2configs/radio.nix index 60659d043..9da0a499c 100644 --- a/lass/2configs/radio.nix +++ b/lass/2configs/radio.nix @@ -146,6 +146,7 @@ in { tables = { filter.INPUT.rules = [ { predicate = "-p tcp --dport 8000"; target = "ACCEPT"; } + { predicate = "-i retiolum -p tcp --dport 8001"; target = "ACCEPT"; } ]; }; }; @@ -259,6 +260,29 @@ in { ]; }; + krebs.htgen.radio = { + port = 8001; + user = { + name = "radio"; + }; + script = '' + case "$Method $Request_URI" in + "POST /skip") + ${skip_track}/bin/skip_track + exit + ;; + "POST /good") + ${good_track}/bin/good_track + exit + ;; + "POST /current") + ${print_current}/bin/print_current + exit + ;; + esac + ''; + }; + services.nginx = { enable = true; virtualHosts."radio.lassul.us" = { -- cgit v1.2.3 From 75debd3e2580303a69daf05b7478befad4c8cbbb Mon Sep 17 00:00:00 2001 From: lassulus Date: Sat, 18 Apr 2020 09:53:23 +0200 Subject: nixpkgs: f6c1d3b -> b67bc34 --- krebs/nixpkgs.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/krebs/nixpkgs.json b/krebs/nixpkgs.json index 43dc0ddfa..3a8998e48 100644 --- a/krebs/nixpkgs.json +++ b/krebs/nixpkgs.json @@ -1,7 +1,7 @@ { "url": "https://github.com/NixOS/nixpkgs-channels", - "rev": "f6c1d3b113ce9e7c908991df2e8eed02f03df1bc", - "date": "2020-04-14T08:34:46-04:00", - "sha256": "08z6qbjmx64bcil3cnvflb7bv9ibdizxcr63yvhgcqzsja7m51n5", + "rev": "b67bc34d4e3de1e89b8bb7cd6e375ba44f1ae8ca", + "date": "2020-04-15T22:11:06+01:00", + "sha256": "1q9a64bl5afflgpa2iaw1q7z7s08c8xq9w6lndlnc5c3siajrp8v", "fetchSubmodules": false } -- cgit v1.2.3 From d1b6b379747223b863e01438ff8bb4764f61256e Mon Sep 17 00:00:00 2001 From: lassulus Date: Sat, 18 Apr 2020 09:53:45 +0200 Subject: nixpkgs-unstable: d96bd33 -> b61999e --- krebs/nixpkgs-unstable.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/krebs/nixpkgs-unstable.json b/krebs/nixpkgs-unstable.json index 847e3c61e..8f426cc05 100644 --- a/krebs/nixpkgs-unstable.json +++ b/krebs/nixpkgs-unstable.json @@ -1,7 +1,7 @@ { "url": "https://github.com/NixOS/nixpkgs-channels", - "rev": "d96bd3394b734487d1c3bfbac0e8f17465e03afe", - "date": "2020-03-19T15:32:34+01:00", - "sha256": "05n27wz5ln9ni5cy5rhjcy612i44gmblkq5m0g827v8pd0nk00da", + "rev": "b61999e4ad60c351b4da63ae3ff43aae3c0bbdfb", + "date": "2020-04-16T08:43:36-04:00", + "sha256": "0cggpdks4qscyirqwfprgdl91mlhjlw24wkg0riapk5f2g2llbpq", "fetchSubmodules": false } -- cgit v1.2.3 From 3c3e20599e32d1aef3639a7b0056cbc277e36b94 Mon Sep 17 00:00:00 2001 From: lassulus Date: Sat, 18 Apr 2020 14:37:15 +0200 Subject: realwallpaper: make ice gray --- krebs/5pkgs/simple/realwallpaper/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/krebs/5pkgs/simple/realwallpaper/default.nix b/krebs/5pkgs/simple/realwallpaper/default.nix index c511458f9..057983fec 100644 --- a/krebs/5pkgs/simple/realwallpaper/default.nix +++ b/krebs/5pkgs/simple/realwallpaper/default.nix @@ -138,7 +138,7 @@ pkgs.writers.writeDashBin "generate-wallpaper" '' # remove snow from ice map if needs_rebuild ice.png ice-raw.jpg; then - convert ice-raw.jpg -fuzz 20% -fill black -opaque white -scale "$in_size" ice.png + convert ice-raw.jpg -fuzz 20% -fill black -opaque white -colorspace gray -blur 0x6 -scale "$in_size" ice.png fi if needs_rebuild snow.png snow-raw.jpg; then -- cgit v1.2.3 From 29e969cae1c58a4279d476c2e9d44a3e87907ea7 Mon Sep 17 00:00:00 2001 From: lassulus Date: Sat, 18 Apr 2020 14:37:33 +0200 Subject: l icarus.r: set thinkfan levels --- lass/1systems/icarus/physical.nix | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lass/1systems/icarus/physical.nix b/lass/1systems/icarus/physical.nix index 861bd8b0b..bd74c29f3 100644 --- a/lass/1systems/icarus/physical.nix +++ b/lass/1systems/icarus/physical.nix @@ -46,6 +46,15 @@ ''; services.thinkfan.enable = true; + services.thinkfan.levels = '' + (0, 0, 55) + (1, 48, 60) + (2, 50, 61) + (3, 52, 63) + (6, 60, 65) + (7, 80, 85) + (127, 90, 32767) + ''; services.logind.lidSwitch = "ignore"; services.logind.lidSwitchDocked = "ignore"; -- cgit v1.2.3 From d593ce40856c791648bc3fbd7465ab1c185d5c5e Mon Sep 17 00:00:00 2001 From: lassulus Date: Sat, 18 Apr 2020 14:55:16 +0200 Subject: l prism.r: move pubkeys --- lass/1systems/prism/config.nix | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lass/1systems/prism/config.nix b/lass/1systems/prism/config.nix index c6e0400bf..d8bb14d0a 100644 --- a/lass/1systems/prism/config.nix +++ b/lass/1systems/prism/config.nix @@ -263,8 +263,6 @@ with import ; } { users.users.download.openssh.authorizedKeys.keys = [ - "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDB0d0JA20Vqn7I4lCte6Ne2EOmLZyMJyS9yIKJYXNLjbLwkQ4AYoQKantPBkTxR75M09E7d3j5heuWnCjWH45TrfQfe1EOSSC3ppCI6C6aIVlaNs+KhAYZS0m2Y8WkKn+TT5JLEa8yybYVN/RlZPOilpj/1QgjU6CQK+eJ1k/kK+QFXcwN82GDVh5kbTVcKUNp2tiyxFA+z9LY0xFDg/JHif2ROpjJVLQBJ+YPuOXZN5LDnVcuyLWKThjxy5srQ8iDjoxBg7dwLHjby5Mv41K4W61Gq6xM53gDEgfXk4cQhJnmx7jA/pUnsn2ZQDeww3hcc7vRf8soogXXz2KC9maiq0M/svaATsa9Ul4hrKnqPZP9Q8ScSEAUX+VI+x54iWrnW0p/yqBiRAzwsczdPzaQroUFTBxrq8R/n5TFdSHRMX7fYNOeVMjhfNca/gtfw9dYBVquCvuqUuFiRc0I7yK44rrMjjVQRcAbw6F8O7+04qWCmaJ8MPlmApwu2c05VMv9hiJo5p6PnzterRSLCqF6rIdhSnuOwrUIt1s/V+EEZXHCwSaNLaQJnYL0H9YjaIuGz4c8kVzxw4c0B6nl+hqW5y5/B2cuHiumnlRIDKOIzlv8ufhh21iN7QpIsPizahPezGoT1XqvzeXfH4qryo8O4yTN/PWoA+f7o9POU7L6hQ== lhebendanz@nixos" - config.krebs.users.palo.pubkey ]; } { @@ -382,6 +380,9 @@ with import ; lass.pubkey lass-android.pubkey makefu.pubkey + palo.pubkey + "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDB0d0JA20Vqn7I4lCte6Ne2EOmLZyMJyS9yIKJYXNLjbLwkQ4AYoQKantPBkTxR75M09E7d3j5heuWnCjWH45TrfQfe1EOSSC3ppCI6C6aIVlaNs+KhAYZS0m2Y8WkKn+TT5JLEa8yybYVN/RlZPOilpj/1QgjU6CQK+eJ1k/kK+QFXcwN82GDVh5kbTVcKUNp2tiyxFA+z9LY0xFDg/JHif2ROpjJVLQBJ+YPuOXZN5LDnVcuyLWKThjxy5srQ8iDjoxBg7dwLHjby5Mv41K4W61Gq6xM53gDEgfXk4cQhJnmx7jA/pUnsn2ZQDeww3hcc7vRf8soogXXz2KC9maiq0M/svaATsa9Ul4hrKnqPZP9Q8ScSEAUX+VI+x54iWrnW0p/yqBiRAzwsczdPzaQroUFTBxrq8R/n5TFdSHRMX7fYNOeVMjhfNca/gtfw9dYBVquCvuqUuFiRc0I7yK44rrMjjVQRcAbw6F8O7+04qWCmaJ8MPlmApwu2c05VMv9hiJo5p6PnzterRSLCqF6rIdhSnuOwrUIt1s/V+EEZXHCwSaNLaQJnYL0H9YjaIuGz4c8kVzxw4c0B6nl+hqW5y5/B2cuHiumnlRIDKOIzlv8ufhh21iN7QpIsPizahPezGoT1XqvzeXfH4qryo8O4yTN/PWoA+f7o9POU7L6hQ== lhebendanz@nixos" + "AAAAB3NzaC1yc2EAAAADAQABAAABgQC4ECL9NSCWqs4KVe+FF+2BPtl5Bv5aQPHqnXllCyiESZykwRKLx6/AbF5SbUAUMVZtp9oDSdp28m3BvVeWJ/q7hAbIxUtfd/jp+JBRZ8Kj6K5GzUO7Bhgl/o0A7xEjAeOKHiYuLjdPMcFUyl6Ah4ey/mcQYf6AdU0+hYUDeUlKe/YxxYD6202W0GJq2xGdIqs/TbopT9iaX+sv0wdXDVfFY72nFqOUwJW3u6O2viKKRugrz/eo50Eo3ts7pYz/FpDXExrUvV9Vu/bQ34pa8nKgF3/AKQHgmzljNQSVZKyAV8OY0UFonjBMXCBg2tXtwfnlzdx2SyuQVv55x+0AuRKsi85G2xLpXu1A3921pseBTW6Q6kbYK9eqxAay2c/kNbwNqFnO+nCvQ6Ier/hvGddOtItMu96IuU2E7mPN6WgvM8/3fjJRFWnZxFxqu/k7iH+yYT8qwRgdiSqZc76qvkYEuabdk2itstTRY0A3SpI3hFMZDw/7bxgMZtqpfyoRk5s= philip@shiki11:15 AAAAB3NzaC1yc2EAAAADAQABAAABgQC4ECL9NSCWqs4KVe+FF+2BPtl5Bv5aQPHqnXllCyiESZykwRKLx6/AbF5SbUAUMVZtp9oDSdp28m3BvVeWJ/q7hAbIxUtfd/jp+JBRZ8Kj6K5GzUO7Bhgl/o0A7xEjAeOKHiYuLjdPMcFUyl6Ah4ey/mcQYf6AdU0+hYUDeUlKe/YxxYD6202W0GJq2xGdIqs/TbopT9iaX+sv0wdXDVfFY72nFqOUwJW3u6O2viKKRugrz/eo50Eo3ts7pYz/FpDXExrUvV9Vu/bQ34pa8nKgF3/AKQHgmzljNQSVZKyAV8OY0UFonjBMXCBg2tXtwfnlzdx2SyuQVv55x+0AuRKsi85G2xLpXu1A3921pseBTW6Q6kbYK9eqxAay2c/kNbwNqFnO+nCvQ6Ier/hvGddOtItMu96IuU2E7mPN6WgvM8/3fjJRFWnZxFxqu/k7iH+yYT8qwRgdiSqZc76qvkYEuabdk2itstTRY0A3SpI3hFMZDw/7bxgMZtqpfyoRk5s= philip@shiki" ]; }; }; -- cgit v1.2.3 From 4e97430ef636724afe237a6b9184c7baa9303249 Mon Sep 17 00:00:00 2001 From: lassulus Date: Sat, 18 Apr 2020 14:55:39 +0200 Subject: l blue: enable tor client --- lass/2configs/blue.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/lass/2configs/blue.nix b/lass/2configs/blue.nix index aad8411b1..a4000cada 100644 --- a/lass/2configs/blue.nix +++ b/lass/2configs/blue.nix @@ -19,6 +19,7 @@ with (import ); ]; services.tor.enable = true; + services.tor.client.enable = true; krebs.iptables.tables.filter.INPUT.rules = [ { predicate = "-i retiolum -p udp --dport 60000:61000"; target = "ACCEPT";} -- cgit v1.2.3 From eeeff5f7d4c22053af549378150dcfc7af399dd1 Mon Sep 17 00:00:00 2001 From: lassulus Date: Sat, 18 Apr 2020 14:57:21 +0200 Subject: l: init review-mail-queue --- lass/2configs/exim-smarthost.nix | 2 ++ lass/5pkgs/review-mail-queue/default.nix | 39 ++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 lass/5pkgs/review-mail-queue/default.nix diff --git a/lass/2configs/exim-smarthost.nix b/lass/2configs/exim-smarthost.nix index 08a226e6d..82839beba 100644 --- a/lass/2configs/exim-smarthost.nix +++ b/lass/2configs/exim-smarthost.nix @@ -113,6 +113,8 @@ ]; in { + environment.systemPackages = [ pkgs.review-mail-queue ]; + krebs.exim-smarthost = { enable = true; dkim = [ diff --git a/lass/5pkgs/review-mail-queue/default.nix b/lass/5pkgs/review-mail-queue/default.nix new file mode 100644 index 000000000..c8c66706c --- /dev/null +++ b/lass/5pkgs/review-mail-queue/default.nix @@ -0,0 +1,39 @@ +{ pkgs }: let + + review = pkgs.writers.writeBash "review-mail" '' + mail="$1" + ${pkgs.exim}/bin/exim -Mvc "$mail" | grep -E 'Subject:|To:' + ${pkgs.exim}/bin/exim -Mvl "$mail" + while :; do + read -p 'delete?' key + case "$key" in + v*) + ${pkgs.exim}/bin/exim -Mvc "$mail" + ;; + d*) + ${pkgs.exim}/bin/exim -Mrm "$mail" + break + ;; + r*) + ${pkgs.exim}/bin/exim -Mt "$mail" + break + ;; + n*) + break + ;; + esac + done + echo '-------------------' + echo '-------------------' + echo '-------------------' + echo '-------------------' + echo '-------------------' + ''; + +in pkgs.writers.writeBashBin "review-mail" '' + for mail in $(${pkgs.exim}/bin/exim -bp \ + | ${pkgs.gnugrep}/bin/grep frozen \ + | ${pkgs.gawk}/bin/awk '{print $3}'); do + ${review} "$mail" + done +'' -- cgit v1.2.3 From 018efa847f1ae3ef1890ab11a0e4dc247aa603df Mon Sep 17 00:00:00 2001 From: lassulus Date: Sat, 18 Apr 2020 14:59:17 +0200 Subject: l: init nm-dmenu --- lass/2configs/network-manager.nix | 6 +++++- lass/5pkgs/custom/xmonad-lass/default.nix | 5 +---- lass/5pkgs/nm-dmenu/default.nix | 6 ++++++ 3 files changed, 12 insertions(+), 5 deletions(-) create mode 100644 lass/5pkgs/nm-dmenu/default.nix diff --git a/lass/2configs/network-manager.nix b/lass/2configs/network-manager.nix index ab27eb841..75b9bd1fd 100644 --- a/lass/2configs/network-manager.nix +++ b/lass/2configs/network-manager.nix @@ -26,7 +26,11 @@ users.users.mainUser = { extraGroups = [ "networkmanager" ]; packages = with pkgs; [ - gnome3.gnome_keyring gnome3.dconf + gnome3.gnome_keyring + gnome3.dconf ]; }; + environment.systemPackages = [ + pkgs.nm-dmenu + ]; } diff --git a/lass/5pkgs/custom/xmonad-lass/default.nix b/lass/5pkgs/custom/xmonad-lass/default.nix index c0aef513f..5d8653721 100644 --- a/lass/5pkgs/custom/xmonad-lass/default.nix +++ b/lass/5pkgs/custom/xmonad-lass/default.nix @@ -150,10 +150,7 @@ myKeyMap = , ("M4-", windows copyToAll) - , ("M4-", spawn "${pkgs.writeDash "nm-dmenu" '' - export PATH=$PATH:${pkgs.dmenu}/bin:${pkgs.networkmanagerapplet}/bin - exec ${pkgs.networkmanager_dmenu}/bin/networkmanager_dmenu "$@" - ''}") + , ("M4-", spawn "${pkgs.nm-dmenu}/bin/nm-dmenu") , ("M4-", spawn "${pkgs.writeDash "paste" '' ${pkgs.coreutils}/bin/sleep 0.1 ${pkgs.xclip}/bin/xclip -o | ${pkgs.xdotool}/bin/xdotool type -f - diff --git a/lass/5pkgs/nm-dmenu/default.nix b/lass/5pkgs/nm-dmenu/default.nix new file mode 100644 index 000000000..cb47bded3 --- /dev/null +++ b/lass/5pkgs/nm-dmenu/default.nix @@ -0,0 +1,6 @@ +{ pkgs, ... }: + +pkgs.writeDashBin "nm-dmenu" '' + export PATH=$PATH:${pkgs.dmenu}/bin:${pkgs.networkmanagerapplet}/bin + exec ${pkgs.networkmanager_dmenu}/bin/networkmanager_dmenu "$@" +'' -- cgit v1.2.3 From eb15765624036550a9b1d9186bbadea5d937ffd8 Mon Sep 17 00:00:00 2001 From: lassulus Date: Sat, 18 Apr 2020 14:59:35 +0200 Subject: l xmonad: use upstream writers --- lass/5pkgs/custom/xmonad-lass/default.nix | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/lass/5pkgs/custom/xmonad-lass/default.nix b/lass/5pkgs/custom/xmonad-lass/default.nix index 5d8653721..f9d73c139 100644 --- a/lass/5pkgs/custom/xmonad-lass/default.nix +++ b/lass/5pkgs/custom/xmonad-lass/default.nix @@ -1,16 +1,10 @@ { config, pkgs, ... }: -pkgs.writeHaskellPackage "xmonad-lass" { - executables.xmonad = { - extra-depends = [ - "containers" - "extra" - "unix" - "X11" - "xmonad" - "xmonad-contrib" - "xmonad-stockholm" - ]; - text = /* haskell */ '' +pkgs.writers.writeHaskellBin "xmonad" { + libraries = with pkgs.haskellPackages; [ + extra + xmonad-stockholm + ]; +} /* haskell */ '' {-# LANGUAGE LambdaCase #-} @@ -220,6 +214,4 @@ gridConfig = def allWorkspaceNames :: W.StackSet i l a sid sd -> X [i] allWorkspaceNames ws = return $ map W.tag (W.hidden ws ++ (map W.workspace $ W.visible ws)) ++ [W.tag $ W.workspace $ W.current ws] - ''; - }; -} +'' -- cgit v1.2.3 From 54827be4cce4770db0150cd8bea8b7a73d84536b Mon Sep 17 00:00:00 2001 From: lassulus Date: Sat, 18 Apr 2020 18:48:54 +0200 Subject: lib: add stripAttr --- lib/default.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/default.nix b/lib/default.nix index 14e6e27a3..5a948bbf3 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -49,6 +49,8 @@ let indent = replaceChars ["\n"] ["\n "]; + stripAttr = converge (filterAttrsRecursive (n: v: v != {} && v != null)); + mapNixDir = f: x: { list = foldl' mergeAttrs {} (map (mapNixDir1 f) x); path = mapNixDir1 f x; -- cgit v1.2.3 From 1e29f558953e47bd77e1514dd993304ecb9f453e Mon Sep 17 00:00:00 2001 From: lassulus Date: Sat, 18 Apr 2020 18:49:10 +0200 Subject: reaktor2: add listen option --- krebs/3modules/reaktor2.nix | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/krebs/3modules/reaktor2.nix b/krebs/3modules/reaktor2.nix index 837a9bea7..fcc453fa4 100644 --- a/krebs/3modules/reaktor2.nix +++ b/krebs/3modules/reaktor2.nix @@ -45,6 +45,10 @@ with import ; default = self.config.port == "6697"; type = types.bool; }; + API.listen = mkOption { + default = null; + type = types.nullOr types.str; + }; }; })); }; @@ -65,9 +69,11 @@ with import ; ExecStart = let configFile = pkgs.writeJSON configFileName configValue; configFileName = "${cfg.systemd-service-name}.config.json"; - configValue = recursiveUpdate { - logTime = false; - } (removeAttrs cfg ["_module"]); + configValue = stripAttr ( + recursiveUpdate { + logTime = false; + } (removeAttrs cfg ["_module"]) + ); in "${pkgs.reaktor2}/bin/reaktor ${configFile}"; Restart = "always"; RestartSec = "30"; -- cgit v1.2.3 From e0576eb972a8ad60bd8f9a4418add448d1e674a5 Mon Sep 17 00:00:00 2001 From: lassulus Date: Sat, 18 Apr 2020 19:17:27 +0200 Subject: l radio: post currently playing song to irc --- lass/2configs/radio.nix | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lass/2configs/radio.nix b/lass/2configs/radio.nix index 9da0a499c..562dbbe58 100644 --- a/lass/2configs/radio.nix +++ b/lass/2configs/radio.nix @@ -196,6 +196,14 @@ in { done | while read track; do echo "$(date -Is)" "$track" | tee -a "$HISTORY_FILE" echo "$(tail -$LIMIT "$HISTORY_FILE")" > "$HISTORY_FILE" + ${pkgs.curl}/bin/curl -fsSv --unix-socket /home/radio/reaktor.sock http://z/ \ + -H content-type:application/json \ + -d "$(${pkgs.jq}/bin/jq -n \ + --arg track "$track" '{ + command:"PRIVMSG", + params:["#the_playlist","playing: " + $track] + }' + )" done ''; in { @@ -207,6 +215,7 @@ in { serviceConfig = { ExecStart = recentlyPlayed; + User = "radio"; }; }; @@ -219,6 +228,7 @@ in { useTLS = true; nick = "the_playlist"; username = "radio"; + API.listen = "unix:/home/radio/reaktor.sock"; plugins = [ { plugin = "register"; -- cgit v1.2.3 From 8bc2a64f49c4f49d942576cd8dadfec832088ffe Mon Sep 17 00:00:00 2001 From: lassulus Date: Sun, 19 Apr 2020 12:30:46 +0200 Subject: l radio: set /current method to GET --- lass/2configs/radio.nix | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lass/2configs/radio.nix b/lass/2configs/radio.nix index 562dbbe58..146472e5f 100644 --- a/lass/2configs/radio.nix +++ b/lass/2configs/radio.nix @@ -277,6 +277,10 @@ in { }; script = '' case "$Method $Request_URI" in + "GET /current") + ${print_current}/bin/print_current + exit + ;; "POST /skip") ${skip_track}/bin/skip_track exit @@ -285,10 +289,6 @@ in { ${good_track}/bin/good_track exit ;; - "POST /current") - ${print_current}/bin/print_current - exit - ;; esac ''; }; -- cgit v1.2.3 From 355ebd73ee298a845ec2393f964354aa8e411073 Mon Sep 17 00:00:00 2001 From: lassulus Date: Sun, 19 Apr 2020 13:21:58 +0200 Subject: l radio: be more http compliant --- lass/2configs/radio.nix | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lass/2configs/radio.nix b/lass/2configs/radio.nix index 146472e5f..c28152175 100644 --- a/lass/2configs/radio.nix +++ b/lass/2configs/radio.nix @@ -44,9 +44,9 @@ let if [[ "$current_track" =~ ^the_playlist/music/.* ]]; then ${pkgs.attr}/bin/setfattr -n user.skip_count -v 0 "$music_dir"/"$current_track" else - mv "$music_dir"/"$current_track" "$music_dir"/the_playlist/music/ + mv "$music_dir"/"$current_track" "$music_dir"/the_playlist/music/ || : fi - echo good: "$track_infos" + echo good: "$track_infos" ''; print_current = pkgs.writeDashBin "print_current" '' @@ -278,6 +278,9 @@ in { script = '' case "$Method $Request_URI" in "GET /current") + printf 'HTTP/1.1 200 OK\r\n' + printf 'Connection: close\r\n' + printf '\r\n' ${print_current}/bin/print_current exit ;; -- cgit v1.2.3 From 1f0af710d80dbc0fd9dd2f3053ad7417bc173947 Mon Sep 17 00:00:00 2001 From: lassulus Date: Sun, 19 Apr 2020 16:26:45 +0200 Subject: l baseX: add some pkgs --- lass/2configs/baseX.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lass/2configs/baseX.nix b/lass/2configs/baseX.nix index 52d694c46..b3340cb31 100644 --- a/lass/2configs/baseX.nix +++ b/lass/2configs/baseX.nix @@ -71,12 +71,14 @@ in { gitAndTools.qgit git-preview gnome3.dconf + iodine lm_sensors ncdu nix-index nix-review nmap pavucontrol + ponymix powertop rxvt_unicode-with-plugins sxiv -- cgit v1.2.3 From 0efd13f942680fae75e46296a643d86c554aa33b Mon Sep 17 00:00:00 2001 From: lassulus Date: Sun, 19 Apr 2020 20:35:55 +0200 Subject: l radio: return /current as json --- lass/2configs/radio.nix | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/lass/2configs/radio.nix b/lass/2configs/radio.nix index c28152175..a457d6322 100644 --- a/lass/2configs/radio.nix +++ b/lass/2configs/radio.nix @@ -49,10 +49,25 @@ let echo good: "$track_infos" ''; + track_youtube_link = pkgs.writeDash "track_youtube_link" '' + ${pkgs.mpc_cli}/bin/mpc current -f %file% \ + | ${pkgs.gnused}/bin/sed 's@.*\(.\{11\}\)\.ogg@https://www.youtube.com/watch?v=\1@' + ''; + print_current = pkgs.writeDashBin "print_current" '' echo "$(${pkgs.mpc_cli}/bin/mpc current -f %file%) \ - $(${pkgs.mpc_cli}/bin/mpc current -f %file% \ - | ${pkgs.gnused}/bin/sed 's@.*\(.\{11\}\)\.ogg@http://www.youtube.com/watch?v=\1@')" + $(${track_youtube_link})" + ''; + + print_current_json = pkgs.writeDashBin "print_current_json" '' + ${pkgs.jq}/bin/jq -n -c \ + --arg name "$(${pkgs.mpc_cli}/bin/mpc current)" \ + --arg filename "$(${pkgs.mpc_cli}/bin/mpc current -f %file%)" \ + --arg youtube "$(${track_youtube_link})" '{ + name: $name, + filename: $filename, + youtube: $youtube + }' ''; in { @@ -81,6 +96,7 @@ in { good_track skip_track print_current + print_current_json ncmpcpp mpc_cli ]; @@ -281,7 +297,7 @@ in { printf 'HTTP/1.1 200 OK\r\n' printf 'Connection: close\r\n' printf '\r\n' - ${print_current}/bin/print_current + ${print_current_json}/bin/print_current_json exit ;; "POST /skip") -- cgit v1.2.3 From e3b37e2bc0b4315254969a622a74120518d59eb0 Mon Sep 17 00:00:00 2001 From: lassulus Date: Mon, 20 Apr 2020 08:46:10 +0200 Subject: l radio: log /skip & /good in irc --- lass/2configs/radio.nix | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/lass/2configs/radio.nix b/lass/2configs/radio.nix index a457d6322..6245691fe 100644 --- a/lass/2configs/radio.nix +++ b/lass/2configs/radio.nix @@ -70,6 +70,17 @@ let }' ''; + write_to_irc = pkgs.writeDash "write_to_irc" '' + ${pkgs.curl}/bin/curl -fsSv --unix-socket /home/radio/reaktor.sock http://z/ \ + -H content-type:application/json \ + -d "$(${pkgs.jq}/bin/jq -n \ + --arg text "$1" '{ + command:"PRIVMSG", + params:["#the_playlist",$text] + }' + )" + ''; + in { users.users = { "${name}" = rec { @@ -212,14 +223,7 @@ in { done | while read track; do echo "$(date -Is)" "$track" | tee -a "$HISTORY_FILE" echo "$(tail -$LIMIT "$HISTORY_FILE")" > "$HISTORY_FILE" - ${pkgs.curl}/bin/curl -fsSv --unix-socket /home/radio/reaktor.sock http://z/ \ - -H content-type:application/json \ - -d "$(${pkgs.jq}/bin/jq -n \ - --arg track "$track" '{ - command:"PRIVMSG", - params:["#the_playlist","playing: " + $track] - }' - )" + ${write_to_irc} "playing: $track" done ''; in { @@ -301,11 +305,21 @@ in { exit ;; "POST /skip") - ${skip_track}/bin/skip_track + printf 'HTTP/1.1 200 OK\r\n' + printf 'Connection: close\r\n' + printf '\r\n' + msg=$(${skip_track}/bin/skip_track) + ${write_to_irc} "$msg" + echo "$msg" exit ;; "POST /good") - ${good_track}/bin/good_track + printf 'HTTP/1.1 200 OK\r\n' + printf 'Connection: close\r\n' + printf '\r\n' + msg=$(${good_track}/bin/good_track) + ${write_to_irc} "$msg" + echo "$msg" exit ;; esac -- cgit v1.2.3 From bf4b5ef13c8f232401d5def002ab0c6e337d4e62 Mon Sep 17 00:00:00 2001 From: lassulus Date: Tue, 21 Apr 2020 14:21:17 +0200 Subject: l: split hass config --- lass/1systems/shodan/config.nix | 1 + lass/2configs/gg23.nix | 77 +------------------ lass/2configs/hass/default.nix | 86 +++++++++++++++++++++ lass/2configs/hass/lib.nix | 83 +++++++++++++++++++++ lass/2configs/hass/rooms/bett.nix | 27 +++++++ lass/2configs/hass/zigbee.nix | 152 ++++++++++++++++++++++++++++++++++++++ 6 files changed, 353 insertions(+), 73 deletions(-) create mode 100644 lass/2configs/hass/default.nix create mode 100644 lass/2configs/hass/lib.nix create mode 100644 lass/2configs/hass/rooms/bett.nix create mode 100644 lass/2configs/hass/zigbee.nix diff --git a/lass/1systems/shodan/config.nix b/lass/1systems/shodan/config.nix index 9bb31191c..064a56955 100644 --- a/lass/1systems/shodan/config.nix +++ b/lass/1systems/shodan/config.nix @@ -19,6 +19,7 @@ with import ; + ]; diff --git a/lass/2configs/gg23.nix b/lass/2configs/gg23.nix index b23494b28..3d4c1e306 100644 --- a/lass/2configs/gg23.nix +++ b/lass/2configs/gg23.nix @@ -20,12 +20,13 @@ with import ; } ''; machines = [ - { ethernetAddress = "c8:3d:d4:2c:40:ae"; hostName = "tv"; ipAddress = "10.42.0.3"; } + { ethernetAddress = "a8:a6:48:65:ce:4c"; hostName = "tv"; ipAddress = "10.42.0.3"; } { ethernetAddress = "3c:2a:f4:22:28:37"; hostName = "drucker"; ipAddress = "10.42.0.4"; } - { ethernetAddress = "80:7d:3a:67:b7:01"; hostName = "s20-bett"; ipAddress = "10.42.0.10"; } + { ethernetAddress = "80:7d:3a:67:b7:01"; hostName = "s20-tv"; ipAddress = "10.42.0.10"; } { ethernetAddress = "80:7d:3a:68:04:f0"; hostName = "s20-drucker"; ipAddress = "10.42.0.11"; } - { ethernetAddress = "80:7d:3a:68:11:a5"; hostName = "s20-kueche"; ipAddress = "10.42.0.12"; } + { ethernetAddress = "80:7d:3a:68:11:a5"; hostName = "s20-wasch"; ipAddress = "10.42.0.12"; } { ethernetAddress = "80:7d:3a:67:bb:69"; hostName = "s20-stereo"; ipAddress = "10.42.0.13"; } + { ethernetAddress = "ec:b5:fa:07:78:16"; hostName = "hue-bridge"; ipAddress = "10.42.0.21"; } { ethernetAddress = "80:8d:b7:c5:80:dc"; hostName = "arubaAP"; ipAddress = "10.42.0.99"; } ]; }; @@ -45,9 +46,6 @@ with import ; boot.kernel.sysctl."net.ipv4.ip_forward" = 1; krebs.iptables.tables.filter.INPUT.rules = [ - { predicate = "-i int0 -p tcp --dport 8123"; target = "ACCEPT"; } # hass - { predicate = "-i retiolum -p tcp --dport 8123"; target = "ACCEPT"; } # hass - { predicate = "-i int0 -p tcp --dport 1883"; target = "ACCEPT"; } # mosquitto { predicate = "-i int0 -p udp --dport 53"; target = "ACCEPT"; } # dns ]; krebs.iptables.tables.filter.FORWARD.rules = [ @@ -62,72 +60,5 @@ with import ; krebs.iptables.tables.nat.POSTROUTING.rules = [ { v6 = false; predicate = "-s 10.42.0.0/24 ! -d 10.42.0.0/24"; target = "MASQUERADE"; } ]; - - services.home-assistant = let - tasmota_s20 = name: topic: { - platform = "mqtt"; - inherit name; - state_topic = "stat/${topic}/POWER"; - command_topic = "cmnd/${topic}/POWER"; - payload_on = "ON"; - payload_off = "OFF"; - }; - in { - enable = true; - package = pkgs.home-assistant.override { - #extraComponents = [ - # (pkgs.fetchgit { - # url = "https://github.com/marcschumacher/dwd_pollen"; - # rev = "0.1"; - # sha256 = "12vldwsds27c9l15ffc6svk9mj17jhypcz736pvpmpqbsymllz2p"; - # }) - #]; - }; - config = { - homeassistant = { - name = "Home"; time_zone = "Europe/Berlin"; - latitude = "48.7687"; - longitude = "9.2478"; - elevation = 247; - }; - sun.elevation = 66; - discovery = {}; - frontend = { }; - mqtt = { - broker = "localhost"; - port = 1883; - client_id = "home-assistant"; - username = "gg23"; - password = "gg23-mqtt"; - keepalive = 60; - protocol = 3.1; - }; - sensor = [ - ]; - switch = [ - (tasmota_s20 "Drucker Strom" "drucker") - (tasmota_s20 "Bett Licht" "bett") - (tasmota_s20 "Kueche Licht" "kueche") - ]; - device_tracker = [ - { - platform = "luci"; - } - ]; - }; - }; - - services.mosquitto = { - enable = true; - host = "0.0.0.0"; - allowAnonymous = false; - checkPasswords = true; - users.gg23 = { - password = "gg23-mqtt"; - acl = [ "topic readwrite #" ]; - }; - }; - environment.systemPackages = [ pkgs.mosquitto ]; - } diff --git a/lass/2configs/hass/default.nix b/lass/2configs/hass/default.nix new file mode 100644 index 000000000..ef9361102 --- /dev/null +++ b/lass/2configs/hass/default.nix @@ -0,0 +1,86 @@ +{ config, lib, pkgs, ... }: +{ + imports = [ + ./zigbee.nix + ./rooms/bett.nix + ]; + + krebs.iptables.tables.filter.INPUT.rules = [ + { predicate = "-i int0 -p tcp --dport 1883"; target = "ACCEPT"; } # mosquitto + { predicate = "-i docker0 -p tcp --dport 1883"; target = "ACCEPT"; } # mosquitto + { predicate = "-i int0 -p tcp --dport 8123"; target = "ACCEPT"; } # hass + { predicate = "-i retiolum -p tcp --dport 8123"; target = "ACCEPT"; } # hass + ]; + + services.home-assistant = { + enable = true; + package = pkgs.home-assistant.override { + # extraComponents = [ "hue" ]; + }; + configWritable = true; + }; + + lass.hass.config = let + tasmota_s20 = name: topic: { + platform = "mqtt"; + inherit name; + state_topic = "stat/${topic}/POWER"; + command_topic = "cmnd/${topic}/POWER"; + payload_on = "ON"; + payload_off = "OFF"; + }; + in { + homeassistant = { + name = "Home"; + time_zone = "Europe/Berlin"; + latitude = "48.7687"; + longitude = "9.2478"; + elevation = 247; + }; + config = {}; + sun.elevation = 66; + discovery = {}; + frontend = {}; + mqtt = { + broker = "localhost"; + port = 1883; + client_id = "home-assistant"; + username = "gg23"; + password = "gg23-mqtt"; + keepalive = 60; + protocol = 3.1; + + discovery = true; + birth_message = { + topic = "/hass/status"; + payload = "online"; + }; + will_message = { + topic = "/hass/status"; + payload = "offline"; + }; + }; + sensor = [ + ]; + switch = [ + (tasmota_s20 "TV" "tv") + (tasmota_s20 "Drucker Strom" "drucker") + (tasmota_s20 "Waschmaschine" "wasch") + (tasmota_s20 "Stereo Anlage" "stereo") + ]; + mobile_app = {}; + }; + + services.mosquitto = { + enable = true; + host = "0.0.0.0"; + allowAnonymous = false; + checkPasswords = true; + users.gg23 = { + password = "gg23-mqtt"; + acl = [ "topic readwrite #" ]; + }; + }; + + environment.systemPackages = [ pkgs.mosquitto ]; +} diff --git a/lass/2configs/hass/lib.nix b/lass/2configs/hass/lib.nix new file mode 100644 index 000000000..c69f5e887 --- /dev/null +++ b/lass/2configs/hass/lib.nix @@ -0,0 +1,83 @@ +{ + lights = { + bett = "light.0x0017880106ed3bd8_light"; + essen = "light.0x0017880108327622_light"; + arbeit = "light.0x0017880106ee2865_light"; + nass = "light.0x00178801082e9f2f_light"; + }; + + sensors = { + bett = "0x00178801086ac38c"; + }; + + lightswitch = switch: light: { + automation = [ + { + trigger = { + platform = "mqtt"; + topic = "zigbee/${switch}"; + }; + condition = { + condition = "or"; + conditions = [ + { + condition = "template"; + value_template = "{{ trigger.payload_json.action == 'on-press' }}"; + } + { + condition = "template"; + value_template = "{{ trigger.payload_json.action == 'up-press' }}"; + } + { + condition = "and"; + conditions = [ + { + condition = "template"; + value_template = "{{ trigger.payload_json.action == 'down-press' }}"; + } + { + condition = "template"; + value_template = "{{ trigger.payload_json.brightness > 30 }}"; + } + ]; + } + ]; + }; + action = [ + { + service = "light.turn_on"; + data_template = { + entity_id = light; + brightness = "{{ trigger.payload_json.brightness }}"; + }; + } + ]; + } + { + trigger = { + platform = "mqtt"; + topic = "zigbee/${switch}"; + }; + condition = { + condition = "or"; + conditions = [ + { + condition = "template"; + value_template = "{{ trigger.payload_json.action == 'off-press' }}"; + } + { + condition = "template"; + value_template = "{{ trigger.payload_json.brightness < 30 }}"; + } + ]; + }; + action = { + service = "light.turn_off"; + data_template = { + entity_id = light; + }; + }; + } + ]; + }; +} diff --git a/lass/2configs/hass/rooms/bett.nix b/lass/2configs/hass/rooms/bett.nix new file mode 100644 index 000000000..21092ef5f --- /dev/null +++ b/lass/2configs/hass/rooms/bett.nix @@ -0,0 +1,27 @@ +{ lib, ... }: +with import ../lib.nix; + +{ + lass.hass.config = lib.lists.fold lib.recursiveUpdate {} [ + { + #automation = [{ + # trigger = { + # platform = "mqtt"; + # topic = "zigbee/0x00178801086ac38c/action"; + # payload = "on-press"; + # }; + # action = { + # service = "light.turn_on"; + # data = { + # brightness = 150; + # rgb_color = [ 255 0 0 ]; + # entity_id = [ + # "light.0x0017880108327622_light" + # ]; + # }; + # }; + #}]; + } + (lightswitch sensors.bett lights.bett) + ]; +} diff --git a/lass/2configs/hass/zigbee.nix b/lass/2configs/hass/zigbee.nix new file mode 100644 index 000000000..4d57f9ca4 --- /dev/null +++ b/lass/2configs/hass/zigbee.nix @@ -0,0 +1,152 @@ +{config, pkgs, lib, ...}: let + + zigbee2mqtt_cfg = pkgs.writeText "zigbee2mqtt.json" (builtins.toJSON { + homeassistant = true; + permit_join = true; + mqtt = { + discovery = true; + base_topic = "zigbee"; + server = "mqtt://10.42.0.1"; + user = "gg23"; + password = "gg23-mqtt"; + }; + serial.port = "/dev/cc2531"; + }); + +in { + # symlink the zigbee controller + services.udev.extraRules = '' + SUBSYSTEM=="tty", ATTRS{idVendor}=="0451", ATTRS{idProduct}=="16a8", SYMLINK+="cc2531", MODE="0660", GROUP="dailout" + ''; + + system.activationScripts.installZigbee = '' + install -d /var/lib/zigbee2mqtt + install ${zigbee2mqtt_cfg} /var/lib/zigbee2mqtt/configuration.yaml + ''; + + # hack to restart docker container on config change + systemd.services.docker-zigbee2mqtt.environment.cfg = zigbee2mqtt_cfg; + + docker-containers.zigbee2mqtt = { + image = "koenkk/zigbee2mqtt"; + extraDockerOptions = [ + "--device=/dev/cc2531:/dev/cc2531" + ]; + volumes = ["/var/lib/zigbee2mqtt:/app/data"]; + }; + + lass.hass.config = { + sensor = [ + # Sensor for monitoring the bridge state + { + platform = "mqtt"; + name = "Zigbee2mqtt Bridge state"; + state_topic = "/zigbee/bridge/state"; + icon = "mdi:router-wireless"; + } + # Sensor for Showing the Zigbee2mqtt Version + { + platform = "mqtt"; + name = "Zigbee2mqtt Version"; + state_topic = "/zigbee/bridge/config"; + value_template = "{{ value_json.version }}"; + icon = "mdi:zigbee"; + } + # Sensor for Showing the Coordinator Version + { + platform = "mqtt"; + name = "Coordinator Version"; + state_topic = "/zigbee/bridge/config"; + value_template = "{{ value_json.coordinator }}"; + icon = "mdi:chip"; + } + ]; + switch = [ + { + platform = "mqtt"; + name = "Zigbee2mqtt Main join"; + state_topic = "/zigbee/bridge/config/permit_join"; + command_topic = "/zigbee/bridge/config/permit_join"; + payload_on = "true"; + payload_off = "false"; + } + ]; + automation = [ + { + alias = "Zigbee2mqtt Log Level"; + initial_state = "on"; + trigger = { + platform = "state"; + entity_id = "input_select.zigbee2mqtt_log_level"; + }; + action = [ + { + service = "mqtt.publish"; + data = { + payload_template = "{{ states('input_select.zigbee2mqtt_log_level') }}"; + topic = "/zigbee/bridge/config/log_level"; + }; + } + ]; + } + # Automation to start timer when enable join is turned on + { + id = "zigbee_join_enabled"; + alias = "Zigbee Join Enabled"; + hide_entity = "true"; + trigger = { + platform = "state"; + entity_id = "switch.zigbee2mqtt_main_join"; + to = "on"; + }; + action = { + service = "timer.start"; + entity_id = "timer.zigbee_permit_join"; + }; + } + # Automation to stop timer when switch turned off and turn off switch when timer finished + { + id = "zigbee_join_disabled"; + alias = "Zigbee Join Disabled"; + hide_entity = "true"; + trigger = [ + { + platform = "event"; + event_type = "timer.finished"; + event_data.entity_id = "timer.zigbee_permit_join"; + } + { + platform = "state"; + entity_id = "switch.zigbee2mqtt_main_join"; + to = "off"; + } + ]; + action = [ + { service = "timer.cancel"; + data.entity_id = "timer.zigbee_permit_join"; + } + { service = "switch.turn_off"; + entity_id = "switch.zigbee2mqtt_main_join"; + } + ]; + } + ]; + input_select.zigbee2mqtt_log_level = { + name = "Zigbee2mqtt Log Level"; + options = [ + "debug" + "info" + "warn" + "error" + ]; + initial = "info"; + icon = "mdi:format-list-bulleted"; + }; + + timer.zigbee_permit_join = { + name = "Zigbee Time remaining"; + duration = 120; + }; + }; +} + -- cgit v1.2.3 From 085074a5c6d3ac4ea6d1517e4f96e46d49d720fa Mon Sep 17 00:00:00 2001 From: lassulus Date: Tue, 21 Apr 2020 14:21:40 +0200 Subject: l shodan.r: show realwallpaper --- lass/1systems/shodan/config.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/lass/1systems/shodan/config.nix b/lass/1systems/shodan/config.nix index 064a56955..831e03f79 100644 --- a/lass/1systems/shodan/config.nix +++ b/lass/1systems/shodan/config.nix @@ -21,6 +21,7 @@ with import ; + ]; krebs.build.host = config.krebs.hosts.shodan; -- cgit v1.2.3 From a50494cc5a192161151cce84716666d205873fd5 Mon Sep 17 00:00:00 2001 From: lassulus Date: Tue, 21 Apr 2020 14:24:14 +0200 Subject: l emot-menu: add more --- lass/5pkgs/emot-menu/default.nix | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lass/5pkgs/emot-menu/default.nix b/lass/5pkgs/emot-menu/default.nix index d5d84e456..440e160d0 100644 --- a/lass/5pkgs/emot-menu/default.nix +++ b/lass/5pkgs/emot-menu/default.nix @@ -18,6 +18,9 @@ ζ | zeta (╯°□°)╯ ┻━┻ | table flip (」゜ロ゜)」 | why woot +(_゜_゜_) | gloom I see you +༼ ༎ຶ ෴ ༎ຶ༽ | sad +(\/) (°,,,,°) (\/) | krebs ''; in -- cgit v1.2.3 From cabaf519b5970cbe5c1e57832d3bd12da4f47371 Mon Sep 17 00:00:00 2001 From: lassulus Date: Tue, 21 Apr 2020 14:38:00 +0200 Subject: l: add hass module --- lass/3modules/default.nix | 1 + lass/3modules/hass.nix | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 lass/3modules/hass.nix diff --git a/lass/3modules/default.nix b/lass/3modules/default.nix index 90dcb9d9c..057c7c74a 100644 --- a/lass/3modules/default.nix +++ b/lass/3modules/default.nix @@ -4,6 +4,7 @@ _: ./dnsmasq.nix ./ejabberd ./folderPerms.nix + ./hass.nix ./hosts.nix ./mysql-backup.nix ./news.nix diff --git a/lass/3modules/hass.nix b/lass/3modules/hass.nix new file mode 100644 index 000000000..30158e78a --- /dev/null +++ b/lass/3modules/hass.nix @@ -0,0 +1,34 @@ +{ config, lib, pkgs, ... }: +with import ; +let + + cfg = config.lass.hass; + +in { + options.lass.hass = { + config = mkOption { + default = {}; + type = with lib.types; let + valueType = nullOr (oneOf [ + bool + int + float + str + (attrsOf valueType) + (listOf valueType) + ]) // { + description = "Yaml value"; + emptyValue.value = {}; + }; + in valueType; + }; + }; + + config = + assert versionOlder version "20.09"; + mkIf (cfg.config != {}) + { + services.home-assistant.config = cfg.config; + }; +} + -- cgit v1.2.3 [cgit] Unable to lock slot /tmp/cgit/1a000000.lock: No such file or directory (2)