Misc updates (lockfile, zigbee2mqtt)
This commit is contained in:
		
							parent
							
								
									b77e23bdf3
								
							
						
					
					
						commit
						b385cf3bee
					
				
					 12 changed files with 175 additions and 62 deletions
				
			
		|  | @ -20,7 +20,7 @@ in | |||
|     enable = mkEnableOption "manage nix configuration."; | ||||
|     package = mkOption { | ||||
|       type = types.package; | ||||
|       default = pkgs.nixVersions.latest; | ||||
|       default = pkgs.nixVersions.nix_2_31; | ||||
|       description = "Which nix package to use."; | ||||
|     }; | ||||
| 
 | ||||
|  |  | |||
|  | @ -15,6 +15,7 @@ in | |||
|       hass_mqtt.file = ../../../../secrets/hass_mqtt.age; | ||||
|       theengs_ble_mqtt.file = ../../../../secrets/theengs_ble_mqtt.age; | ||||
|       teslamate_mqtt.file = ../../../../secrets/teslamate_mqtt.age; | ||||
|       zigbee2mqtt_mqtt.file = ../../../../secrets/zigbee2mqtt_mqtt.age; | ||||
|     }; | ||||
| 
 | ||||
|     services.mosquitto = { | ||||
|  | @ -41,6 +42,13 @@ in | |||
|               acl = [ "readwrite teslamate/#" ]; | ||||
|               passwordFile = config.age.secrets.teslamate_mqtt.path; | ||||
|             }; | ||||
|             zigbee2mqtt = { | ||||
|               acl = [ | ||||
|                 "readwrite zigbee2mqtt/#" | ||||
|                 "readwrite homeassistant/#" | ||||
|               ]; | ||||
|               passwordFile = config.age.secrets.zigbee2mqtt_mqtt.path; | ||||
|             }; | ||||
|           }; | ||||
|         } | ||||
|       ]; | ||||
|  |  | |||
							
								
								
									
										75
									
								
								modules/nixos/services/zigbee2mqtt/default.nix
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										75
									
								
								modules/nixos/services/zigbee2mqtt/default.nix
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,75 @@ | |||
| { | ||||
|   config, | ||||
|   lib, | ||||
|   namespace, | ||||
|   ... | ||||
| }: | ||||
| let | ||||
|   cfg = config.${namespace}.services.zigbee2mqtt; | ||||
| in | ||||
| { | ||||
|   options.${namespace}.services.zigbee2mqtt = { | ||||
|     enable = lib.mkEnableOption "zigbee2mqtt"; | ||||
|     acmeCertName = lib.mkOption { | ||||
|       type = lib.types.str; | ||||
|       default = ""; | ||||
|       description = '' | ||||
|         If set to a non-empty string, forces SSL with the supplied acme | ||||
|         certificate. | ||||
|       ''; | ||||
|     }; | ||||
|   }; | ||||
| 
 | ||||
|   config = lib.mkIf cfg.enable { | ||||
|     age.secrets.zigbee2mqtt_creds = { | ||||
|       file = ../../../../secrets/zigbee2mqtt_creds.age; | ||||
|       path = "/var/lib/zigbee2mqtt/secret.yaml"; | ||||
|       owner = "zigbee2mqtt"; | ||||
|       group = "zigbee2mqtt"; | ||||
|       mode = "0400"; | ||||
|     }; | ||||
| 
 | ||||
|     services.zigbee2mqtt = { | ||||
|       enable = true; | ||||
|       settings = { | ||||
|         version = 4; | ||||
|         mqtt = { | ||||
|           base_topic = "zigbee2mqtt"; | ||||
|           server = "mqtt://192.168.113.13:1833"; | ||||
|           # TODO: Write secret.yaml file | ||||
|           user = "!secret.yaml user"; | ||||
|           password = "!secret.yaml password"; | ||||
|         }; | ||||
|         serial = { | ||||
|           port = "tcp://192.168.113.130:6638"; | ||||
|           adapter = "zstack"; | ||||
|         }; | ||||
|         advanced = { | ||||
|           channel = 11; | ||||
|           network_key = "GENERATE"; | ||||
|           pan_id = "GENERATE"; | ||||
|           ext_pan_id = "GENERATE"; | ||||
|         }; | ||||
|         frontend = { | ||||
|           enabled = true; | ||||
|           port = 8080; | ||||
|         }; | ||||
|         homeassistant = { | ||||
|           enabled = true; | ||||
|         }; | ||||
|       }; | ||||
|     }; | ||||
| 
 | ||||
|     services.nginx = { | ||||
|       enable = true; | ||||
|       recommendedProxySettings = true; | ||||
|       virtualHosts."zigbee2mqtt.kilonull.com" = { | ||||
|         locations."/".proxyPass = "http://127.0.0.1:8080"; | ||||
|       } | ||||
|       // lib.optionalAttrs (cfg.acmeCertName != "") { | ||||
|         forceSSL = true; | ||||
|         useACMEHost = cfg.acmeCertName; | ||||
|       }; | ||||
|     }; | ||||
|   }; | ||||
| } | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue