From d40f20b711a71240d235a26b6c87156afc355612 Mon Sep 17 00:00:00 2001 From: tv Date: Fri, 29 Mar 2019 18:14:39 +0100 Subject: q-power_supply: init from tv's q --- krebs/5pkgs/simple/q-power_supply.nix | 126 +++++++++++++++++++++++++++++++++ tv/5pkgs/simple/q/default.nix | 127 +--------------------------------- 2 files changed, 127 insertions(+), 126 deletions(-) create mode 100644 krebs/5pkgs/simple/q-power_supply.nix diff --git a/krebs/5pkgs/simple/q-power_supply.nix b/krebs/5pkgs/simple/q-power_supply.nix new file mode 100644 index 000000000..87f900194 --- /dev/null +++ b/krebs/5pkgs/simple/q-power_supply.nix @@ -0,0 +1,126 @@ +{ gawk, gnused, writeDashBin }: + +writeDashBin "q-power_supply" '' + power_supply() {( + set -efu + uevent=$1 + eval "$(${gnused}/bin/sed -n ' + s/^\([A-Z_]\+=[0-9A-Za-z_-]*\)$/export \1/p + ' $uevent)" + case $POWER_SUPPLY_NAME in + AC) + exit # not battery + ;; + esac + exec = .42) t_col = "1;32" + else if (r >= 23) t_col = "1;33" + else if (r >= 11) t_col = "1;31" + else t_col = "5;1;31" + return sgr(t_col) strdup("■", t1) sgr(";30") strdup("■", t2) sgr() + } + + function sgr(p) { + return "\x1b[" p "m" + } + + function strdup(s,n,t) { + t = sprintf("%"n"s","") + gsub(/ /,s,t) + return t + } + + END { + name = ENVIRON["POWER_SUPPLY_NAME"] + + charge_unit = "Ah" + charge_now = ENVIRON["POWER_SUPPLY_CHARGE_NOW"] / 10^6 + charge_full = ENVIRON["POWER_SUPPLY_CHARGE_FULL"] / 10^6 + + current_unit = "A" + current_now = ENVIRON["POWER_SUPPLY_CURRENT_NOW"] / 10^6 + + energy_unit = "Wh" + energy_now = ENVIRON["POWER_SUPPLY_ENERGY_NOW"] / 10^6 + energy_full = ENVIRON["POWER_SUPPLY_ENERGY_FULL"] / 10^6 + + power_unit = "W" + power_now = ENVIRON["POWER_SUPPLY_POWER_NOW"] / 10^6 + + voltage_unit = "V" + voltage_now = ENVIRON["POWER_SUPPLY_VOLTAGE_NOW"] / 10^6 + voltage_min_design = ENVIRON["POWER_SUPPLY_VOLTAGE_MIN_DESIGN"] / 10^6 + + #printf "charge_now: %s\n", charge_now + #printf "charge_full: %s\n", charge_full + #printf "current_now: %s\n", current_now + #printf "energy_now: %s\n", energy_now + #printf "energy_full: %s\n", energy_full + #printf "energy_full: %s\n", ENVIRON["POWER_SUPPLY_ENERGY_FULL"] + #printf "energy_full: %s\n", ENVIRON["POWER_SUPPLY_ENERGY_FULL"] / 10^6 + #printf "power_now: %s\n", power_now + #printf "voltage_now: %s\n", voltage_now + + if (current_now == 0 && voltage_now != 0) { + current_now = power_now / voltage_now + } + if (power_now == 0) { + power_now = current_now * voltage_now + } + if (charge_now == 0 && voltage_min_design != 0) { + charge_now = energy_now / voltage_min_design + } + if (energy_now == 0) { + energy_now = charge_now * voltage_min_design + } + if (charge_full == 0 && voltage_min_design != 0) { + charge_full = energy_full / voltage_min_design + } + if (energy_full == 0) { + energy_full = charge_full * voltage_min_design + } + + if (charge_now == 0 || charge_full == 0) { + die("unknown charge") + } + + charge_ratio = charge_now / charge_full + + out = out name + out = out sprintf(" %s", print_bar(10, charge_ratio)) + out = out sprintf(" %d%", charge_ratio * 100) + out = out sprintf(" %.2f%s", charge_now, charge_unit) + if (current_now != 0) { + out = out sprintf("/%.1f%s", current_now, current_unit) + } + out = out sprintf(" %d%s", energy_full, energy_unit) + if (power_now != 0) { + out = out sprintf("/%.1f%s", power_now, power_unit) + } + if (current_now != 0) { + out = out sprintf(" %s", print_hm(charge_now / current_now)) + } + + print out + } + ' + )} + + for uevent in /sys/class/power_supply/*/uevent; do + power_supply "$uevent" || : + done +'' diff --git a/tv/5pkgs/simple/q/default.nix b/tv/5pkgs/simple/q/default.nix index 7906b968f..e17282e17 100644 --- a/tv/5pkgs/simple/q/default.nix +++ b/tv/5pkgs/simple/q/default.nix @@ -102,131 +102,6 @@ let ' ''; - q-power_supply = let - power_supply = pkgs.writeBash "power_supply" '' - set -efu - uevent=$1 - eval "$(${pkgs.gnused}/bin/sed -n ' - s/^\([A-Z_]\+=[0-9A-Za-z_-]*\)$/export \1/p - ' $uevent)" - case $POWER_SUPPLY_NAME in - AC) - exit # not battery - ;; - esac - exec = .42) t_col = "1;32" - else if (r >= 23) t_col = "1;33" - else if (r >= 11) t_col = "1;31" - else t_col = "5;1;31" - return sgr(t_col) strdup("■", t1) sgr(";30") strdup("■", t2) sgr() - } - - function sgr(p) { - return "\x1b[" p "m" - } - - function strdup(s,n,t) { - t = sprintf("%"n"s","") - gsub(/ /,s,t) - return t - } - - END { - name = ENVIRON["POWER_SUPPLY_NAME"] - - charge_unit = "Ah" - charge_now = ENVIRON["POWER_SUPPLY_CHARGE_NOW"] / 10^6 - charge_full = ENVIRON["POWER_SUPPLY_CHARGE_FULL"] / 10^6 - - current_unit = "A" - current_now = ENVIRON["POWER_SUPPLY_CURRENT_NOW"] / 10^6 - - energy_unit = "Wh" - energy_now = ENVIRON["POWER_SUPPLY_ENERGY_NOW"] / 10^6 - energy_full = ENVIRON["POWER_SUPPLY_ENERGY_FULL"] / 10^6 - - power_unit = "W" - power_now = ENVIRON["POWER_SUPPLY_POWER_NOW"] / 10^6 - - voltage_unit = "V" - voltage_now = ENVIRON["POWER_SUPPLY_VOLTAGE_NOW"] / 10^6 - voltage_min_design = ENVIRON["POWER_SUPPLY_VOLTAGE_MIN_DESIGN"] / 10^6 - - #printf "charge_now: %s\n", charge_now - #printf "charge_full: %s\n", charge_full - #printf "current_now: %s\n", current_now - #printf "energy_now: %s\n", energy_now - #printf "energy_full: %s\n", energy_full - #printf "energy_full: %s\n", ENVIRON["POWER_SUPPLY_ENERGY_FULL"] - #printf "energy_full: %s\n", ENVIRON["POWER_SUPPLY_ENERGY_FULL"] / 10^6 - #printf "power_now: %s\n", power_now - #printf "voltage_now: %s\n", voltage_now - - if (current_now == 0 && voltage_now != 0) { - current_now = power_now / voltage_now - } - if (power_now == 0) { - power_now = current_now * voltage_now - } - if (charge_now == 0 && voltage_min_design != 0) { - charge_now = energy_now / voltage_min_design - } - if (energy_now == 0) { - energy_now = charge_now * voltage_min_design - } - if (charge_full == 0 && voltage_min_design != 0) { - charge_full = energy_full / voltage_min_design - } - if (energy_full == 0) { - energy_full = charge_full * voltage_min_design - } - - if (charge_now == 0 || charge_full == 0) { - die("unknown charge") - } - - charge_ratio = charge_now / charge_full - - out = out name - out = out sprintf(" %s", print_bar(10, charge_ratio)) - out = out sprintf(" %d%", charge_ratio * 100) - out = out sprintf(" %.2f%s", charge_now, charge_unit) - if (current_now != 0) { - out = out sprintf("/%.1f%s", current_now, current_unit) - } - out = out sprintf(" %d%s", energy_full, energy_unit) - if (power_now != 0) { - out = out sprintf("/%.1f%s", power_now, power_unit) - } - if (current_now != 0) { - out = out sprintf(" %s", print_hm(charge_now / current_now)) - } - - print out - } - ' - ''; - in '' - for uevent in /sys/class/power_supply/*/uevent; do - ${power_supply} "$uevent" || : - done - ''; - q-virtualization = /* sh */ '' echo "VT: $(${pkgs.systemd}/bin/systemd-detect-virt)" ''; @@ -302,7 +177,7 @@ pkgs.writeBashBin "q" '' ${q-sgtdate} (${q-gitdir}) & (${q-intel_backlight}) & - (${q-power_supply}) & + ${pkgs.q-power_supply}/bin/q-power_supply & (${q-virtualization}) & (${q-wireless}) & (${q-online}) & -- cgit v1.2.3 From 0ae1dc7b96f26dec1240b837f7bdd2bc633c6398 Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 2 Apr 2019 20:06:31 +0200 Subject: nix-writers: 3.3.0 -> 3.4.0 --- submodules/nix-writers | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/submodules/nix-writers b/submodules/nix-writers index d856f05da..c528cf970 160000 --- a/submodules/nix-writers +++ b/submodules/nix-writers @@ -1 +1 @@ -Subproject commit d856f05daff9cd726d1e798f1bb9a18eecbe2f50 +Subproject commit c528cf970e292790b414b4c1c8c8e9d7e73b2a71 -- cgit v1.2.3 From 966620d6c64bbb2a375e2dc30d8a70c636cd8864 Mon Sep 17 00:00:00 2001 From: makefu Date: Thu, 4 Apr 2019 09:11:33 +0200 Subject: ma pkgs.prison-break: init at 0.1.0 --- makefu/5pkgs/prison-break/default.nix | 20 ++++++++++++++++++++ makefu/5pkgs/prison-break/straight-plugin.nix | 22 ++++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 makefu/5pkgs/prison-break/default.nix create mode 100644 makefu/5pkgs/prison-break/straight-plugin.nix diff --git a/makefu/5pkgs/prison-break/default.nix b/makefu/5pkgs/prison-break/default.nix new file mode 100644 index 000000000..f86ac3762 --- /dev/null +++ b/makefu/5pkgs/prison-break/default.nix @@ -0,0 +1,20 @@ +{pkgs, fetchFromGitHub}: +with pkgs.python3.pkgs; + +buildPythonPackage rec { + pname = "prison-break"; + version = "0.1.0"; + src = fetchFromGitHub { + owner = "makefu"; + repo = pname; + rev = "5eed6371e151e716faafa054e005bd98d77b4b5d"; + sha256 = "170zs9grbgkx83ghg6pm13v7vhi604y44j550ypp2x26nidaw63j"; + }; + propagatedBuildInputs = [ + docopt + requests + beautifulsoup4 + (callPackage ./straight-plugin.nix {}) + ]; + checkInputs = [ black ]; +} diff --git a/makefu/5pkgs/prison-break/straight-plugin.nix b/makefu/5pkgs/prison-break/straight-plugin.nix new file mode 100644 index 000000000..606c60b5d --- /dev/null +++ b/makefu/5pkgs/prison-break/straight-plugin.nix @@ -0,0 +1,22 @@ +{ lib +, buildPythonPackage +, fetchPypi +}: + +buildPythonPackage rec { + pname = "straight-plugin"; + version = "1.5.0"; + + src = fetchPypi { + pname = "straight.plugin"; + inherit version; + sha256 = "818a7641068932ed6436d0af0a3bb77bbbde29df0a7142c8bd1a249e7c2f0d38"; + }; + + meta = with lib; { + description = "A simple namespaced plugin facility"; + homepage = https://github.com/ironfroggy/straight.plugin; + license = licenses.mit; + maintainers = [ maintainers.makefu ]; + }; +} -- cgit v1.2.3 From f7a22959ca67c1426149b61b518fec663d81d0c1 Mon Sep 17 00:00:00 2001 From: makefu Date: Thu, 4 Apr 2019 09:14:03 +0200 Subject: gitlab-ci: trigger NUR update --- .gitlab-ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1946f269e..6d2f15063 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -15,5 +15,6 @@ nur-packages makefu: - git filter-branch -f --prune-empty --subdirectory-filter makefu/5pkgs HEAD - git remote add deploy git@github.com:makefu/nur-packages.git || git remote set-url deploy git@github.com:makefu/nur-packages.git - git push --force deploy HEAD:master + - curl -XPOST http://nur-update.herokuapp.com/update?repo=makefu after_script: - rm -f deploy.key -- cgit v1.2.3 From bce8dd2348af3f15a6fe3c9cb91b5b7576c2bf99 Mon Sep 17 00:00:00 2001 From: makefu Date: Thu, 4 Apr 2019 09:18:10 +0200 Subject: ma editors/vim: try out languageClient --- makefu/2configs/editor/vim.nix | 1 + makefu/2configs/editor/vimrc | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/makefu/2configs/editor/vim.nix b/makefu/2configs/editor/vim.nix index d14a611b4..8a58e44de 100644 --- a/makefu/2configs/editor/vim.nix +++ b/makefu/2configs/editor/vim.nix @@ -23,6 +23,7 @@ in { vimrcConfig.vam.pluginDictionaries = [ { names = [ "undotree" # "YouCompleteMe" + "LanguageClient-neovim" "vim-better-whitespace" ]; } # vim-nix handles indentation better but does not perform sanity { names = [ "vim-addon-nix" ]; ft_regex = "^nix\$"; } diff --git a/makefu/2configs/editor/vimrc b/makefu/2configs/editor/vimrc index 8cdab55db..96c505ba8 100644 --- a/makefu/2configs/editor/vimrc +++ b/makefu/2configs/editor/vimrc @@ -96,3 +96,14 @@ augroup Binary au BufWritePost *.bin if &bin | %!xxd au BufWritePost *.bin set nomod | endif augroup END + +let g:LanguageClient_serverCommands = { +\ 'python': ['pyls'] +\ } +nnoremap :call LanguageClient_contextMenu() +nnoremap gh :call LanguageClient_textDocument_hover() +nnoremap gd :call LanguageClient_textDocument_definition() +nnoremap gr :call LanguageClient_textDocument_references() +nnoremap gs :call LanguageClient_textDocument_documentSymbol() +nnoremap :call LanguageClient_textDocument_rename() +nnoremap gf :call LanguageClient_textDocument_formatting() -- cgit v1.2.3 From df60cdea0a5beb2df8046bc85b8789862ee8c040 Mon Sep 17 00:00:00 2001 From: makefu Date: Thu, 4 Apr 2019 09:50:16 +0200 Subject: ma bureautomation: remove faulty motion detector --- .../bureautomation/automation/10h_timer.nix | 5 +- .../bureautomation/automation/bureau-shutdown.nix | 27 ++++----- .../bureautomation/automation/nachtlicht.nix | 4 +- .../bureautomation/device_tracker/openwrt.nix | 14 +++++ makefu/2configs/bureautomation/devices/users.nix | 17 ++++++ makefu/2configs/bureautomation/hass.nix | 65 ++++++++++++++++------ makefu/2configs/bureautomation/person/team.nix | 29 ++++++++++ makefu/2configs/bureautomation/switch/rfbridge.nix | 17 ++++++ .../bureautomation/switch/tasmota_switch.nix | 2 +- 9 files changed, 144 insertions(+), 36 deletions(-) create mode 100644 makefu/2configs/bureautomation/device_tracker/openwrt.nix create mode 100644 makefu/2configs/bureautomation/devices/users.nix create mode 100644 makefu/2configs/bureautomation/person/team.nix create mode 100644 makefu/2configs/bureautomation/switch/rfbridge.nix diff --git a/makefu/2configs/bureautomation/automation/10h_timer.nix b/makefu/2configs/bureautomation/automation/10h_timer.nix index a311d468c..d86b46179 100644 --- a/makefu/2configs/bureautomation/automation/10h_timer.nix +++ b/makefu/2configs/bureautomation/automation/10h_timer.nix @@ -2,8 +2,9 @@ { alias = "start Felix 10h"; trigger = { platform = "state"; - entity_id = "binary_sensor.redbutton"; - to = "on"; + entity_id = [ "device_tracker.felix_phone" "device_tracker.felix_laptop" ]; + from = "not_home"; + to = "home"; }; condition = { condition = "and"; diff --git a/makefu/2configs/bureautomation/automation/bureau-shutdown.nix b/makefu/2configs/bureautomation/automation/bureau-shutdown.nix index 9e6574300..1def5f3ad 100644 --- a/makefu/2configs/bureautomation/automation/bureau-shutdown.nix +++ b/makefu/2configs/bureautomation/automation/bureau-shutdown.nix @@ -1,9 +1,10 @@ [ - { alias = "Turn on Fernseher on movement"; + { alias = "Turn on Fernseher on group home"; trigger = { - platform = "state"; - entity_id = "binary_sensor.motion"; - to = "on"; + condition = "state"; + entity_id = "group.team"; + from = "not_home"; + to = "home"; }; action = { service = "homeassistant.turn_on"; @@ -13,15 +14,15 @@ ]; }; } - { alias = "Turn off Fernseher 10 minutes after last movement"; + { alias = "Turn off Fernseher after last in group left"; trigger = [ { # trigger when movement was detected at the time - platform = "state"; - entity_id = "binary_sensor.motion"; - to = "off"; - for.minutes = 10; + condition = "state"; + entity_id = "group.team"; + from = "home"; + to = "not_home"; } - { # trigger at 20:00 no matter what + { # trigger at 18:00 no matter what # to avoid 'everybody left before 18:00:00' platform = "time"; at = "18:00:00"; @@ -44,10 +45,10 @@ after = "18:00:00"; # weekday = [ "mon" "tue" "wed" "thu" "fri" ]; } - { + { # if anybody is still there condition = "state"; - entity_id = "binary_sensor.motion"; - state = "off"; + entity_id = "group.team"; + state = "not_home"; } ]; }; diff --git a/makefu/2configs/bureautomation/automation/nachtlicht.nix b/makefu/2configs/bureautomation/automation/nachtlicht.nix index 066e9b06c..2becd4a39 100644 --- a/makefu/2configs/bureautomation/automation/nachtlicht.nix +++ b/makefu/2configs/bureautomation/automation/nachtlicht.nix @@ -9,7 +9,7 @@ action = { service = "homeassistant.turn_off"; - entity_id = [ "switch.nachtlicht" ]; + entity_id = [ "group.nachtlicht" ]; }; } @@ -37,7 +37,7 @@ action = { service = "homeassistant.turn_on"; - entity_id = [ "switch.nachtlicht" ]; + entity_id = [ "group.nachtlicht" ]; }; } ] diff --git a/makefu/2configs/bureautomation/device_tracker/openwrt.nix b/makefu/2configs/bureautomation/device_tracker/openwrt.nix new file mode 100644 index 000000000..0db9821a1 --- /dev/null +++ b/makefu/2configs/bureautomation/device_tracker/openwrt.nix @@ -0,0 +1,14 @@ +[ + { platform = "luci"; + name = "router"; + host = "192.168.8.1"; + username = "root"; + password = import ; + interval_seconds = 30; # instead of 12seconds + consider_home = 300; # 5 minutes timeout + new_device_defaults = { + track_new_devices = true; + hide_if_away = false; + }; + } +] diff --git a/makefu/2configs/bureautomation/devices/users.nix b/makefu/2configs/bureautomation/devices/users.nix new file mode 100644 index 000000000..305c0ca86 --- /dev/null +++ b/makefu/2configs/bureautomation/devices/users.nix @@ -0,0 +1,17 @@ +{ + thorsten-phone = { + name = "Thorsten"; + mac = "8c:f5:a3:bc:83:a0"; + track = true; + hide_if_away = true; + }; + felix-laptop = { + name = "Felix"; + mac = "6c:88:14:b4:43:9c"; + track = true; + hide_if_away = true; + }; + # b0:e5:ed:52:ee:43 - honor8 + # 38:94:96:b0:13:c7 - android-4ef03e4f4a14b6b9 + # ac:5f:3e:cc:b8:5e - Galaxy S7 +} diff --git a/makefu/2configs/bureautomation/hass.nix b/makefu/2configs/bureautomation/hass.nix index 007d00b09..a104f0c44 100644 --- a/makefu/2configs/bureautomation/hass.nix +++ b/makefu/2configs/bureautomation/hass.nix @@ -1,8 +1,9 @@ { pkgs, lib, ... }: let + kodi-host = "192.168.8.11"; in { networking.firewall.allowedTCPPorts = [ 8123 ]; - + state = [ "/var/lib/hass/known_devices.yaml" ]; services.home-assistant = { enable = true; config = { @@ -33,7 +34,8 @@ in { retain = true; }; }; - switch = (import ./switch/tasmota_switch.nix); + switch = (import ./switch/tasmota_switch.nix) ++ + (import ./switch/rfbridge.nix); light = (import ./light/statuslight.nix) ++ (import ./light/buzzer.nix); timer = { @@ -54,7 +56,12 @@ in { { platform = "kodi"; name = "wbob"; - host = "192.168.8.11"; + host = kodi-host; + } + ]; + media_player = [ + { platform = "kodi"; + host = kodi-host; } ]; script = (import ./script/multi_blink.nix) {inherit lib;}; @@ -70,6 +77,10 @@ in { camera = (import ./camera/verkehrskamera.nix); + # not yet released + #person = + # (import ./person/team.nix ); + frontend = { }; http = { }; conversation = {}; @@ -82,36 +93,55 @@ in { { view = "yes"; entities = [ "group.sensors" + "group.camera" "group.outside" - "group.switches" - "group.automation" - # "group.camera" + "group.team" + "group.nachtlicht" + # "group.switches" ]; }; automation = [ - "timer.felix_10h" - "script.blitz_10s" - "script.buzz_red_led_fast" - "camera.Baumarkt" ]; switches = [ "switch.bauarbeiterlampe" "switch.blitzdings" "switch.fernseher" "switch.feuer" - "switch.nachtlicht" "light.status_felix" "light.status_daniel" "light.buslicht" "light.redbutton_buzzer" ]; - - camera = [ ]; + team = [ + "device_tracker.thorsten_phone" + "device_tracker.felix_phone" + "device_tracker.ecki_tablet" + "device_tracker.daniel_phone" + "device_tracker.carsten_phone" + # "person.thorsten" + # "person.felix" + # "person.ecki" + # "person.daniel" + ]; + camera = [ + "camera.Baumarkt" + "camera.Autobahn_Heilbronn" + "camera.Autobahn_Singen" + ]; + nachtlicht = [ + "switch.nachtlicht_a" + "switch.nachtlicht_b" + "switch.nachtlicht_c" + "switch.nachtlicht_d" + ]; sensors = [ - "binary_sensor.motion" - "binary_sensor.redbutton" + "media_player.kodi" + "script.blitz_10s" + "script.buzz_red_led_fast" + "timer.felix_10h" "sensor.easy2_dht22_humidity" "sensor.easy2_dht22_temperature" + # "binary_sensor.redbutton" ]; outside = [ # "sensor.ditzingen_pm10" @@ -120,8 +150,7 @@ in { "sensor.dark_sky_humidity" # "sensor.dark_sky_pressure" "sensor.dark_sky_hourly_summary" - "camera.Autobahn_Heilbronn" - "camera.Autobahn_Singen" + "device_tracker.router" ]; }; # only for automation @@ -131,7 +160,7 @@ in { automation = (import ./automation/bureau-shutdown.nix) ++ (import ./automation/nachtlicht.nix) ++ (import ./automation/10h_timer.nix); - + device_tracker = (import ./device_tracker/openwrt.nix ); }; }; } diff --git a/makefu/2configs/bureautomation/person/team.nix b/makefu/2configs/bureautomation/person/team.nix new file mode 100644 index 000000000..e18c42194 --- /dev/null +++ b/makefu/2configs/bureautomation/person/team.nix @@ -0,0 +1,29 @@ +[ + { name = "Thorsten"; + id = 1; + device_trackers = [ + "device_tracker.thorsten_phone" + "device_tracker.thorsten_arbeitphone" + ]; + } + { name = "Felix"; + id = 2; + device_trackers = [ + "device_tracker.felix_phone" + "device_tracker.felix_laptop" + ]; + } + { name = "Ecki"; + id = 3; + device_trackers = [ + "device_tracker.ecki_phone" + "device_tracker.ecki_tablet" + ]; + } + { name = "Daniel"; + id = 4; + device_trackers = [ + "device_tracker.daniel_phone" + ]; + } +] diff --git a/makefu/2configs/bureautomation/switch/rfbridge.nix b/makefu/2configs/bureautomation/switch/rfbridge.nix new file mode 100644 index 000000000..1336549a3 --- /dev/null +++ b/makefu/2configs/bureautomation/switch/rfbridge.nix @@ -0,0 +1,17 @@ +let + topic = "rfbridge"; + bridge = name: payload_on: payload_off: + { platform = "mqtt"; + inherit name payload_on payload_off; + command_topic = "/bam/${topic}/cmnd/rfcode"; + availability_topic = "/bam/${topic}/tele/LWT"; + payload_available= "Online"; + payload_not_available= "Offline"; + }; +in +[ + (bridge "Nachtlicht A" "#414551" "#414554") + (bridge "Nachtlicht B" "#415151" "#415154") + (bridge "Nachtlicht C" "#415451" "#415454") + (bridge "Nachtlicht D" "#41551F" "#415514") +] diff --git a/makefu/2configs/bureautomation/switch/tasmota_switch.nix b/makefu/2configs/bureautomation/switch/tasmota_switch.nix index b00a8e454..eb7b5fb80 100644 --- a/makefu/2configs/bureautomation/switch/tasmota_switch.nix +++ b/makefu/2configs/bureautomation/switch/tasmota_switch.nix @@ -15,5 +15,5 @@ in [ (tasmota_plug "Blitzdings" "plug2") (tasmota_plug "Fernseher" "plug3") (tasmota_plug "Feuer" "plug4") - (tasmota_plug "Nachtlicht" "plug5") + (tasmota_plug "Blaulicht" "plug5") ] -- cgit v1.2.3 From b162f79087cf0d02948a1cd76697e4958fd37e59 Mon Sep 17 00:00:00 2001 From: makefu Date: Thu, 4 Apr 2019 11:11:30 +0200 Subject: ma 0tests: add router secret --- makefu/0tests/data/secrets/hass/router.nix | 1 + 1 file changed, 1 insertion(+) create mode 100644 makefu/0tests/data/secrets/hass/router.nix diff --git a/makefu/0tests/data/secrets/hass/router.nix b/makefu/0tests/data/secrets/hass/router.nix new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/makefu/0tests/data/secrets/hass/router.nix @@ -0,0 +1 @@ + -- cgit v1.2.3 From 854bd37b06a4bddcf5d71e7c6a2264eaac66c928 Mon Sep 17 00:00:00 2001 From: makefu Date: Thu, 4 Apr 2019 15:37:35 +0200 Subject: ma pkgs.bento4: rip (upstreamed) init-host: put into configs to still be able to push to NUR --- makefu/2configs/tools/init-host/default.nix | 47 +++++++++++++++++++++++++++++ makefu/5pkgs/bento4/default.nix | 29 ------------------ makefu/5pkgs/default.nix | 2 +- makefu/5pkgs/init-host/default.nix | 47 ----------------------------- 4 files changed, 48 insertions(+), 77 deletions(-) create mode 100644 makefu/2configs/tools/init-host/default.nix delete mode 100644 makefu/5pkgs/bento4/default.nix delete mode 100644 makefu/5pkgs/init-host/default.nix diff --git a/makefu/2configs/tools/init-host/default.nix b/makefu/2configs/tools/init-host/default.nix new file mode 100644 index 000000000..d1d3f7195 --- /dev/null +++ b/makefu/2configs/tools/init-host/default.nix @@ -0,0 +1,47 @@ +{ pkgs }: +pkgs.writeDashBin "generate-secrets" '' + set -euf + HOSTNAME="''${1?must provide hostname}" + TMPDIR=$(${pkgs.coreutils}/bin/mktemp -d) + PASSWORD=$(${pkgs.pwgen}/bin/pwgen 25 1) + HASHED_PASSWORD=$(echo $PASSWORD | ${pkgs.hashPassword}/bin/hashPassword -s) > /dev/null + + ${pkgs.openssh}/bin/ssh-keygen -t ed25519 -f $TMPDIR/ssh.id_ed25519 -P "" -C "" >/dev/null + ${pkgs.openssl}/bin/openssl genrsa -out $TMPDIR/retiolum.rsa_key.priv 4096 2>/dev/null > /dev/null + ${pkgs.openssl}/bin/openssl rsa -in $TMPDIR/retiolum.rsa_key.priv -pubout -out $TMPDIR/retiolum.rsa_key.pub 2>/dev/null > /dev/null + cat < $TMPDIR/hashedPasswords.nix + { + root = "$HASHED_PASSWORD"; + } + EOF + + cd $TMPDIR + for x in *; do + ${pkgs.coreutils}/bin/cat $x | secrets insert -m $HOSTNAME/$x > /dev/null + done + echo $PASSWORD | secrets insert -m $HOSTNAME/root > /dev/null + + cat <; + ssh.pubkey = "$(cat $TMPDIR/ssh.id_ed25519.pub)"; + }; + EOF + + rm -rf $TMPDIR +'' + diff --git a/makefu/5pkgs/bento4/default.nix b/makefu/5pkgs/bento4/default.nix deleted file mode 100644 index 6f5f1deba..000000000 --- a/makefu/5pkgs/bento4/default.nix +++ /dev/null @@ -1,29 +0,0 @@ -{ stdenv, fetchFromGitHub -, cmake -}: -stdenv.mkDerivation rec { - name = "bento4-${version}"; - version = "1.5.1-624"; - - src = fetchFromGitHub { - owner = "axiomatic-systems"; - repo = "Bento4"; - rev = "v${version}"; - sha256 = "1cq6vhrq3n3lc1n454slbc66qdyqam2srxgdhfpyfxbq5c4y06nf"; - }; - - nativeBuildInputs = [ cmake ]; - installPhase = '' - mkdir -p $out/{lib,bin} - find -iname '*.so' -exec mv --target-directory="$out/lib" {} \; - find -maxdepth 1 -executable -type f -exec mv --target-directory="$out/bin" {} \; - ''; - - meta = with stdenv.lib; { - description = "Full-featured MP4 format and MPEG DASH library and tools"; - homepage = http://bento4.com; - license = licenses.gpl3; - maintainers = with maintainers; [ makefu ]; - platforms = with platforms; linux; - }; -} diff --git a/makefu/5pkgs/default.nix b/makefu/5pkgs/default.nix index 8ae41427c..1ae10459f 100644 --- a/makefu/5pkgs/default.nix +++ b/makefu/5pkgs/default.nix @@ -1,4 +1,4 @@ -self: super: +self: super: with super.lib; with builtins; let # This callPackage will try to detect obsolete overrides. callPackage = path: args: let diff --git a/makefu/5pkgs/init-host/default.nix b/makefu/5pkgs/init-host/default.nix deleted file mode 100644 index d1d3f7195..000000000 --- a/makefu/5pkgs/init-host/default.nix +++ /dev/null @@ -1,47 +0,0 @@ -{ pkgs }: -pkgs.writeDashBin "generate-secrets" '' - set -euf - HOSTNAME="''${1?must provide hostname}" - TMPDIR=$(${pkgs.coreutils}/bin/mktemp -d) - PASSWORD=$(${pkgs.pwgen}/bin/pwgen 25 1) - HASHED_PASSWORD=$(echo $PASSWORD | ${pkgs.hashPassword}/bin/hashPassword -s) > /dev/null - - ${pkgs.openssh}/bin/ssh-keygen -t ed25519 -f $TMPDIR/ssh.id_ed25519 -P "" -C "" >/dev/null - ${pkgs.openssl}/bin/openssl genrsa -out $TMPDIR/retiolum.rsa_key.priv 4096 2>/dev/null > /dev/null - ${pkgs.openssl}/bin/openssl rsa -in $TMPDIR/retiolum.rsa_key.priv -pubout -out $TMPDIR/retiolum.rsa_key.pub 2>/dev/null > /dev/null - cat < $TMPDIR/hashedPasswords.nix - { - root = "$HASHED_PASSWORD"; - } - EOF - - cd $TMPDIR - for x in *; do - ${pkgs.coreutils}/bin/cat $x | secrets insert -m $HOSTNAME/$x > /dev/null - done - echo $PASSWORD | secrets insert -m $HOSTNAME/root > /dev/null - - cat <; - ssh.pubkey = "$(cat $TMPDIR/ssh.id_ed25519.pub)"; - }; - EOF - - rm -rf $TMPDIR -'' - -- cgit v1.2.3 From f22610b839fb2c6535567d921a538f645439c65d Mon Sep 17 00:00:00 2001 From: makefu Date: Thu, 4 Apr 2019 15:48:19 +0200 Subject: ma pkgs.targetcli: rip --- makefu/5pkgs/targetcli/default.nix | 64 -------------------------------------- 1 file changed, 64 deletions(-) delete mode 100644 makefu/5pkgs/targetcli/default.nix diff --git a/makefu/5pkgs/targetcli/default.nix b/makefu/5pkgs/targetcli/default.nix deleted file mode 100644 index 927c34c5a..000000000 --- a/makefu/5pkgs/targetcli/default.nix +++ /dev/null @@ -1,64 +0,0 @@ -{ pkgs, fetchFromGitHub, ... }: -with pkgs.python2Packages; -let - version = "2.1"; - rtslib = buildPythonPackage rec { - pname = "rtslib"; - inherit version; - src = fetchFromGitHub { - owner = "datera"; - repo = "rtslib"; - rev = version; - sha256 = "1d58k9i4xigfqgycyismsqzkz65ssjdri2v9fg0wpica1klyyv22"; - }; - propagatedBuildInputs = [ ipaddr netifaces configobj ]; - }; - configshell = buildPythonPackage rec { - pname = "configshell"; - version = "1.6"; - src = fetchFromGitHub { - owner = "datera"; - repo = "configshell"; - rev = version; - sha256 = "14n7xbcaicsvwajv1aihz727dlkn6zfaqjbnn7mcpns83c2hms7y"; - }; - propagatedBuildInputs = [ pyparsing ]; - }; - - tcm-py = buildPythonPackage rec { - pname = "tcm-py"; - version = "0ac9091c1ff7a52d5435a4f4449e82637142e06e"; - src = fetchFromGitHub { - owner = "datera"; - repo = "lio-utils"; - rev = "0ac9091c1ff7a52d5435a4f4449e82637142e06e"; - sha256 = "0fc922kxvgr7rwg1y875vqvkipcrixmlafsp5g8mipmq90i8zcq0"; - } + "/tcm-py"; - propagatedBuildInputs = [ ]; - }; - - lio-py = buildPythonPackage rec { - pname = "lio-py"; - version = "0ac9091c1ff7a52d5435a4f4449e82637142e06e"; - src = fetchFromGitHub { - owner = "datera"; - repo = "lio-utils"; - rev = "0ac9091c1ff7a52d5435a4f4449e82637142e06e"; - sha256 = "0fc922kxvgr7rwg1y875vqvkipcrixmlafsp5g8mipmq90i8zcq0"; - } + "/lio-py"; - propagatedBuildInputs = [ ]; - }; - -in buildPythonApplication rec { - pname = "targetcli"; - inherit version; - - propagatedBuildInputs = [ rtslib configshell lio-py tcm-py ]; - - src = fetchFromGitHub { - owner = "datera"; - repo = "targetcli"; - rev = version; - sha256 = "10nax7761g93qzky01y3hra8i4s11cgyy9w5w6l8781lj21lgi3d"; - }; -} -- cgit v1.2.3 From 521ddfb835fe430c70312a16466086dcaaef6dc1 Mon Sep 17 00:00:00 2001 From: makefu Date: Thu, 4 Apr 2019 22:53:57 +0200 Subject: ma bureautomation: fix automation config --- makefu/2configs/bureautomation/automation/bureau-shutdown.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/makefu/2configs/bureautomation/automation/bureau-shutdown.nix b/makefu/2configs/bureautomation/automation/bureau-shutdown.nix index 1def5f3ad..28c65721e 100644 --- a/makefu/2configs/bureautomation/automation/bureau-shutdown.nix +++ b/makefu/2configs/bureautomation/automation/bureau-shutdown.nix @@ -1,7 +1,7 @@ [ { alias = "Turn on Fernseher on group home"; trigger = { - condition = "state"; + platform = "state"; entity_id = "group.team"; from = "not_home"; to = "home"; @@ -17,7 +17,7 @@ { alias = "Turn off Fernseher after last in group left"; trigger = [ { # trigger when movement was detected at the time - condition = "state"; + platform = "state"; entity_id = "group.team"; from = "home"; to = "not_home"; -- cgit v1.2.3 From 197064cdba91649fd2e94e57d4ba54a0a3ea4b85 Mon Sep 17 00:00:00 2001 From: makefu Date: Thu, 4 Apr 2019 22:54:18 +0200 Subject: ma bureautomation: show switches again --- makefu/2configs/bureautomation/hass.nix | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/makefu/2configs/bureautomation/hass.nix b/makefu/2configs/bureautomation/hass.nix index a104f0c44..f3a400acb 100644 --- a/makefu/2configs/bureautomation/hass.nix +++ b/makefu/2configs/bureautomation/hass.nix @@ -97,7 +97,7 @@ in { "group.outside" "group.team" "group.nachtlicht" - # "group.switches" + "group.switches" ]; }; automation = [ @@ -110,7 +110,6 @@ in { "light.status_felix" "light.status_daniel" "light.buslicht" - "light.redbutton_buzzer" ]; team = [ "device_tracker.thorsten_phone" -- cgit v1.2.3 From 5761d563f5db527fb0e82e226efa42d029d31d21 Mon Sep 17 00:00:00 2001 From: makefu Date: Thu, 4 Apr 2019 22:55:24 +0200 Subject: ma bureautomation: use tele/STATE instead of stat/POWER --- makefu/2configs/bureautomation/light/statuslight.nix | 19 ++++++++++--------- .../2configs/bureautomation/switch/tasmota_switch.nix | 5 ++++- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/makefu/2configs/bureautomation/light/statuslight.nix b/makefu/2configs/bureautomation/light/statuslight.nix index 3a9582f2f..0acab7281 100644 --- a/makefu/2configs/bureautomation/light/statuslight.nix +++ b/makefu/2configs/bureautomation/light/statuslight.nix @@ -8,20 +8,20 @@ let inherit name; retain = false; qos = 1; - optimistic = false; + #optimistic = true; # state - # TODO: currently broken, will not use the custom state topic - state_topic = "/bam/${topic}/stat/POWER"; command_topic = "/bam/${topic}/cmnd/POWER"; + state_topic = "/bam/${topic}/tele/STATE"; + value_template = "{{ value_json.POWER }}"; availability_topic = "/bam/${topic}/tele/LWT"; - payload_on= "ON"; - payload_off= "OFF"; + payload_on = "ON"; + payload_off = "OFF"; payload_available= "Online"; payload_not_available= "Offline"; # brightness - brightness_state_topic = "/bam/${topic}/stat/Dimmer"; + brightness_state_topic = "/bam/${topic}/tele/STATE"; + brightness_value_template = "{{value_json.Dimmer}}"; brightness_command_topic = "/bam/${topic}/cmnd/Dimmer"; - brightness_value_template = "{{ value_json.Dimmer }}"; brightness_scale = 100; # color rgb_state_topic = "/bam/${topic}/stat/Color"; @@ -29,10 +29,11 @@ let rgb_command_mode = "hex"; rgb_command_template = "{{ '%02x%02x%02x' | format(red, green, blue)}}"; # effects - effect_state_topic = "/bam/${topic}/stat/Scheme"; + effect_state_topic = "/bam/${topic}/tele/STATE"; + effects_value_template = "{{value_json.Scheme}}"; effect_command_topic = "/bam/${topic}/cmnd/Scheme"; effect_value_template = "{{ value_json.Scheme }}"; - effect_list = [ + effect_list = [ 0 # single color for LED light 1 # start wake up sequence (same as Wakeup) 2 # cycle up through colors using Speed option diff --git a/makefu/2configs/bureautomation/switch/tasmota_switch.nix b/makefu/2configs/bureautomation/switch/tasmota_switch.nix index eb7b5fb80..115bae0cc 100644 --- a/makefu/2configs/bureautomation/switch/tasmota_switch.nix +++ b/makefu/2configs/bureautomation/switch/tasmota_switch.nix @@ -2,13 +2,16 @@ let tasmota_plug = name: topic: { platform = "mqtt"; inherit name; - state_topic = "/bam/${topic}/stat/POWER"; + state_topic = "/bam/${topic}/tele/STATE"; + value_template = "{{ value_json.POWER }}"; command_topic = "/bam/${topic}/cmnd/POWER"; availability_topic = "/bam/${topic}/tele/LWT"; payload_on= "ON"; payload_off= "OFF"; payload_available= "Online"; payload_not_available= "Offline"; + retain = false; + qos = 1; }; in [ (tasmota_plug "Bauarbeiterlampe" "plug") -- cgit v1.2.3 From 8172c6074419d9148fcab7b798e87f3168930bd7 Mon Sep 17 00:00:00 2001 From: makefu Date: Fri, 5 Apr 2019 01:44:29 +0200 Subject: bureautomation: enable telegram bot --- .../bureautomation/automation/10h_timer.nix | 8 ++++++- .../bureautomation/automation/bureau-shutdown.nix | 26 +++++++++++++++------- makefu/2configs/bureautomation/hass.nix | 13 ++++++++++- 3 files changed, 37 insertions(+), 10 deletions(-) diff --git a/makefu/2configs/bureautomation/automation/10h_timer.nix b/makefu/2configs/bureautomation/automation/10h_timer.nix index d86b46179..dd747114e 100644 --- a/makefu/2configs/bureautomation/automation/10h_timer.nix +++ b/makefu/2configs/bureautomation/automation/10h_timer.nix @@ -128,7 +128,13 @@ }; action = [ - # TODO: Pushbullet + { + service = "notify.telegrambot"; + data = { + title = "Zu lange Felix!"; + message = "Du bist schon 10 Stunden auf Arbeit, geh jetzt gefälligst nach Hause!"; + }; + } { service = "homeassistant.turn_on"; entity_id = [ diff --git a/makefu/2configs/bureautomation/automation/bureau-shutdown.nix b/makefu/2configs/bureautomation/automation/bureau-shutdown.nix index 28c65721e..c632a9e69 100644 --- a/makefu/2configs/bureautomation/automation/bureau-shutdown.nix +++ b/makefu/2configs/bureautomation/automation/bureau-shutdown.nix @@ -28,14 +28,24 @@ at = "18:00:00"; } ]; - action = { - service = "homeassistant.turn_off"; - entity_id = [ - "switch.fernseher" - "switch.feuer" - "light.status_felix" - ]; - }; + action = [ + { + service = "homeassistant.turn_off"; + entity_id = [ + "switch.fernseher" + "switch.feuer" + "light.status_felix" + "light.status_daniel" + ]; + } + { + service = "notify.telegrambot"; + data = { + title = "Bureau Shutdown"; + message = "All devices are turned off due to {{ trigger.platform }} - {{ trigger }}"; + }; + } + ]; condition = { condition = "and"; conditions = [ diff --git a/makefu/2configs/bureautomation/hass.nix b/makefu/2configs/bureautomation/hass.nix index f3a400acb..4e5fe7b63 100644 --- a/makefu/2configs/bureautomation/hass.nix +++ b/makefu/2configs/bureautomation/hass.nix @@ -55,9 +55,16 @@ in { notify = [ { platform = "kodi"; - name = "wbob"; + name = "wbob-kodi"; host = kodi-host; } + { + platform = "telegram"; + name = "telegrambot"; + chat_id = builtins.elemAt + (builtins.fromJSON (builtins.readFile + )).allowed_chat_ids 0; + } ]; media_player = [ { platform = "kodi"; @@ -88,6 +95,10 @@ in { logbook = {}; tts = [ { platform = "google";} ]; recorder = {}; + telegram_bot = [ + (builtins.fromJSON + (builtins.readFile )) + ]; group = { default_view = { view = "yes"; -- cgit v1.2.3 From cec7e3124d2ef99f7acf42337ac3c53469c620cf Mon Sep 17 00:00:00 2001 From: makefu Date: Fri, 5 Apr 2019 01:47:01 +0200 Subject: ma 0secrets: add telegram-bot.json --- makefu/0tests/data/secrets/hass/telegram-bot.json | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 makefu/0tests/data/secrets/hass/telegram-bot.json diff --git a/makefu/0tests/data/secrets/hass/telegram-bot.json b/makefu/0tests/data/secrets/hass/telegram-bot.json new file mode 100644 index 000000000..442177930 --- /dev/null +++ b/makefu/0tests/data/secrets/hass/telegram-bot.json @@ -0,0 +1,5 @@ +{ + "platform": "polling", + "api_key": "1:A", + "allowed_chat_ids": [ 0 1 ] +} -- cgit v1.2.3 From 8d3c776baf3b2e35a4cd76c9d33cdecda7122b7f Mon Sep 17 00:00:00 2001 From: makefu Date: Fri, 5 Apr 2019 02:02:08 +0200 Subject: ma tools: enable init-host, rambox --- makefu/2configs/tools/all.nix | 1 + makefu/2configs/tools/core-gui.nix | 2 +- makefu/2configs/tools/dev.nix | 13 +++++++++---- makefu/2configs/tools/extra-gui.nix | 1 + makefu/2configs/tools/pcmanfm-extra.nix | 11 +++++++++++ 5 files changed, 23 insertions(+), 5 deletions(-) create mode 100644 makefu/2configs/tools/pcmanfm-extra.nix diff --git a/makefu/2configs/tools/all.nix b/makefu/2configs/tools/all.nix index b6554e040..6844fdfe4 100644 --- a/makefu/2configs/tools/all.nix +++ b/makefu/2configs/tools/all.nix @@ -10,6 +10,7 @@ ./games.nix ./media.nix ./mobility.nix + ./pcmanfm-extra.nix ./scanner-tools.nix ./sec.nix ./sec-gui.nix diff --git a/makefu/2configs/tools/core-gui.nix b/makefu/2configs/tools/core-gui.nix index 582d941a6..41bfef270 100644 --- a/makefu/2configs/tools/core-gui.nix +++ b/makefu/2configs/tools/core-gui.nix @@ -6,7 +6,7 @@ chromium feh clipit - firefox + # firefox keepassx pcmanfm evince diff --git a/makefu/2configs/tools/dev.nix b/makefu/2configs/tools/dev.nix index fe25bd49a..23da9d577 100644 --- a/makefu/2configs/tools/dev.nix +++ b/makefu/2configs/tools/dev.nix @@ -2,10 +2,15 @@ { users.users.makefu.packages = with pkgs;[ - python3 - python3Packages.pyserial + (python3.withPackages(ps: [ + ps.python-language-server + # the following plugins are optional, they provide type checking, import sorting and code formatting + ps.pyls-mypy ps.pyls-isort ps.pyls-black + ps.virtualenv + ])) picocom - python3Packages.virtualenv + python3.pkgs.pyserial + python3.pkgs.virtualenv # embedded gi flashrom @@ -26,6 +31,6 @@ nix-review # git-related tig - init-host + (pkgs.callPackage ./init-host {}) ]; } diff --git a/makefu/2configs/tools/extra-gui.nix b/makefu/2configs/tools/extra-gui.nix index 3d26cc574..dfb4183df 100644 --- a/makefu/2configs/tools/extra-gui.nix +++ b/makefu/2configs/tools/extra-gui.nix @@ -14,5 +14,6 @@ saleae-logic gitAndTools.gitFull signal-desktop + rambox ]; } diff --git a/makefu/2configs/tools/pcmanfm-extra.nix b/makefu/2configs/tools/pcmanfm-extra.nix new file mode 100644 index 000000000..2d5d20f80 --- /dev/null +++ b/makefu/2configs/tools/pcmanfm-extra.nix @@ -0,0 +1,11 @@ +{ pkgs, ... }: +{ + users.users.makefu.packages = with pkgs; [ + pcmanfm + lxqt.lxqt-policykit + shared_mime_info + lxmenu-data + ]; + environment.variables.GIO_EXTRA_MODULES = [ "${pkgs.gvfs}/lib/gio/modules" ]; + services.gnome3.gvfs.enable = true; +} -- cgit v1.2.3 From 8f285e407d560dd243b082d756f682fd15379cf4 Mon Sep 17 00:00:00 2001 From: makefu Date: Fri, 5 Apr 2019 02:03:39 +0200 Subject: ma 0tests: fix router.nix --- makefu/0tests/data/secrets/hass/router.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/makefu/0tests/data/secrets/hass/router.nix b/makefu/0tests/data/secrets/hass/router.nix index 8b1378917..e16c76dff 100644 --- a/makefu/0tests/data/secrets/hass/router.nix +++ b/makefu/0tests/data/secrets/hass/router.nix @@ -1 +1 @@ - +"" -- cgit v1.2.3 From 2f53271af0fda00bdc452c2bc5e569f064f562f6 Mon Sep 17 00:00:00 2001 From: makefu Date: Fri, 5 Apr 2019 07:50:57 +0200 Subject: ma 0tests: fix telegram-bot json file --- makefu/0tests/data/secrets/hass/telegram-bot.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/makefu/0tests/data/secrets/hass/telegram-bot.json b/makefu/0tests/data/secrets/hass/telegram-bot.json index 442177930..1e1857df9 100644 --- a/makefu/0tests/data/secrets/hass/telegram-bot.json +++ b/makefu/0tests/data/secrets/hass/telegram-bot.json @@ -1,5 +1,5 @@ { "platform": "polling", "api_key": "1:A", - "allowed_chat_ids": [ 0 1 ] + "allowed_chat_ids": [ 0, 1 ] } -- cgit v1.2.3 From bd539533789a85a1786ae6f997a76d16d453b7f4 Mon Sep 17 00:00:00 2001 From: lassulus Date: Tue, 26 Mar 2019 14:39:52 +0100 Subject: l blue: use file nixpkgs deployment when not testing --- lass/1systems/blue/source.nix | 17 ++++------------- lass/krops.nix | 5 ++--- 2 files changed, 6 insertions(+), 16 deletions(-) diff --git a/lass/1systems/blue/source.nix b/lass/1systems/blue/source.nix index a52771a4d..8f748ab8f 100644 --- a/lass/1systems/blue/source.nix +++ b/lass/1systems/blue/source.nix @@ -1,20 +1,11 @@ { lib, pkgs, ... }: { nixpkgs = lib.mkForce { - derivation = let + file = toString (pkgs.fetchFromGitHub { + owner = "nixos"; + repo = "nixpkgs"; rev = (lib.importJSON ../../../krebs/nixpkgs.json).rev; sha256 = (lib.importJSON ../../../krebs/nixpkgs.json).sha256; - in '' - with import (builtins.fetchTarball { - url = "https://github.com/nixos/nixpkgs/archive/${rev}.tar.gz"; - sha256 = "${sha256}"; - }) {}; - pkgs.fetchFromGitHub { - owner = "nixos"; - repo = "nixpkgs"; - rev = "${rev}"; - sha256 = "${sha256}"; - } - ''; + }); }; } diff --git a/lass/krops.nix b/lass/krops.nix index d64454ea5..12652216a 100644 --- a/lass/krops.nix +++ b/lass/krops.nix @@ -11,7 +11,7 @@ {} ; - source = { test }: lib.evalSource [ + source = { test }: lib.evalSource ([ (krebs-source { test = test; }) { nixos-config.symlink = "stockholm/lass/1systems/${name}/physical.nix"; @@ -24,8 +24,7 @@ }; }; } - host-source - ]; + ] ++ (lib.optional (! test) host-source)); in { -- cgit v1.2.3 From 2b748822b18a41b6ff9beb6bafeb9753eebb2e56 Mon Sep 17 00:00:00 2001 From: lassulus Date: Sun, 7 Apr 2019 17:47:31 +0200 Subject: nixpkgs: 8abca4b -> 2229509 --- krebs/nixpkgs.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/krebs/nixpkgs.json b/krebs/nixpkgs.json index 28c98ceb2..1ee21020b 100644 --- a/krebs/nixpkgs.json +++ b/krebs/nixpkgs.json @@ -1,7 +1,7 @@ { "url": "https://github.com/NixOS/nixpkgs-channels", - "rev": "8abca4bc7b8b313c6e3073d074d623d1095c0dba", - "date": "2019-03-07T09:54:51+01:00", - "sha256": "1qhhlqkwzxwhq8ga4n7p4zg4nrhl79m6x4qd0pgaic6n4z5m82gr", + "rev": "222950952f15f6b1e9f036b80440b597f23e652d", + "date": "2019-04-05T10:07:50+02:00", + "sha256": "1hfchhy8vlc333sglabk1glkcnv4mrnarm9j4havqn7g5ri68vrd", "fetchSubmodules": false } -- cgit v1.2.3 From 1c014eb05c0022906629ee7fb9189cf6764ddc2f Mon Sep 17 00:00:00 2001 From: lassulus Date: Sun, 7 Apr 2019 18:08:54 +0200 Subject: l prism.r: add syncthing.id --- krebs/3modules/lass/default.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/krebs/3modules/lass/default.nix b/krebs/3modules/lass/default.nix index 7352d36e9..0b5eb93ce 100644 --- a/krebs/3modules/lass/default.nix +++ b/krebs/3modules/lass/default.nix @@ -106,6 +106,7 @@ in { }; ssh.privkey.path = ; ssh.pubkey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIAsANFdMi825qWQXQbWLYuNZ6/fARt3lnh1KStQHQQMD"; + syncthing.id = "QITFKYQ-VEPIPL2-AZIXHMD-BBT62ML-YHSB35A-BSUIBXS-QYMPFHW-M7XN2QU"; }; archprism = { cores = 1; -- cgit v1.2.3 From a8c958821dcc9912dddb6727a4ad74a4dbcbe02f Mon Sep 17 00:00:00 2001 From: lassulus Date: Sun, 7 Apr 2019 18:10:02 +0200 Subject: l skynet.r: add wiregrill --- krebs/3modules/lass/default.nix | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/krebs/3modules/lass/default.nix b/krebs/3modules/lass/default.nix index 0b5eb93ce..9c18f8a73 100644 --- a/krebs/3modules/lass/default.nix +++ b/krebs/3modules/lass/default.nix @@ -327,6 +327,13 @@ in { -----END RSA PUBLIC KEY----- ''; }; + wiregrill = { + ip6.addr = w6 "5ce7"; + aliases = [ + "skynet.w" + ]; + wireguard.pubkey = "pt9a6nP+YPqxnSskcM9NqRmAmFzbO5bE7wzViFFonnU="; + }; }; secure = true; ssh.privkey.path = ; -- cgit v1.2.3 From e56e7fbe7103f4c570bf8e4cdee764b9ad0b5062 Mon Sep 17 00:00:00 2001 From: lassulus Date: Sun, 7 Apr 2019 18:19:05 +0200 Subject: l phone.w: rotate all keys --- krebs/3modules/lass/default.nix | 4 ++-- krebs/3modules/lass/ssh/android.rsa | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/krebs/3modules/lass/default.nix b/krebs/3modules/lass/default.nix index 9c18f8a73..146d7a441 100644 --- a/krebs/3modules/lass/default.nix +++ b/krebs/3modules/lass/default.nix @@ -502,12 +502,12 @@ in { aliases = [ "phone.w" ]; - wireguard.pubkey = "zVunBVOxsMETlnHkgjfH71HaZjjNUOeYNveAVv5z3jw="; + wireguard.pubkey = "MRicxap2VxPnzmXoOqqjQNGWJ54cQC8Tfy28+IXXsxM="; }; }; external = true; ci = false; - syncthing.id = "V6D4CKT-7POOIKX-KB6UM7R-3R774RB-DSZ26FE-MSW3VTO-6AIJCIA-ZHJXKA7"; + syncthing.id = "DUFMX7V-HNR6WXM-LZB5LJE-TM6QIOH-MTGHEUJ-QSD3XIY-YRFJLOR-G6Y3XQB"; }; morpheus = { cores = 1; diff --git a/krebs/3modules/lass/ssh/android.rsa b/krebs/3modules/lass/ssh/android.rsa index 3d35b76e4..675ba8df2 100644 --- a/krebs/3modules/lass/ssh/android.rsa +++ b/krebs/3modules/lass/ssh/android.rsa @@ -1 +1 @@ -ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOPH4c2zQCaCmus4T9GvaY1lrgVR9CKV3Fx1vRn1K1XB u0_a194@android +ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIPF7RHU4q6w1f3xWcfeAD6u23jDs2fd/H3IuxdT5G1ZL -- cgit v1.2.3 From 212e7f4b9843790e29fd990a17279dc96e181baf Mon Sep 17 00:00:00 2001 From: lassulus Date: Sun, 7 Apr 2019 18:21:18 +0200 Subject: syncthing: add id option --- krebs/3modules/syncthing.nix | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/krebs/3modules/syncthing.nix b/krebs/3modules/syncthing.nix index 3c60eec4b..34879fd3f 100644 --- a/krebs/3modules/syncthing.nix +++ b/krebs/3modules/syncthing.nix @@ -11,8 +11,7 @@ let }) cfg.peers; folders = map (folder: { - inherit (folder) path type; - id = folder.path; + inherit (folder) path id type; devices = map (peer: { deviceId = cfg.peers.${peer}.id; }) folder.peers; rescanIntervalS = folder.rescanInterval; fsWatcherEnabled = folder.watch; @@ -83,13 +82,18 @@ in folders = mkOption { default = []; - type = types.listOf (types.submodule ({ + type = types.listOf (types.submodule ({ config, ... }: { options = { path = mkOption { type = types.absolute-pathname; }; + id = mkOption { + type = types.str; + default = config.path; + }; + peers = mkOption { type = types.listOf types.str; default = []; -- cgit v1.2.3 From 853e6b6d2610a9c49bf24c1c29ab59fddad64382 Mon Sep 17 00:00:00 2001 From: lassulus Date: Sun, 7 Apr 2019 19:26:45 +0200 Subject: l: add ensure-permissions module --- lass/3modules/default.nix | 1 + lass/3modules/ensure-permissions.nix | 66 ++++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+) create mode 100644 lass/3modules/ensure-permissions.nix diff --git a/lass/3modules/default.nix b/lass/3modules/default.nix index 613c7c8ac..59043aeb1 100644 --- a/lass/3modules/default.nix +++ b/lass/3modules/default.nix @@ -3,6 +3,7 @@ _: imports = [ ./dnsmasq.nix ./ejabberd + ./ensure-permissions.nix ./folderPerms.nix ./hosts.nix ./mysql-backup.nix diff --git a/lass/3modules/ensure-permissions.nix b/lass/3modules/ensure-permissions.nix new file mode 100644 index 000000000..36edc1127 --- /dev/null +++ b/lass/3modules/ensure-permissions.nix @@ -0,0 +1,66 @@ +{ config, pkgs, ... }: with import ; + +let + + cfg = config.lass.ensure-permissions; + +in + +{ + options.lass.ensure-permissions = mkOption { + default = []; + type = types.listOf (types.submodule ({ + options = { + + folder = mkOption { + type = types.absolute-pathname; + }; + + owner = mkOption { + # TODO user type + type = types.str; + default = "root"; + }; + + group = mkOption { + # TODO group type + type = types.str; + default = "root"; + }; + + permission = mkOption { + # TODO permission type + type = types.str; + default = "u+rw,g+rw"; + }; + + }; + })); + }; + + config = mkIf (cfg != []) { + + system.activationScripts.ensure-permissions = concatMapStringsSep "\n" (plan: '' + ${pkgs.coreutils}/bin/mkdir -p ${plan.folder} + ${pkgs.coreutils}/bin/chmod -R ${plan.permission} ${plan.folder} + ${pkgs.coreutils}/bin/chown -R ${plan.owner}:${plan.group} ${plan.folder} + '') cfg; + systemd.services = + listToAttrs (map (plan: nameValuePair "ensure-permisson.${replaceStrings ["/"] ["_"] plan.folder}" { + wantedBy = [ "multi-user.target" ]; + serviceConfig = { + Restart = "always"; + RestartSec = 10; + ExecStart = pkgs.writeDash "ensure-perms" '' + ${pkgs.inotifyTools}/bin/inotifywait -mrq -e CREATE --format %w%f ${plan.folder} \ + | while IFS= read -r FILE; do + ${pkgs.coreutils}/bin/chmod -R ${plan.permission} "$FILE" 2>/dev/null + ${pkgs.coreutils}/bin/chown -R ${plan.owner}:${plan.group} "$FILE" 2>/dev/null + done + ''; + }; + }) cfg) + ; + + }; +} -- cgit v1.2.3 From 797dd8cc2ac3b67ec385e0350db1c3c77012486f Mon Sep 17 00:00:00 2001 From: lassulus Date: Sun, 7 Apr 2019 18:44:57 +0200 Subject: l: sync more with syncthing --- lass/1systems/blue/config.nix | 7 +++++++ lass/1systems/mors/config.nix | 10 ++++++++++ lass/2configs/syncthing.nix | 11 ++++++++++- 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/lass/1systems/blue/config.nix b/lass/1systems/blue/config.nix index d740403da..da555a860 100644 --- a/lass/1systems/blue/config.nix +++ b/lass/1systems/blue/config.nix @@ -13,6 +13,13 @@ with import ; krebs.build.host = config.krebs.hosts.blue; + krebs.syncthing.folders = [ + { id = "contacts"; path = "/home/lass/contacts"; peers = [ "mors" "blue" "green" "phone" ]; } + ]; + lass.ensure-permissions = [ + { folder = "/home/lass/contacts"; owner = "lass"; group = "syncthing"; } + ]; + environment.shellAliases = { deploy = pkgs.writeDash "deploy" '' set -eu diff --git a/lass/1systems/mors/config.nix b/lass/1systems/mors/config.nix index f35ebff56..250d96e53 100644 --- a/lass/1systems/mors/config.nix +++ b/lass/1systems/mors/config.nix @@ -48,6 +48,16 @@ with import ; { predicate = "-p udp --dport 27950:27965"; target = "ACCEPT"; } ]; } + { + krebs.syncthing.folders = [ + { id = "contacts"; path = "/home/lass/contacts"; peers = [ "mors" "blue" "green" "phone" ]; } + { id = "the_playlist"; path = "/home/lass/tmp/the_playlist"; peers = [ "mors" "phone" ]; } + ]; + lass.ensure-permissions = [ + { folder = "/home/lass/contacts"; owner = "lass"; group = "syncthing"; } + { folder = "/home/lass/tmp/the_playlist"; owner = "lass"; group = "syncthing"; } + ]; + } { lass.umts = { enable = true; diff --git a/lass/2configs/syncthing.nix b/lass/2configs/syncthing.nix index 164e89679..842abc195 100644 --- a/lass/2configs/syncthing.nix +++ b/lass/2configs/syncthing.nix @@ -3,6 +3,7 @@ with import ; { services.syncthing = { enable = true; + group = "syncthing"; }; krebs.iptables.tables.filter.INPUT.rules = [ { predicate = "-p tcp --dport 22000"; target = "ACCEPT";} @@ -14,7 +15,15 @@ with import ; key = toString ; peers = mapAttrs (n: v: { id = v.syncthing.id; }) (filterAttrs (n: v: v.syncthing.id != null) config.krebs.hosts); folders = [ - { path = "/tmp/testsync"; peers = [ "icarus" "mors" "skynet" ]; } + { path = "/home/lass/sync"; peers = [ "icarus" "mors" "skynet" "blue" "green" "littleT" "prism"]; } ]; }; + + system.activationScripts.syncthing-home = '' + ${pkgs.coreutils}/bin/chmod a+x /home/lass + ''; + + lass.ensure-permissions = [ + { folder = "/home/lass/sync"; owner = "lass"; group = "syncthing"; } + ]; } -- cgit v1.2.3 From 44a48a8d3a4ce4732545a96828bf41ab6cf283da Mon Sep 17 00:00:00 2001 From: lassulus Date: Sun, 7 Apr 2019 19:35:34 +0200 Subject: l: add green.r --- krebs/3modules/lass/default.nix | 40 ++++++++++++++++++++++++++++++++++++++++ lass/1systems/green/config.nix | 28 ++++++++++++++++++++++++++++ lass/1systems/green/physical.nix | 8 ++++++++ lass/1systems/green/source.nix | 14 ++++++++++++++ 4 files changed, 90 insertions(+) create mode 100644 lass/1systems/green/config.nix create mode 100644 lass/1systems/green/physical.nix create mode 100644 lass/1systems/green/source.nix diff --git a/krebs/3modules/lass/default.nix b/krebs/3modules/lass/default.nix index 146d7a441..a3b8cab39 100644 --- a/krebs/3modules/lass/default.nix +++ b/krebs/3modules/lass/default.nix @@ -495,6 +495,46 @@ in { ssh.pubkey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILSBxtPf8yJfzzI7/iYpoRSc/TT+zYmE/HM9XWS3MZlv"; syncthing.id = "J2LMIPD-PBEPVKL-A3MN6NQ-KL6DZ4N-K4GGWZB-E2EPLFN-PDLVAOC-DCSZHAD"; }; + + green = { + cores = 1; + nets = { + retiolum = { + ip4.addr = "10.243.0.66"; + ip6.addr = r6 "12ee"; + aliases = [ + "green.r" + ]; + tinc.pubkey = '' + -----BEGIN PUBLIC KEY----- + MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAwpgFxMxWQ0Cp3I82bLWk + uoDBjWqhM9Pgq6PJSpJjyNAgMkKJcQnWi0WpELaHISAVqjdPGUQSLiar++JN3YBx + ZQGFiucG0ijVJKAUbQQDYbc+RGK8MGO2v3Bv/6E56UKjxtT1zjjvkyXpSC7FN477 + n9IfsvIzH/RLcAP5VnHBYqZ467UR4rqi7T7yWjrEgr+VirY9Opp9LM9YozlbRrlI + hYshk5RET/EvOSwYlw/KJEMMmYHro74neZKIVKoXD3CSE66rncNmdFwD3ZXVxYn6 + m3Eob8ojWPW+CpAL2AurUyq4Igem9JVigZiyKGgaYsdkOWgkYLW2M0DXX+vCRcM6 + BvJgJn7s0PHkLvybEVveTolRWO+I/IG1LN8m0SvrVPXf5JYHB32nKYwVMLwi+BQ1 + pwo0USGByVRv2lWZfy3doKxow0ppilq4DwoT+iqVO4sK5YhPipBHSmCcaxlquHjy + 2k1eb0gYisp0LBjHlhTErXtt4RlrUqs/84RfgtIZYUowJfXbtEbyDmLIlESbY7qk + UlXIMXtY0sWpDivWwpdMj9kJdKlS09QTMeLYz4fFGXMksFmLijx8RKDOYfNWL7oA + udmEOHPzYzu/Ex8RfKJjD4GhWLDvDTcyXDG9vmuDNZGcPHANeg23sGhr5Hz37FRT + 3MVh92sFyMVYkJcL7SISk80CAwEAAQ== + -----END PUBLIC KEY----- + ''; + }; + wiregrill = { + ip6.addr = w6 "12ee"; + aliases = [ + "green.w" + ]; + wireguard.pubkey = "lOORkStNJ6iP5ffqjHa/kWOxilJIMW4E6BEtNvNhLGk="; + }; + }; + ssh.privkey.path = ; + ssh.pubkey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIH0wqzo7rMkyw6gqTGuUp8aUA0vtwj0HuuaTIkkOnA30 "; + syncthing.id = "CADHN7J-CWRCWTZ-3GZRLII-JBVZN4N-RGHDGDL-UTAJNYI-RZPHK55-7EYAWQM"; + }; + phone = { nets = { wiregrill = { diff --git a/lass/1systems/green/config.nix b/lass/1systems/green/config.nix new file mode 100644 index 000000000..6ae157e38 --- /dev/null +++ b/lass/1systems/green/config.nix @@ -0,0 +1,28 @@ +with import ; +{ config, lib, pkgs, ... }: +{ + imports = [ + + + + + + + # + + ]; + + krebs.build.host = config.krebs.hosts.green; + + krebs.syncthing.folders = [ + { id = "contacts"; path = "/home/lass/contacts"; peers = [ "mors" "blue" "green" "phone" ]; } + ]; + lass.ensure-permissions = [ + { folder = "/home/lass/contacts"; owner = "lass"; group = "syncthing"; } + ]; + + + #networking.nameservers = [ "1.1.1.1" ]; + + #time.timeZone = "Europe/Berlin"; +} diff --git a/lass/1systems/green/physical.nix b/lass/1systems/green/physical.nix new file mode 100644 index 000000000..7499ff723 --- /dev/null +++ b/lass/1systems/green/physical.nix @@ -0,0 +1,8 @@ +{ + imports = [ + ./config.nix + ]; + boot.isContainer = true; + networking.useDHCP = false; + environment.variables.NIX_REMOTE = "daemon"; +} diff --git a/lass/1systems/green/source.nix b/lass/1systems/green/source.nix new file mode 100644 index 000000000..21f3a8bd5 --- /dev/null +++ b/lass/1systems/green/source.nix @@ -0,0 +1,14 @@ +{ lib, pkgs, ... }: +{ + nixpkgs = lib.mkForce { + file = { + path = toString (pkgs.fetchFromGitHub { + owner = "nixos"; + repo = "nixpkgs"; + rev = (lib.importJSON ../../../krebs/nixpkgs.json).rev; + sha256 = (lib.importJSON ../../../krebs/nixpkgs.json).sha256; + }); + useChecksum = true; + }; + }; +} -- cgit v1.2.3 From 4769b3186597117daec579ac71df79e2fafabcf5 Mon Sep 17 00:00:00 2001 From: lassulus Date: