Unverified Commit 7dac4f96 authored by lassulus's avatar lassulus Committed by GitHub
Browse files

deye-dummycloud: init at c36009e (#458603)

parents 9eea4320 8cf08210
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -20939,6 +20939,12 @@
    githubId = 66107;
    name = "Daniel Poelzleithner";
  };
  poeschel = {
    email = "poeschel@mailbox.org";
    github = "poeschel";
    githubId = 703724;
    name = "Lars Pöschel";
  };
  pogobanane = {
    email = "mail@peter-okelmann.de";
    github = "pogobanane";
+1 −0
Original line number Diff line number Diff line
@@ -709,6 +709,7 @@
  ./services/hardware/usbmuxd.nix
  ./services/hardware/usbrelayd.nix
  ./services/hardware/vdr.nix
  ./services/home-automation/deye-dummycloud.nix
  ./services/home-automation/ebusd.nix
  ./services/home-automation/esphome.nix
  ./services/home-automation/evcc.nix
+56 −0
Original line number Diff line number Diff line
{
  config,
  lib,
  pkgs,
  ...
}:

let
  cfg = config.services.deye-dummycloud;
in
{
  options.services.deye-dummycloud = {
    enable = lib.mkEnableOption "the deye-dummycloud service";

    mqttBrokerUrl = lib.mkOption {
      type = lib.types.str;
      default = "mqtt://localhost";
      description = "MQTT broker URL";
    };
    mqttUsername = lib.mkOption {
      type = lib.types.str;
      default = "";
      description = "MQTT username";
    };
    mqttPassword = lib.mkOption {
      type = lib.types.str;
      default = "";
      description = "MQTT password";
    };
  };

  config = lib.mkIf cfg.enable {
    systemd.services.deye-dummycloud = {
      description = "Dummycloud server for DEYE microinverters and bridge to mqtt";
      wants = [ "network.target" ];
      after = [ "network.target" ];
      wantedBy = [ "multi-user.target" ];
      serviceConfig = {
        WorkingDirectory = "${pkgs.deye-dummycloud}/lib/node_modules/deye-dummycloud";
        ExecStart = "${pkgs.nodejs}/bin/node app.js";
        Restart = "always";
        User = "deye-dummycloud";
        DynamicUser = true;
        ProtectSystem = "full";
        ProtectHome = true;
        Environment = [
          "MQTT_BROKER_URL=${cfg.mqttBrokerUrl}"
          "MQTT_USERNAME=${cfg.mqttUsername}"
          "MQTT_PASSWORD=${cfg.mqttPassword}"
        ];
      };
    };

    environment.systemPackages = [ pkgs.deye-dummycloud ];
  };
}
+2250 −0

File added.

Preview size limit exceeded, changes collapsed.

+32 −0
Original line number Diff line number Diff line
{
  lib,
  buildNpmPackage,
  fetchFromGitHub,
  nodejs,
}:

buildNpmPackage {
  pname = "deye-dummycloud";
  version = "c36009e";

  src = fetchFromGitHub {
    owner = "Hypfer";
    repo = "deye-microinverter-cloud-free";
    rev = "c36009e5c1711aa0f76bd17d63e33322535a87f9";
    hash = "sha256-ARd2Vi305lErYAZ3FN+hXocHCHxC3gr6mbrPn032zxc=";
  };
  sourceRoot = "source/dummycloud";
  npmDepsHash = "sha256-zN+iE9M12osr72z9Jvp80SdLeGahz7drvF+kx7914AE=";

  patches = [ ./0001-packge.json-Remove-dev-dependencies-for-repoducible-.patch ];

  dontNpmBuild = true;

  meta = {
    description = "A dummy cloud server for DEYE microinverters (Node.js) and bridge to mqtt";
    homepage = "https://github.com/Hypfer/deye-microinverter-cloud-free";
    license = lib.licenses.asl20;
    maintainers = with lib.maintainers; [ poeschel ];
    platforms = lib.platforms.linux;
  };
}