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(-) (limited to 'lass') 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(+) (limited to 'lass') 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 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(+) (limited to 'lass') 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(-) (limited to 'lass') 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(+) (limited to 'lass') 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 (limited to 'lass') 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 (limited to 'lass') 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(-) (limited to 'lass') 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 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(+) (limited to 'lass') 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(-) (limited to 'lass') 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(-) (limited to 'lass') 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(+) (limited to 'lass') 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(-) (limited to 'lass') 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(-) (limited to 'lass') 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 (limited to 'lass') 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(+) (limited to 'lass') 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(+) (limited to 'lass') 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 (limited to 'lass') 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 From 935552166a558002501494ab3eb358c86875b85b Mon Sep 17 00:00:00 2001 From: lassulus Date: Tue, 21 Apr 2020 17:17:42 +0200 Subject: l xmonad: follow rename of urxvt pkg --- lass/5pkgs/custom/xmonad-lass/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lass') diff --git a/lass/5pkgs/custom/xmonad-lass/default.nix b/lass/5pkgs/custom/xmonad-lass/default.nix index f9d73c139..e1c45598f 100644 --- a/lass/5pkgs/custom/xmonad-lass/default.nix +++ b/lass/5pkgs/custom/xmonad-lass/default.nix @@ -56,7 +56,7 @@ instance UrgencyHook LibNotifyUrgencyHook where safeSpawn "${pkgs.libnotify}/bin/notify-send" [show name, "workspace " ++ idx] myTerm :: FilePath -myTerm = "${pkgs.rxvt_unicode_with-plugins}/bin/urxvtc" +myTerm = "${pkgs.rxvt_unicode-with-plugins}/bin/urxvtc" myFont :: String myFont = "-*-clean-*-*-*-*-*-*-*-*-*-*-iso10646-1" -- cgit v1.2.3 From d76411357cb4dfee732e8e6a415d6bb14a7209e1 Mon Sep 17 00:00:00 2001 From: lassulus Date: Tue, 21 Apr 2020 17:52:41 +0200 Subject: l websites lass: remove deprecated acme plugins option --- lass/2configs/websites/lassulus.nix | 5 ----- 1 file changed, 5 deletions(-) (limited to 'lass') diff --git a/lass/2configs/websites/lassulus.nix b/lass/2configs/websites/lassulus.nix index 901fecfb2..983e7a05f 100644 --- a/lass/2configs/websites/lassulus.nix +++ b/lass/2configs/websites/lassulus.nix @@ -72,11 +72,6 @@ in { security.acme.certs."cgit.lassul.us" = { email = "lassulus@lassul.us"; webroot = "/var/lib/acme/acme-challenge"; - plugins = [ - "account_key.json" - "fullchain.pem" - "key.pem" - ]; group = "nginx"; user = "nginx"; }; -- cgit v1.2.3 From e780ca6410f7fbd6471ed223056a31cf4e2af45e Mon Sep 17 00:00:00 2001 From: lassulus Date: Tue, 21 Apr 2020 17:55:36 +0200 Subject: l uriel.r: disable libinput --- lass/1systems/uriel/config.nix | 1 + 1 file changed, 1 insertion(+) (limited to 'lass') diff --git a/lass/1systems/uriel/config.nix b/lass/1systems/uriel/config.nix index 3eddcfc52..b50dc63f5 100644 --- a/lass/1systems/uriel/config.nix +++ b/lass/1systems/uriel/config.nix @@ -12,6 +12,7 @@ with import ; i18n.defaultLocale ="de_DE.UTF-8"; time.timeZone = "Europe/Berlin"; services.xserver.enable = true; + services.xserver.libinput.enable = false; users.users.locke = { uid = genid "locke"; home = "/home/locke"; -- cgit v1.2.3 From 5546774ac9f86976d53b3c038e64c16a139c5838 Mon Sep 17 00:00:00 2001 From: lassulus Date: Tue, 21 Apr 2020 18:14:52 +0200 Subject: l websites lass: add acme mail --- lass/2configs/websites/lassulus.nix | 1 + 1 file changed, 1 insertion(+) (limited to 'lass') diff --git a/lass/2configs/websites/lassulus.nix b/lass/2configs/websites/lassulus.nix index 983e7a05f..cea30f2c5 100644 --- a/lass/2configs/websites/lassulus.nix +++ b/lass/2configs/websites/lassulus.nix @@ -13,6 +13,7 @@ in { ]; security.acme = { + email = "acme@lassul.us"; certs."lassul.us" = { allowKeysForGroup = true; group = "lasscert"; -- cgit v1.2.3 From cb7ecfee3b4ba4a0034e28014d3ce92bcf750661 Mon Sep 17 00:00:00 2001 From: lassulus Date: Tue, 21 Apr 2020 18:27:06 +0200 Subject: l: accept acme terms --- lass/2configs/websites/lassulus.nix | 1 + 1 file changed, 1 insertion(+) (limited to 'lass') diff --git a/lass/2configs/websites/lassulus.nix b/lass/2configs/websites/lassulus.nix index cea30f2c5..baeac213b 100644 --- a/lass/2configs/websites/lassulus.nix +++ b/lass/2configs/websites/lassulus.nix @@ -14,6 +14,7 @@ in { security.acme = { email = "acme@lassul.us"; + acceptTerms = true; certs."lassul.us" = { allowKeysForGroup = true; group = "lasscert"; -- cgit v1.2.3 From c49867b40327f83a18b956404875637ca379c1ba Mon Sep 17 00:00:00 2001 From: lassulus Date: Tue, 21 Apr 2020 20:38:40 +0200 Subject: remove nin --- lass/1systems/prism/config.nix | 7 ------- 1 file changed, 7 deletions(-) (limited to 'lass') diff --git a/lass/1systems/prism/config.nix b/lass/1systems/prism/config.nix index d8bb14d0a..004183102 100644 --- a/lass/1systems/prism/config.nix +++ b/lass/1systems/prism/config.nix @@ -65,13 +65,6 @@ with import ; config.krebs.users.makefu.pubkey ]; }; - users.users.nin = { - uid = genid "nin"; - isNormalUser = true; - openssh.authorizedKeys.keys = [ - config.krebs.users.nin.pubkey - ]; - }; users.extraUsers.dritter = { uid = genid_uint31 "dritter"; isNormalUser = true; -- cgit v1.2.3 From 8b6e3b79315bdb70504674a61ea2c209e460e50e Mon Sep 17 00:00:00 2001 From: lassulus Date: Wed, 22 Apr 2020 08:04:24 +0200 Subject: l prism.r: remove onondaga --- lass/1systems/prism/config.nix | 20 -------------------- 1 file changed, 20 deletions(-) (limited to 'lass') diff --git a/lass/1systems/prism/config.nix b/lass/1systems/prism/config.nix index 004183102..f1f14e791 100644 --- a/lass/1systems/prism/config.nix +++ b/lass/1systems/prism/config.nix @@ -116,26 +116,6 @@ with import ; localAddress = "10.233.2.2"; }; } - { - #onondaga - systemd.services."container@onondaga".reloadIfChanged = mkForce false; - containers.onondaga = { - config = { ... }: { - imports = [ ]; - environment.systemPackages = [ pkgs.git ]; - services.openssh.enable = true; - users.users.root.openssh.authorizedKeys.keys = [ - config.krebs.users.lass.pubkey - config.krebs.users.nin.pubkey - ]; - }; - autoStart = true; - enableTun = true; - privateNetwork = true; - hostAddress = "10.233.2.5"; - localAddress = "10.233.2.6"; - }; - } -- cgit v1.2.3 From e8002452f9d049eabe42b194624713f85cfbc91b Mon Sep 17 00:00:00 2001 From: lassulus Date: Wed, 22 Apr 2020 15:49:28 +0200 Subject: l: rip umts module --- lass/3modules/default.nix | 1 - lass/3modules/umts.nix | 112 ---------------------------------------------- 2 files changed, 113 deletions(-) delete mode 100644 lass/3modules/umts.nix (limited to 'lass') diff --git a/lass/3modules/default.nix b/lass/3modules/default.nix index 057c7c74a..f6179c394 100644 --- a/lass/3modules/default.nix +++ b/lass/3modules/default.nix @@ -12,7 +12,6 @@ _: ./pyload.nix ./restic.nix ./screenlock.nix - ./umts.nix ./usershadow.nix ./xjail.nix ./autowifi.nix diff --git a/lass/3modules/umts.nix b/lass/3modules/umts.nix deleted file mode 100644 index 207278440..000000000 --- a/lass/3modules/umts.nix +++ /dev/null @@ -1,112 +0,0 @@ -{ config, lib, pkgs, ... }: - -with import ; - -let - cfg = config.lass.umts; - - out = { - options.lass.umts = api; - config = lib.mkIf cfg.enable imp; - }; - - api = { - enable = mkEnableOption "umts"; - modem = mkOption { - type = types.str; - default = "/dev/ttyUSB0"; - }; - initstrings = mkOption { - type = types.str; - default = '' - Init1 = ATZ - Init2 = ATQ0 V1 E1 S0=0 &C1 &D2 - ''; - }; - username = mkOption { - type = types.str; - default = "default"; - }; - password = mkOption { - type = types.str; - default = "default"; - }; - pppDefaults = mkOption { - type = types.str; - default = '' - noipdefault - usepeerdns - defaultroute - persist - noauth - ''; - }; - }; - - nixpkgs-1509 = import (pkgs.fetchFromGitHub { - owner = "NixOS"; repo = "nixpkgs-channels"; - rev = "91371c2bb6e20fc0df7a812332d99c38b21a2bda"; - sha256 = "1as1i0j9d2n3iap9b471y4x01561r2s3vmjc5281qinirlr4al73"; - }) {}; - - wvdial = nixpkgs-1509.wvdial; # https://github.com/NixOS/nixpkgs/issues/16113 - - umts-bin = pkgs.writeScriptBin "umts" '' - #!/bin/sh - set -euf - systemctl start umts - trap "systemctl stop umts;trap - INT TERM EXIT;exit" INT TERM EXIT - echo nameserver 8.8.8.8 | tee -a /etc/resolv.conf - journalctl -xfu umts - ''; - - wvdial-defaults = '' - [Dialer Defaults] - Modem = ${cfg.modem} - ${cfg.initstrings} - Modem Type = Analog Modem - Baud = 460800 - phone= *99# - Username = ${cfg.username} - Password = ${cfg.password} - Stupid Mode = 1 - Idle Seconds = 0 - PPPD Path = ${pkgs.ppp}/bin/pppd - ''; - - imp = { - environment.shellAliases = { - umts = "sudo ${umts-bin}/bin/umts"; - }; - - environment.systemPackages = [ - pkgs.ppp - ]; - - security.sudo.extraConfig = '' - lass ALL= (root) NOPASSWD: ${umts-bin}/bin/umts - ''; - - environment.etc = [ - { - source = pkgs.writeText "wvdial.conf" wvdial-defaults; - target = "wvdial.conf"; - } - { - source = pkgs.writeText "wvdial" cfg.pppDefaults; - target = "ppp/peers/wvdial"; - } - ]; - - systemd.services.umts = { - description = "UMTS wvdial Service"; - serviceConfig = { - Type = "simple"; - Restart = "always"; - RestartSec = "10s"; - ExecStart = "${wvdial}/bin/wvdial -n"; - }; - }; - }; - -in out -- cgit v1.2.3 From 1e91a3c8b22519e4302fdcd5e28151fbc534a2a9 Mon Sep 17 00:00:00 2001 From: lassulus Date: Wed, 22 Apr 2020 15:52:54 +0200 Subject: l network-manager: disable modem-manager --- lass/2configs/network-manager.nix | 12 ------------ 1 file changed, 12 deletions(-) (limited to 'lass') diff --git a/lass/2configs/network-manager.nix b/lass/2configs/network-manager.nix index 75b9bd1fd..b41cc7ac8 100644 --- a/lass/2configs/network-manager.nix +++ b/lass/2configs/network-manager.nix @@ -2,18 +2,6 @@ { networking.wireless.enable = lib.mkForce false; - systemd.services.modemmanager = { - description = "ModemManager"; - after = [ "network-manager.service" ]; - bindsTo = [ "network-manager.service" ]; - wantedBy = [ "network-manager.service" ]; - serviceConfig = { - ExecStart = "${pkgs.modemmanager}/bin/ModemManager"; - PrivateTmp = true; - Restart = "always"; - RestartSec = "5"; - }; - }; networking.networkmanager = { ethernet.macAddress = "random"; wifi.macAddress = "random"; -- cgit v1.2.3 From 2cfe78f16c3b4ecaec672bc3cd2f8edd2f2c5930 Mon Sep 17 00:00:00 2001 From: lassulus Date: Wed, 22 Apr 2020 15:53:22 +0200 Subject: l: add ppp.nix --- lass/1systems/mors/config.nix | 1 + lass/2configs/ppp.nix | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 lass/2configs/ppp.nix (limited to 'lass') diff --git a/lass/1systems/mors/config.nix b/lass/1systems/mors/config.nix index fe0b6d85b..ff21bf5db 100644 --- a/lass/1systems/mors/config.nix +++ b/lass/1systems/mors/config.nix @@ -39,6 +39,7 @@ with import ; # + { krebs.iptables.tables.filter.INPUT.rules = [ #risk of rain diff --git a/lass/2configs/ppp.nix b/lass/2configs/ppp.nix new file mode 100644 index 000000000..9cc7568a5 --- /dev/null +++ b/lass/2configs/ppp.nix @@ -0,0 +1,32 @@ +{ pkgs, ... }: { + + # usage: pppd call default + + environment.etc."ppp/peers/default".text = '' + /dev/ttyACM2 + 921600 + crtscts + defaultroute + holdoff 10 + lock + maxfail 0 + noauth + nodetach + noipdefault + passive + persist + usepeerdns + connect "${pkgs.ppp}/bin/chat -f ${pkgs.writeText "default.chat" '' + ABORT "BUSY" + ABORT "NO CARRIER" + REPORT CONNECT + "" "ATDT*99#" + CONNECT + ''}" + ''; + + environment.systemPackages = [ + pkgs.ppp + ]; + +} -- cgit v1.2.3 From 2b5db20b95a30cbf3f31baae406fd5b915828573 Mon Sep 17 00:00:00 2001 From: lassulus Date: Wed, 22 Apr 2020 16:04:43 +0200 Subject: l mors.r: remove umts module stuff --- lass/1systems/mors/config.nix | 10 ---------- 1 file changed, 10 deletions(-) (limited to 'lass') diff --git a/lass/1systems/mors/config.nix b/lass/1systems/mors/config.nix index ff21bf5db..c1ceb0633 100644 --- a/lass/1systems/mors/config.nix +++ b/lass/1systems/mors/config.nix @@ -77,16 +77,6 @@ with import ; }; }; } - { - lass.umts = { - enable = true; - modem = "/dev/serial/by-id/usb-Lenovo_F5521gw_2C7D8D7C35FC7040-if09"; - initstrings = '' - Init1 = AT+CFUN=1 - Init2 = AT+CGDCONT=1,"IP","pinternet.interkom.de","",0,0 - ''; - }; - } { services.nginx = { enable = true; -- cgit v1.2.3 From 5df24fc8de72600d4ccb15b896b99c03b5a92a8f Mon Sep 17 00:00:00 2001 From: lassulus Date: Wed, 22 Apr 2020 16:42:14 +0200 Subject: l xjail: remove deprecated string usage --- lass/3modules/xjail.nix | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'lass') diff --git a/lass/3modules/xjail.nix b/lass/3modules/xjail.nix index f6ce7ccc9..37f90ee1c 100644 --- a/lass/3modules/xjail.nix +++ b/lass/3modules/xjail.nix @@ -6,11 +6,11 @@ with import ; type = types.attrsOf (types.submodule ({ config, ...}: { options = { name = mkOption { - type = types.string; + type = types.str; default = config._module.args.name; }; user = mkOption { - type = types.string; + type = types.str; default = config.name; }; groups = mkOption { @@ -18,11 +18,11 @@ with import ; default = []; }; from = mkOption { - type = types.string; + type = types.str; default = "lass"; }; display = mkOption { - type = types.string; + type = types.str; default = toString (genid_uint31 config._module.args.name); }; dpi = mkOption { @@ -47,7 +47,7 @@ with import ; }; wm = mkOption { #TODO find type - type = types.string; + type = types.str; default = "${pkgs.writeHaskellPackage "xephyrify-xmonad" { executables.xmonad = { extra-depends = [ -- cgit v1.2.3 From 39236226cdf8692b5904831471d9ad45942146a4 Mon Sep 17 00:00:00 2001 From: lassulus Date: Wed, 22 Apr 2020 16:42:43 +0200 Subject: l baseX: set windowManager.default -> defaultSession --- lass/2configs/baseX.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lass') diff --git a/lass/2configs/baseX.nix b/lass/2configs/baseX.nix index b3340cb31..1185be9d4 100644 --- a/lass/2configs/baseX.nix +++ b/lass/2configs/baseX.nix @@ -114,7 +114,7 @@ in { xkbOptions = "caps:escape"; libinput.enable = true; displayManager.lightdm.enable = true; - windowManager.default = "xmonad"; + displayManager.defaultSession = "none+xmonad"; windowManager.session = [{ name = "xmonad"; start = '' -- cgit v1.2.3 From 90a2b572d45eb6989e38546049cbed4c0b842ca1 Mon Sep 17 00:00:00 2001 From: lassulus Date: Sun, 26 Apr 2020 19:22:50 +0200 Subject: l: add home-media.nix --- lass/1systems/icarus/config.nix | 11 +++-------- lass/1systems/shodan/config.nix | 13 +------------ lass/2configs/home-media.nix | 23 +++++++++++++++++++++++ 3 files changed, 27 insertions(+), 20 deletions(-) create mode 100644 lass/2configs/home-media.nix (limited to 'lass') diff --git a/lass/1systems/icarus/config.nix b/lass/1systems/icarus/config.nix index 5e16052ad..8332e7c53 100644 --- a/lass/1systems/icarus/config.nix +++ b/lass/1systems/icarus/config.nix @@ -21,20 +21,15 @@ with import ; # + ]; - #media center - users.users.media = { - isNormalUser = true; - uid = genid_uint31 "media"; - extraGroups = [ "video" "audio" ]; - }; + krebs.build.host = config.krebs.hosts.icarus; services.xserver.displayManager.lightdm.autoLogin = { enable = true; user = "media"; }; - krebs.build.host = config.krebs.hosts.icarus; - programs.adb.enable = true; + environment.systemPackages = [ pkgs.chromium ]; } diff --git a/lass/1systems/shodan/config.nix b/lass/1systems/shodan/config.nix index 831e03f79..e41c9bd1e 100644 --- a/lass/1systems/shodan/config.nix +++ b/lass/1systems/shodan/config.nix @@ -22,22 +22,11 @@ with import ; + ]; krebs.build.host = config.krebs.hosts.shodan; - #media center - users.users.media = { - isNormalUser = true; - uid = genid_uint31 "media"; - extraGroups = [ "video" "audio" ]; - }; - - services.xserver.displayManager.lightdm.autoLogin = { - enable = true; - user = "media"; - }; - services.logind.lidSwitch = "ignore"; services.logind.lidSwitchDocked = "ignore"; diff --git a/lass/2configs/home-media.nix b/lass/2configs/home-media.nix new file mode 100644 index 000000000..7e10aed34 --- /dev/null +++ b/lass/2configs/home-media.nix @@ -0,0 +1,23 @@ +with import ; +{ pkgs, ... }: +{ + users.users.media = { + isNormalUser = true; + uid = genid_uint31 "media"; + extraGroups = [ "video" "audio" ]; + }; + + services.xserver.displayManager.lightdm.autoLogin = { + enable = true; + user = "media"; + }; + + hardware.pulseaudio.configFile = pkgs.writeText "pulse.pa" '' + .include ${pkgs.pulseaudioFull}/etc/pulse/default.pa + load-module module-native-protocol-tcp auth-ip-acl=127.0.0.1;10.42.0.0/24 auth-anonymous=1 + ''; + + krebs.iptables.tables.filter.INPUT.rules = [ + { predicate = "-p tcp --dport 4713"; target = "ACCEPT"; } # pulseaudio + ]; +} -- cgit v1.2.3 From cf5b35b2df428495f5bf4dd89e3cab190f069080 Mon Sep 17 00:00:00 2001 From: lassulus Date: Sat, 16 May 2020 17:21:34 +0200 Subject: l hass: add more rooms & automations --- lass/2configs/hass/default.nix | 26 ++++- lass/2configs/hass/lib.nix | 196 +++++++++++++++++++++++++++++++++++-- lass/2configs/hass/rooms/bett.nix | 25 +---- lass/2configs/hass/rooms/essen.nix | 9 ++ lass/2configs/hass/rooms/nass.nix | 10 ++ lass/2configs/hass/zigbee.nix | 79 ++++++++------- 6 files changed, 272 insertions(+), 73 deletions(-) create mode 100644 lass/2configs/hass/rooms/essen.nix create mode 100644 lass/2configs/hass/rooms/nass.nix (limited to 'lass') diff --git a/lass/2configs/hass/default.nix b/lass/2configs/hass/default.nix index ef9361102..639ba3d3f 100644 --- a/lass/2configs/hass/default.nix +++ b/lass/2configs/hass/default.nix @@ -1,8 +1,12 @@ { config, lib, pkgs, ... }: +with import ./lib.nix { inherit lib; }; + { imports = [ ./zigbee.nix ./rooms/bett.nix + ./rooms/essen.nix + ./rooms/nass.nix ]; krebs.iptables.tables.filter.INPUT.rules = [ @@ -33,9 +37,11 @@ homeassistant = { name = "Home"; time_zone = "Europe/Berlin"; - latitude = "48.7687"; - longitude = "9.2478"; - elevation = 247; + latitude = "52.46187"; + longitude = "13.41489"; + elevation = 90; + unit_system = "metric"; + customize = friendly_names; }; config = {}; sun.elevation = 66; @@ -61,6 +67,10 @@ }; }; sensor = [ + { + platform = "dwd_weather_warnings"; + region_name = "Berlin"; + } ]; switch = [ (tasmota_s20 "TV" "tv") @@ -69,6 +79,16 @@ (tasmota_s20 "Stereo Anlage" "stereo") ]; mobile_app = {}; + hue = {}; + weather = [ + { + platform = "openweathermap"; + api_key = "xxx"; # TODO put into secrets + } + ]; + system_health = {}; + history = {}; + shopping_list = {}; }; services.mosquitto = { diff --git a/lass/2configs/hass/lib.nix b/lass/2configs/hass/lib.nix index c69f5e887..555cfae28 100644 --- a/lass/2configs/hass/lib.nix +++ b/lass/2configs/hass/lib.nix @@ -1,18 +1,196 @@ -{ +{ lib, ... }: +rec { lights = { - bett = "light.0x0017880106ed3bd8_light"; - essen = "light.0x0017880108327622_light"; - arbeit = "light.0x0017880106ee2865_light"; - nass = "light.0x00178801082e9f2f_light"; + bett = "0x0017880106ed3bd8"; + essen = "0x0017880108327622"; + arbeit = "0x0017880106ee2865"; + nass = "0x00178801082e9f2f"; + }; + + switches = { + dimmer = { + bett = "0x00178801086ac38c"; + essen = "0x00178801086ad1fb"; + nass = "0x00178801086ac373"; + }; }; sensors = { - bett = "0x00178801086ac38c"; + movement = { + essen = "0x0017880106f772f2"; + nass = "0x0017880106f77f30"; + }; + }; + + friendly_names = + lib.mapAttrs' (n: v: lib.nameValuePair "light.${v}_light" { friendly_name = "l.${n}"; }) lights // + lib.mapAttrs' (n: v: lib.nameValuePair "binary_sensor.${v}_update_available" { friendly_name = "s.${n}_up"; }) switches.dimmer // + lib.mapAttrs' (n: v: lib.nameValuePair "binary_sensor.${v}_update_available" { friendly_name = "i.${n}_up"; }) sensors.movement // + lib.mapAttrs' (n: v: lib.nameValuePair "binary_sensor.${v}_update_available" { friendly_name = "l.${n}_up"; }) lights // + lib.mapAttrs' (n: v: lib.nameValuePair "sensor.${v}_linkquality" { friendly_name = "s.${n}_link"; }) switches.dimmer // + lib.mapAttrs' (n: v: lib.nameValuePair "sensor.${v}_linkquality" { friendly_name = "i.${n}_link"; }) sensors.movement // + lib.mapAttrs' (n: v: lib.nameValuePair "sensor.${v}_linkquality" { friendly_name = "l.${n}_link"; }) lights // + lib.mapAttrs' (n: v: lib.nameValuePair "sensor.${v}_battery" { friendly_name = "s.${n}_bat"; }) switches.dimmer // + lib.mapAttrs' (n: v: lib.nameValuePair "sensor.${v}_battery" { friendly_name = "i.${n}_bat"; }) sensors.movement // + lib.mapAttrs' (n: v: lib.nameValuePair "sensor.${v}_action" { friendly_name = "s.${n}_act"; }) switches.dimmer // + lib.mapAttrs' (n: v: lib.nameValuePair "binary_sensor.${v}_occupancy" { friendly_name = "i.${n}_move"; }) sensors.movement // + lib.mapAttrs' (n: v: lib.nameValuePair "binary_sensor.${v}_occupancy" { friendly_name = "i.${n}_move"; }) sensors.movement // + lib.mapAttrs' (n: v: lib.nameValuePair "sensor.${v}_temperature" { friendly_name = "i.${n}_heat"; }) sensors.movement // + lib.mapAttrs' (n: v: lib.nameValuePair "sensor.${v}_temperature" { friendly_name = "i.${n}_heat"; }) sensors.movement // + lib.mapAttrs' (n: v: lib.nameValuePair "sensor.${v}_illuminance" { friendly_name = "i.${n}_lux"; }) sensors.movement // + lib.mapAttrs' (n: v: lib.nameValuePair "sensor.${v}_illuminance" { friendly_name = "i.${n}_lux"; }) sensors.movement // + {}; + + detect_movement = sensor: light: delay: + let + id = "${sensor}_${light}"; + sensor_ = "binary_sensor.${sensor}_occupancy"; + light_ = "light.${light}_light"; + in { + input_boolean."${id}" = { + }; + timer."${id}" = { + duration = delay; + }; + automation = [ + # { + # alias = "debug detect_movement"; + # trigger = { + # platform = "state"; + # entity_id = sensor_; + # }; + # action = [ + # { + # service = "system_log.write"; + # data_template = { + # message = "XXXXXXXXXXXXXXXXXXXXXX {{ states('input_boolean.${sensor}_${light}_triggered') == 'on' }}"; + # #message = "XXXXXXXXXXXXXXXXXXXXXX {{ state_attr('trigger.to_state.state', 'illuminance') }}"; + # }; + # } + # ]; + # } + { + alias = "movement reset timer ${id}"; + hide_entity = true; + trigger = { + platform = "state"; + entity_id = sensor_; + from = "off"; + to = "on"; + }; + action = [ + { + service = "timer.cancel"; + data_template.entity_id = "timer.${id}"; + } + ]; + } + { + alias = "movement on ${id}"; + # hide_entity = true; + trigger = { + platform = "state"; + entity_id = "binary_sensor.${sensor}_occupancy"; + from = "off"; + to = "on"; + }; + condition = { + condition = "and"; + conditions = [ + { + condition = "template"; + value_template = "{{ trigger.to_state.attributes.illuminance < 13000 }}"; + } + { + condition = "template"; + value_template = "{{ states('${light_}') == 'off' }}"; + } + ]; + }; + action = [ + { + service = "light.turn_on"; + data_template = { + entity_id = light_; + brightness = "100"; + }; + } + { delay = "0:00:02"; } + { + service = "input_boolean.turn_on"; + data_template.entity_id = "input_boolean.${id}"; + } + ]; + } + { + alias = "movement off ${id}"; +