Merge remote-tracking branch 'lass/master'

This commit is contained in:
makefu 2020-05-21 08:38:16 +02:00
commit d027d1d531
No known key found for this signature in database
GPG Key ID: 36F7711F3FC0F225
27 changed files with 352 additions and 110 deletions

View File

@ -2,20 +2,11 @@
let
# Firefox addons
https-everywhere = pkgs.callPackage ./own-pkgs/https-everywhere {};
ublock-origin = pkgs.callPackage ./own-pkgs/ublock-origin {};
webgl-fingerprint-defender = pkgs.callPackage ./own-pkgs/webgl-fingerprint-defender {};
canvas-fingerprint-defender = pkgs.callPackage ./own-pkgs/canvas-fingerprint-defender {};
audio-fingerprint-defender = pkgs.callPackage ./own-pkgs/audio-fingerprint-defender {};
font-fingerprint-defender = pkgs.callPackage ./own-pkgs/font-fingerprint-defender {};
user-agent-switcher = pkgs.callPackage ./own-pkgs/user-agent-switcher {};
dark-reader = pkgs.callPackage ./own-pkgs/dark-reader {};
wrapper = pkgs.callPackage ./overlays/firefox-with-config.nix { };
wrapper = pkgs.callPackage ../5pkgs/firefox/firefox-with-config.nix { };
myFirefox = wrapper pkgs.firefox-unwrapped {
extraExtensions = [
# these plugins are defined in 5pkgs/firefox
extraExtensions = with pkgs ; [
dark-reader
https-everywhere
ublock-origin

View File

@ -232,11 +232,10 @@ services.xserver.enable = true;
services.xserver.displayManager.lightdm.enable = true;
# Allow users in video group to change brightness
hardware.brightnessctl.enable = true;
environment.systemPackages = with pkgs; [
rofi # Dmenu replacement
acpilight # Replacement for xbacklight
brightnessctl
arandr # Xrandr gui
feh
wirelesstools # To get wireless statistics

View File

@ -0,0 +1,18 @@
with import <stockholm/lib>;
self: super:
let
# This callPackage will try to detect obsolete overrides.
callPackage = path: args: let
override = self.callPackage path args;
upstream = optionalAttrs (override ? "name")
(super.${(parseDrvName override.name).name} or {});
in if upstream ? "name" &&
override ? "name" &&
compareVersions upstream.name override.name != -1
then trace "Upstream `${upstream.name}' gets overridden by `${override.name}'." override
else override;
in
mapNixDir (path: callPackage path {}) ./.

View File

@ -68,6 +68,31 @@ in {
};
};
};
helsinki = {
owner = config.krebs.users.ajs124;
nets = {
retiolum = {
ip4.addr = "10.243.10.1";
aliases = [ "helsinki.r" ];
tinc.pubkey = ''
-----BEGIN RSA PUBLIC KEY-----
MIICCgKCAgEA5MnCmT9xVEtv3hoZsjmgF4pVnPgzaWWVrZVguMfXcbTiusgWqBIM
Ms/Ue676J3kQIJT1QSMA2RWDUU++dUcfhHF87vFpnyCnaKjfz6LyAwlSfKluttyY
aFNgcUWlZRl4wkqys/oYhLD1q26mO/ekCA2eohzbB1TCaPY97VM5nl0MkXStMN76
B+Ipw/gQcZXuWYct8Nj69sETPLnbf6ZBKs+T213as+NUSHVUdmBmV8QtmHDI3e7B
4wAK1JkFCQgVu9gm/6BvqWroOMcmtxzSceyrY+0MWnAnM+wrLcYYaT2xw1OJyWmM
riOHHMw9iLVxqyQ+3eDucJRQcJzO7I4j8zQaoYxPE1ZSl4wTsaypkMuNOyhYv2C9
RNPJgTBlr911NnY7TcKauz/lO1Qcl5kHBMrIfwsbsQK+zfN2XX+s21/SPeSJ7k1N
OqXeyX0mz2l7bhBDwTTDtINSz8sB3BL59mVbWY5z5b90oeKPrfygmp7V0CSKgHBr
b5ZIhMRfgcK+HjolcEqdL9INpJZVFYt3vWPNhDpbX5sEOjjR+ODceriL8zdlTBRx
PyB9OiK6tN+L63QFM7H1NFN9fPeOd2WbHvfoeX255kx8FHSALKL5rVSz9Ejwc97k
rG0FItgHXajPazulBfUV0N9ck7SwLTmStKxtQ8NKCoIJLpv2ip4C+t0CAwEAAQ==
-----END RSA PUBLIC KEY-----
Ed25519PublicKey = 47fX1g6qynVprA+PtniBLEonFp1B70nMrJ8SBCWNJnL
'';
};
};
};
homeros = {
owner = config.krebs.users.kmein;
nets = {
@ -399,6 +424,9 @@ in {
};
};
users = {
ajs124 = {
mail = "stockholm@ajs124.de";
};
ciko = {
mail = "wieczorek.stefan@googlemail.com";
};

View File

@ -1,7 +1,7 @@
{
"url": "https://github.com/NixOS/nixpkgs-channels",
"rev": "1e90c46c2d98f9391df79954a74d14f263cad729",
"date": "2020-04-20T23:47:17-04:00",
"sha256": "1xs0lgh3q1hbrj0lbpy3czw41cv6vxx9kdf2npwc58z8xq3sdqmh",
"rev": "5adf2a6c11646898742b0c08f7e94101620ba707",
"date": "2020-05-11T09:54:07+01:00",
"sha256": "0wf7pwma2qyfak39b242mcq8z7cdj65sds7hcjxchy0448shapzi",
"fetchSubmodules": false
}

View File

@ -21,20 +21,15 @@ with import <stockholm/lib>;
#<stockholm/lass/2configs/prism-share.nix>
<stockholm/lass/2configs/ssh-cryptsetup.nix>
<stockholm/lass/2configs/network-manager.nix>
<stockholm/lass/2configs/home-media.nix>
];
#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 ];
}

View File

@ -22,22 +22,11 @@ with import <stockholm/lib>;
<stockholm/lass/2configs/hass>
<stockholm/lass/2configs/br.nix>
<stockholm/lass/2configs/fetchWallpaper.nix>
<stockholm/lass/2configs/home-media.nix>
];
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";

View File

@ -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 = {

View File

@ -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}";
hide_entity = true;
trigger = {
platform = "state";
entity_id = sensor_;
from = "on";
to = "off";
};
condition = {
condition = "template";
value_template = "{{ states('input_boolean.${id}') == 'on' }}";
};
action = [
{
service = "timer.start";
entity_id = "timer.${id}";
}
];
}
{
alias = "movement override ${id}";
hide_entity = true;
trigger = {
platform = "state";
entity_id = light_;
};
action = [
{
service = "input_boolean.turn_off";
data_template.entity_id = "input_boolean.${id}";
}
{
service = "system_log.write";
data_template = {
message = "XXXXXXXXXXXXXXXXXXXXXX {{ trigger }}";
};
}
];
}
{
alias = "movement expired ${id}";
hide_entity = true;
trigger = {
platform = "event";
event_type = "timer.finished";
event_data.entity_id = "timer.${id}";
};
action = [
{
service = "light.turn_off";
data_template = {
entity_id = light_;
};
}
{
service = "input_boolean.turn_off";
data_template.entity_id = "input_boolean.${id}";
}
];
}
];
};
lightswitch = switch: light: {
automation = [
{
alias = "lightswitch ${switch} turn on light ${light}";
hide_entity = "true";
trigger = {
platform = "mqtt";
topic = "zigbee/${switch}";
@ -47,13 +225,15 @@
{
service = "light.turn_on";
data_template = {
entity_id = light;
entity_id = "light.${light}_light";
brightness = "{{ trigger.payload_json.brightness }}";
};
}
];
}
{
alias = "lightswitch ${switch} turn off light ${light}";
hide_entity = "true";
trigger = {
platform = "mqtt";
topic = "zigbee/${switch}";
@ -74,7 +254,7 @@
action = {
service = "light.turn_off";
data_template = {
entity_id = light;
entity_id = "light.${light}_light";
};
};
}

View File

@ -1,27 +1,8 @@
{ lib, ... }:
with import ../lib.nix;
with import ../lib.nix { inherit lib; };
{
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)
lass.hass.config = lib.mkMerge [
(lightswitch switches.dimmer.bett lights.bett)
];
}

View File

@ -0,0 +1,9 @@
{ lib, ... }:
with import ../lib.nix { inherit lib; };
{
lass.hass.config = lib.mkMerge [
(detect_movement sensors.movement.essen lights.essen 10)
(lightswitch switches.dimmer.essen lights.essen)
];
}

View File

@ -0,0 +1,10 @@
{ lib, ... }:
with import ../lib.nix { inherit lib; };
{
lass.hass.config = lib.mkMerge [
(detect_movement sensors.movement.nass lights.nass 100)
(lightswitch switches.dimmer.nass lights.nass)
];
}

View File

@ -2,7 +2,7 @@
zigbee2mqtt_cfg = pkgs.writeText "zigbee2mqtt.json" (builtins.toJSON {
homeassistant = true;
permit_join = true;
permit_join = false;
mqtt = {
discovery = true;
base_topic = "zigbee";
@ -41,14 +41,14 @@ in {
{
platform = "mqtt";
name = "Zigbee2mqtt Bridge state";
state_topic = "/zigbee/bridge/state";
state_topic = "/zigbee2mqtt/bridge/state";
icon = "mdi:router-wireless";
}
# Sensor for Showing the Zigbee2mqtt Version
{
platform = "mqtt";
name = "Zigbee2mqtt Version";
state_topic = "/zigbee/bridge/config";
state_topic = "/zigbee2mqtt/bridge/config";
value_template = "{{ value_json.version }}";
icon = "mdi:zigbee";
}
@ -56,7 +56,7 @@ in {
{
platform = "mqtt";
name = "Coordinator Version";
state_topic = "/zigbee/bridge/config";
state_topic = "/zigbee2mqtt/bridge/config";
value_template = "{{ value_json.coordinator }}";
icon = "mdi:chip";
}
@ -64,39 +64,39 @@ in {
switch = [
{
platform = "mqtt";
name = "Zigbee2mqtt Main join";
state_topic = "/zigbee/bridge/config/permit_join";
command_topic = "/zigbee/bridge/config/permit_join";
name = "zigbee2mqtt_join";
state_topic = "/zigbee2mqtt/bridge/config/permit_join";
command_topic = "/zigbee2mqtt/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";
};
}
];
}
#{
# 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 = "/zigbee2mqtt/bridge/config/log_level";
# };
# }
# ];
#}
# Automation to start timer when enable join is turned on
{
id = "zigbee_join_enabled";
alias = "Zigbee Join Enabled";
alias = "";
hide_entity = "true";
trigger = {
platform = "state";
entity_id = "switch.zigbee2mqtt_main_join";
entity_id = "switch.zigbee2mqtt_join";
to = "on";
};
action = {
@ -107,7 +107,6 @@ in {
# 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 = [
{
@ -117,7 +116,7 @@ in {
}
{
platform = "state";
entity_id = "switch.zigbee2mqtt_main_join";
entity_id = "switch.zigbee2mqtt_join";
to = "off";
}
];
@ -126,22 +125,22 @@ in {
data.entity_id = "timer.zigbee_permit_join";
}
{ service = "switch.turn_off";
entity_id = "switch.zigbee2mqtt_main_join";
entity_id = "switch.zigbee2mqtt_join";
}
];
}
];
input_select.zigbee2mqtt_log_level = {
name = "Zigbee2mqtt Log Level";
options = [
"debug"
"info"
"warn"
"error"
];
initial = "info";
icon = "mdi:format-list-bulleted";
};
#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";

View File

@ -0,0 +1,23 @@
with import <stockholm/lib>;
{ 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
];
}