Commit 4f4005dd authored by dish's avatar dish
Browse files

home-assistant-custom-lovelace-modules.zigbee2mqtt-networkmap: modernize

Gets rid of mkYarnPackage and its need for a package.json, as well as
the custom updateScript which was needed because of the package.json
parent 68005ab6
Loading
Loading
Loading
Loading
+0 −25
Original line number Diff line number Diff line
{
  "name": "zigbee2mqtt-networkmap",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "serve": "vue-cli-service serve",
    "build": "vue-cli-service build",
    "lint": "vue-cli-service lint"
  },
  "dependencies": {
    "vue": "^2.7.15"
  },
  "devDependencies": {
    "@babel/core": "^7.26.0",
    "@babel/eslint-parser": "^7.25.9",
    "@material/mwc-button": "^0.27.0",
    "@vue/cli-plugin-eslint": "^5.0.8",
    "@vue/cli-service": "^5.0.8",
    "@vue/eslint-config-standard": "^8.0.1",
    "eslint": "^8.57.1",
    "eslint-plugin-vue": "^9.32.0",
    "lodash.isequal": "^4.5.0",
    "vue-d3-network": "^0.1.28"
  }
}
+19 −30
Original line number Diff line number Diff line
{
  lib,
  stdenv,
  fetchFromGitHub,
  fetchYarnDeps,
  mkYarnPackage,
  yarnConfigHook,
  yarnBuildHook,
  nodejs,
  nix-update-script,
}:

mkYarnPackage rec {
stdenv.mkDerivation (finalAttrs: {
  pname = "zigbee2mqtt-networkmap";
  version = "0.10.0";

  src = fetchFromGitHub {
    owner = "azuwis";
    repo = "zigbee2mqtt-networkmap";
    rev = "v${version}";
    tag = "v${finalAttrs.version}";
    hash = "sha256-S4iUTjI+pFfa8hg1/lJSI1tl2nEIh+LO2WTYhWWLh/s=";
  };

  packageJSON = ./package.json;

  offlineCache = fetchYarnDeps {
    yarnLock = "${src}/yarn.lock";
    inherit (finalAttrs) src;
    hash = "sha256-yo+K3vUJH6WwyNj/UuvbhhmhdqzJ3XUzX+cKUueutjE=";
  };

  configurePhase = ''
    runHook preConfigure

    cp -r $node_modules node_modules
    chmod +w node_modules

    runHook postConfigure
  '';

  buildPhase = ''
    runHook preBuild

    yarn --offline build

    runHook postBuild
  '';
  nativeBuildInputs = [
    yarnConfigHook
    yarnBuildHook
    nodejs
  ];

  installPhase = ''
    runHook preInstall
@@ -51,16 +42,14 @@ mkYarnPackage rec {

  dontFixup = true;

  doDist = false;

  passthru.entrypoint = "zigbee2mqtt-networkmap.js";
  passthru.updateScript = ./update.sh;
  passthru.updateScript = nix-update-script { };

  meta = with lib; {
    changelog = "https://github.com/azuwis/zigbee2mqtt-networkmap/releases/tag/v${version}";
  meta = {
    changelog = "https://github.com/azuwis/zigbee2mqtt-networkmap/releases/tag/v${finalAttrs.version}";
    description = "Home Assistant Custom Card to show Zigbee2mqtt network map";
    homepage = "https://github.com/azuwis/zigbee2mqtt-networkmap";
    maintainers = with maintainers; [ azuwis ];
    license = licenses.mit;
    maintainers = with lib.maintainers; [ azuwis ];
    license = lib.licenses.mit;
  };
}
})
+0 −13
Original line number Diff line number Diff line
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p nix-update

set -xe

dirname="$(dirname "$0")"

# nix-update picks the wrong file `pkgs/development/tools/yarn2nix-moretea/yarn2nix/default.nix`
nix-update --override-filename "$dirname/package.nix" home-assistant-custom-lovelace-modules.zigbee2mqtt-networkmap

# update package.json
source=$(nix-build -A home-assistant-custom-lovelace-modules.zigbee2mqtt-networkmap.src)
cp "$source/package.json" "$dirname/package.json"