esphome: Use proper dashboard version in update script

Also reduce faulty with scoping and use proper callPackage.
This commit is contained in:
Martin Weinelt 2023-01-27 02:40:06 +01:00
parent 765bec3650
commit b15f2af95e
No known key found for this signature in database
GPG key ID: 87C1E9888F856759
2 changed files with 19 additions and 7 deletions

View file

@ -1,4 +1,5 @@
{ lib
, callPackage
, python3
, fetchFromGitHub
, platformio
@ -13,7 +14,7 @@ let
};
};
in
with python.pkgs; buildPythonApplication rec {
python.pkgs.buildPythonApplication rec {
pname = "esphome";
version = "2022.12.4";
format = "setuptools";
@ -42,7 +43,7 @@ with python.pkgs; buildPythonApplication rec {
# They have validation functions like:
# - validate_cryptography_installed
# - validate_pillow_installed
propagatedBuildInputs = [
propagatedBuildInputs = with python.pkgs; [
aioesphomeapi
click
colorama
@ -71,7 +72,7 @@ with python.pkgs; buildPythonApplication rec {
"--set ESPHOME_USE_SUBPROCESS ''"
];
nativeCheckInputs = [
nativeCheckInputs = with python.pkgs; [
hypothesis
mock
pytest-asyncio
@ -92,7 +93,7 @@ with python.pkgs; buildPythonApplication rec {
'';
passthru = {
dashboard = esphome-dashboard;
dashboard = python.pkgs.esphome-dashboard;
updateScript = callPackage ./update.nix {};
};

View file

@ -1,12 +1,23 @@
{ writeShellScript
, lib
, curl
, jq
, git
, gnugrep
, gnused
, nix-update
}:
writeShellScript "update-esphome" ''
PATH=${lib.makeBinPath [ git nix-update ]}
PATH=${lib.makeBinPath [ curl gnugrep gnused jq git nix-update ]}
nix-update esphome.dashboard
nix-update esphome
LATEST=$(curl https://api.github.com/repos/esphome/esphome/releases/latest | jq -r '.name')
echo "Latest version: $LATEST"
DASHBOARD_VERSION=$(curl https://raw.githubusercontent.com/esphome/esphome/$LATEST/requirements.txt | \
grep "esphome-dashboard==" | sed "s/.*=//")
echo "Dashboard version: $DASHBOARD_VERSION"
nix-update esphome.dashboard --version $DASHBOARD_VERSION
nix-update esphome --version $LATEST
''