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

View File

@@ -1,5 +1,7 @@
{ pkgs, ... }:
let hp-driver = pkgs.hplipWithPlugin;
let
inherit (import <niveum/lib>) localAddresses;
hp-driver = pkgs.hplipWithPlugin;
in {
services.printing = {
enable = true;
@@ -16,7 +18,7 @@ in {
hardware.printers.ensurePrinters = [{
name = "OfficeJet";
location = "Zimmer";
deviceUri = "https://192.168.178.27";
deviceUri = "https://${localAddresses.officejet}";
model = "drv:///hp/hpcups.drv/hp-officejet_4650_series.ppd";
ppdOptions = {
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> ];
niveum.traadfri = {
enable = true;
user = "kmein";
host = "192.168.178.28";
host = localAddresses.tradfri;
key = lib.strings.fileContents <secrets/traadfri.key>;
rooms = {
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, ... }:
let
inherit (import ./lib.nix) triggers;
inherit (import <niveum/lib>) localAddresses;
in
{
disabledModules = [
@@ -31,8 +32,9 @@ in
discovery = {};
system_health = {};
history = {};
tradfri.host = "192.168.178.28";
# tradfri.host = localAddresses.tradfri; # dont use until python3Packages.pytradfri is packaged
sun = {};
mobile_app = {};
shopping_list = {};
sensor = [
{

View File

@@ -1,6 +1,22 @@
{ config, pkgs, lib, ... }:
let
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
{
disabledModules = [
@@ -8,30 +24,37 @@ in
];
imports = [
<nixos-unstable/nixos/modules/services/misc/home-assistant.nix>
<nixos-unstable/nixos/modules/services/misc/zigbee2mqtt.nix>
<nixpkgs-unstable/nixos/modules/services/misc/home-assistant.nix>
<nixpkgs-unstable/nixos/modules/services/misc/zigbee2mqtt.nix>
];
/*
ids = {
uids.zigbee2mqtt = genid "zigbee2mqtt";
gids.zigbee2mqtt = genid "zigbee2mqtt";
};
services.zigbee2mqtt = {
enable = true;
config = zigbee2mqttConfig;
package = pkgs.unstable.zigbee2mqtt;
config = {
permit_join = true;
homeassistant = true;
serial.port = "/dev/ttyACM0";
mqtt = {
discovery = true;
base_topic = "zigbee";
server = "mqtt://192.168.178.24"; # Rasperry local IP
user = "albrecht";
password = lib.strings.fileContents <system-secrets/mosquitto>;
};
};
*/
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=${zigbee2mqttDevice}:${zigbee2mqttDevice}"
];
volumes = ["/var/lib/zigbee2mqtt:/app/data"];
};
services.mosquitto = {