From 63bde1fd099a21554aba0024b9ac015b63786ed8 Mon Sep 17 00:00:00 2001 From: Aaron Bieber Date: Wed, 9 Aug 2023 12:46:14 -0600 Subject: [PATCH] box,pwntie: setup rtlamr and rtlamr2mqtt (non-working) --- flake.nix | 1 + hosts/box/default.nix | 47 ++++++++++++++++++++++++++++++++++++---- hosts/pwntie/default.nix | 2 ++ pkgs/rtlamr.nix | 27 +++++++++++++++++++++++ 4 files changed, 73 insertions(+), 4 deletions(-) create mode 100644 pkgs/rtlamr.nix diff --git a/flake.nix b/flake.nix index 9024e14..7350119 100644 --- a/flake.nix +++ b/flake.nix @@ -267,6 +267,7 @@ spkgs.callPackage ./pkgs/ada_language_server.nix {inherit spkgs;}; alire = spkgs.callPackage ./pkgs/alire.nix {inherit spkgs;}; bearclaw = spkgs.callPackage ./pkgs/bearclaw.nix {inherit spkgs;}; + rtlamr = spkgs.callPackage ./pkgs/rtlamr.nix {inherit spkgs;}; clilol = spkgs.callPackage ./pkgs/clilol.nix {inherit spkgs;}; gqrss = spkgs.callPackage ./pkgs/gqrss.nix { inherit spkgs; diff --git a/hosts/box/default.nix b/hosts/box/default.nix index 150bac5..1e755fc 100644 --- a/hosts/box/default.nix +++ b/hosts/box/default.nix @@ -44,6 +44,12 @@ owner = config.users.users.nginx.name; mode = "400"; }; + rtlamr2mqtt = pkgs.fetchFromGitHub { + owner = "allangood"; + repo = "rtlamr2mqtt"; + rev = "b2b05b9c16c396790913fd6f2ff11d5afdef4de8"; + hash = "sha256-bm348peVASsApjH+tUyFeF/gXltUNhssT7o+z20qnCc="; + }; in { _module.args.isUnstable = false; imports = [ @@ -51,6 +57,11 @@ in { #"${inputs.unstable}/nixos/modules/services/home-automation/home-assistant.nix" ]; + systemd.tmpfiles.rules = [ + "C /var/lib/hass/custom_components/rtlamr2mqtt - - - - ${rtlamr2mqtt}" + "Z /var/lib/hass/custom_components 770 hass hass - -" + ]; + sops.secrets = { #nextcloud_db_pass = { # owner = config.users.users.nextcloud.name; @@ -136,6 +147,7 @@ in { config.services.gitea.settings.server.SSH_PORT 21063 #homekit 21064 #homekit + 1883 # mosquitto ]; allowedUDPPorts = [ 5353 #homekit @@ -233,6 +245,17 @@ in { hardware.rtl-sdr.enable = true; services = { + mosquitto = { + enable = true; + listeners = [ + { + acl = ["pattern readwrite #"]; + omitPasswordAuth = true; + settings.allow_anonymous = true; + } + ]; + }; + avahi = { enable = true; openFirewall = true; @@ -253,22 +276,38 @@ in { "aprs" "brother" "esphome" - "rest" "ffmpeg" "homekit" "homekit_controller" "icloud" "jellyfin" + "logger" "met" - "prometheus" + "mqtt" "nextdns" + "prometheus" "pushover" + "rest" "snmp" "zeroconf" - - "logger" ]; config = { + mqtt.sensor = [ + # { + # name = "Gas Meter"; + # unique_id = "gas_meter"; + # state_topic = "readings/48582066/meter_reading"; + # icon = "mdi:gas-burner"; + # unit_of_measurement = "cu ft"; + # } + # { + # name = "Electric Meter"; + # unique_id = "electric_meter"; + # state_topic = "readings/20015637/meter_reading"; + # icon = "mdi:meter-electric-outline"; + # unit_of_measurement = "kWh"; + # } + ]; logger = { default = "warning"; logs = { diff --git a/hosts/pwntie/default.nix b/hosts/pwntie/default.nix index 784cf3a..5fc6493 100644 --- a/hosts/pwntie/default.nix +++ b/hosts/pwntie/default.nix @@ -45,6 +45,8 @@ in { #nixpkgs.config.allowUnfree = true; environment.systemPackages = with pkgs; [ rtl-sdr + direwolf + (callPackage ../../pkgs/rtlamr.nix {}) ]; #programs = { diff --git a/pkgs/rtlamr.nix b/pkgs/rtlamr.nix new file mode 100644 index 0000000..8886fb8 --- /dev/null +++ b/pkgs/rtlamr.nix @@ -0,0 +1,27 @@ +{ + lib, + buildGoModule, + fetchFromGitHub, + ... +}: +with lib; + buildGoModule rec { + pname = "rtlamr"; + version = "0.9.3"; + + src = fetchFromGitHub { + owner = "bemasher"; + repo = pname; + rev = "v${version}"; + hash = "sha256-0LufLU/wTmCRqTnQBNJg5UnDv0u1Thec5FSWATWqZsQ="; + }; + + vendorHash = "sha256-uT6zfsWgIot0EMNqwtwJNFXN/WaAyOGfcYJjuyOXT4g="; + + meta = { + description = "rtl-sdr receiver for Itron ETR meters"; + homepage = "https://github.com/bemasher/rtlamr"; + license = licenses.agpl3; + maintainers = with maintainers; [qbit]; + }; + }