1
0
mirror of https://github.com/kmein/niveum synced 2026-03-16 10:11:08 +01:00

feat(lib): add localAddresses

This commit is contained in:
2020-10-24 13:27:36 +02:00
parent 177977160f
commit 240b97dce9
6 changed files with 73 additions and 26 deletions

View File

@@ -1,5 +1,7 @@
{ pkgs, lib, config, options, ... }: { pkgs, lib, config, options, ... }:
let inherit (lib.strings) makeBinPath; let
inherit (lib.strings) makeBinPath;
inherit (import <niveum/lib>) localAddresses;
in { in {
imports = [ imports = [
<niveum/modules/constants.nix> <niveum/modules/constants.nix>
@@ -222,11 +224,6 @@ in {
environment.systemPackages = [ pkgs.wpa_supplicant_gui ]; environment.systemPackages = [ pkgs.wpa_supplicant_gui ];
} }
{
networking.hosts = {
"192.168.178.1" = [ "fritz.box" ];
};
}
{ i18n.defaultLocale = "en_GB.UTF-8"; } { i18n.defaultLocale = "en_GB.UTF-8"; }
{ services.illum.enable = true; } { services.illum.enable = true; }
{ {
@@ -266,6 +263,12 @@ in {
helpLine = lib.mkForce ""; helpLine = lib.mkForce "";
}; };
} }
{
networking.hosts = lib.mapAttrs' (name: address: {
name = address;
value = [ "${name}.local" ];
}) localAddresses;
}
./alacritty.nix ./alacritty.nix
./bash.nix ./bash.nix
./bluetooth.nix ./bluetooth.nix

View File

@@ -1,5 +1,7 @@
{ pkgs, ... }: { pkgs, ... }:
let hp-driver = pkgs.hplipWithPlugin; let
inherit (import <niveum/lib>) localAddresses;
hp-driver = pkgs.hplipWithPlugin;
in { in {
services.printing = { services.printing = {
enable = true; enable = true;
@@ -16,7 +18,7 @@ in {
hardware.printers.ensurePrinters = [{ hardware.printers.ensurePrinters = [{
name = "OfficeJet"; name = "OfficeJet";
location = "Zimmer"; location = "Zimmer";
deviceUri = "https://192.168.178.27"; deviceUri = "https://${localAddresses.officejet}";
model = "drv:///hp/hpcups.drv/hp-officejet_4650_series.ppd"; model = "drv:///hp/hpcups.drv/hp-officejet_4650_series.ppd";
ppdOptions = { ppdOptions = {
Duplex = "DuplexNoTumble"; # DuplexNoTumble DuplexTumble None Duplex = "DuplexNoTumble"; # DuplexNoTumble DuplexTumble None

View File

@@ -1,10 +1,15 @@
{ pkgs, lib, ... }: { { pkgs, lib, ... }:
let
inherit (import <niveum/lib>) localAddresses;
living-room-id = 131086;
in
{
imports = [ <niveum/modules/traadfri.nix> ]; imports = [ <niveum/modules/traadfri.nix> ];
niveum.traadfri = { niveum.traadfri = {
enable = true; enable = true;
user = "kmein"; user = "kmein";
host = "192.168.178.28"; host = localAddresses.tradfri;
key = lib.strings.fileContents <secrets/traadfri.key>; key = lib.strings.fileContents <secrets/traadfri.key>;
rooms = { rooms = {
corridor = 131080; corridor = 131080;

12
lib/default.nix Normal file
View File

@@ -0,0 +1,12 @@
{
localAddresses = {
toum = "192.168.178.24";
homeros = "192.168.178.22";
wilde = "192.168.178.32";
android = "192.168.178.35";
tradfri = "192.168.178.28";
officejet = "192.168.178.27";
fritzbox = "192.168.178.1";
};
}

View File

@@ -1,6 +1,7 @@
{ config, pkgs, lib, ... }: { config, pkgs, lib, ... }:
let let
inherit (import ./lib.nix) triggers; inherit (import ./lib.nix) triggers;
inherit (import <niveum/lib>) localAddresses;
in in
{ {
disabledModules = [ disabledModules = [
@@ -31,8 +32,9 @@ in
discovery = {}; discovery = {};
system_health = {}; system_health = {};
history = {}; history = {};
tradfri.host = "192.168.178.28"; # tradfri.host = localAddresses.tradfri; # dont use until python3Packages.pytradfri is packaged
sun = {}; sun = {};
mobile_app = {};
shopping_list = {}; shopping_list = {};
sensor = [ sensor = [
{ {

View File

@@ -1,6 +1,22 @@
{ config, pkgs, lib, ... }: { config, pkgs, lib, ... }:
let let
inherit (import <stockholm/lib>) genid; inherit (import <stockholm/lib>) genid;
inherit (import <niveum/lib>) localAddresses;
zigbee2mqttDevice = "/dev/ttyACM0";
zigbee2mqttConfig = {
permit_join = false;
homeassistant = true;
serial.port = zigbee2mqttDevice;
mqtt = {
discovery = true;
base_topic = "zigbee";
server = "mqtt://${localAddresses.toum}"; # Rasperry local IP
user = "albrecht";
password = lib.strings.fileContents <system-secrets/mosquitto>;
};
};
zigbee2mqtt_cfg = pkgs.writeText "zigbee2mqtt.json" (builtins.toJSON zigbee2mqttConfig);
in in
{ {
disabledModules = [ disabledModules = [
@@ -8,30 +24,37 @@ in
]; ];
imports = [ imports = [
<nixos-unstable/nixos/modules/services/misc/home-assistant.nix> <nixpkgs-unstable/nixos/modules/services/misc/home-assistant.nix>
<nixos-unstable/nixos/modules/services/misc/zigbee2mqtt.nix> <nixpkgs-unstable/nixos/modules/services/misc/zigbee2mqtt.nix>
]; ];
/*
ids = { ids = {
uids.zigbee2mqtt = genid "zigbee2mqtt"; uids.zigbee2mqtt = genid "zigbee2mqtt";
gids.zigbee2mqtt = genid "zigbee2mqtt"; gids.zigbee2mqtt = genid "zigbee2mqtt";
}; };
services.zigbee2mqtt = { services.zigbee2mqtt = {
enable = true; enable = true;
config = zigbee2mqttConfig;
package = pkgs.unstable.zigbee2mqtt; package = pkgs.unstable.zigbee2mqtt;
config = { };
permit_join = true; */
homeassistant = true;
serial.port = "/dev/ttyACM0";
mqtt = { system.activationScripts.installZigbee = ''
discovery = true; install -d /var/lib/zigbee2mqtt
base_topic = "zigbee"; install ${zigbee2mqtt_cfg} /var/lib/zigbee2mqtt/configuration.yaml
server = "mqtt://192.168.178.24"; # Rasperry local IP '';
user = "albrecht";
password = lib.strings.fileContents <system-secrets/mosquitto>; # hack to restart docker container on config change
}; systemd.services.docker-zigbee2mqtt.environment.cfg = zigbee2mqtt_cfg;
};
docker-containers.zigbee2mqtt = {
image = "koenkk/zigbee2mqtt";
extraDockerOptions = [
"--device=${zigbee2mqttDevice}:${zigbee2mqttDevice}"
];
volumes = ["/var/lib/zigbee2mqtt:/app/data"];
}; };
services.mosquitto = { services.mosquitto = {