1
0
Fork 0

add tapo cli

This commit is contained in:
Maurice Debray 2026-02-10 16:30:26 +01:00
parent ea3f8f01bb
commit 4638bfae0e
7 changed files with 166 additions and 25 deletions

15
nix/lon.lock Normal file
View file

@ -0,0 +1,15 @@
{
"version": "1",
"sources": {
"nixpkgs": {
"type": "GitHub",
"fetchType": "tarball",
"owner": "NixOS",
"repo": "nixpkgs",
"branch": "nixos-unstable",
"revision": "d6c71932130818840fc8fe9509cf50be8c64634f",
"url": "https://github.com/NixOS/nixpkgs/archive/d6c71932130818840fc8fe9509cf50be8c64634f.tar.gz",
"hash": "sha256-ub1gpAONMFsT/GU2hV6ZWJjur8rJ6kKxdm9IlCT0j84="
}
}
}

53
nix/lon.nix Normal file
View file

@ -0,0 +1,53 @@
# Generated by lon. Do not modify!
let
lock = builtins.fromJSON (builtins.readFile ./lon.lock);
# Override with a path defined in an environment variable. If no variable is
# set, the original path is used.
overrideFromEnv =
name: path:
let
replacement = builtins.getEnv "LON_OVERRIDE_${name}";
in
if replacement == "" then
path
else
# this turns the string into an actual Nix path (for both absolute and
# relative paths)
if builtins.substring 0 1 replacement == "/" then
/. + replacement
else
/. + builtins.getEnv "PWD" + "/${replacement}";
fetchSource =
args@{ fetchType, ... }:
if fetchType == "git" then
builtins.fetchGit (
{
url = args.url;
ref = args.branch;
rev = args.revision;
narHash = args.hash;
submodules = args.submodules;
}
// (
if args ? lastModified then
{
inherit (args) lastModified;
shallow = true;
}
else
{ }
)
)
else if fetchType == "tarball" then
builtins.fetchTarball {
url = args.url;
sha256 = args.hash;
}
else
builtins.throw "Unsupported source type ${fetchType}";
in
builtins.mapAttrs (name: args: overrideFromEnv name (fetchSource args)) lock.sources

46
nix/tapo.nix Normal file
View file

@ -0,0 +1,46 @@
{
lib,
rustPlatform,
buildPythonPackage,
maturin,
fetchFromGitHub,
}:
buildPythonPackage rec {
pname = "tapo";
version = "0.8.8";
pyproject = true;
src = fetchFromGitHub {
owner = "mihai-dinculescu";
repo = "tapo";
rev = "v${version}";
hash = "sha256-cVrD2XfS3Oum0DL9DYQfnNN6WKyjSiy94Vj+sUMmbcc=";
};
nativeBuildInputs = [
rustPlatform.cargoSetupHook
rustPlatform.maturinBuildHook
];
sourceRoot = "${src.name}/tapo-py";
cargoRoot = "../";
env = {
CARGO_TARGET_DIR = "./target";
};
cargoDeps = rustPlatform.fetchCargoVendor {
inherit pname version src;
hash = "sha256-Klr3rx1zYcul1gPz6H+d5idHlNJQB3SuY5nZlXwHFmY=";
};
meta = {
description = "Unofficial Tapo API Client. Works with TP-Link Tapo smart devices. Tested with light bulbs (L510, L520, L530, L535, L610, L630), light strips (L900, L920, L930), plugs (P100, P105, P110, P110M, P115), power strips (P300, P304M, P316M), hubs (H100), switches (S200B) and sensors (KE100, T100, T110, T300, T310, T315";
homepage = "https://github.com/mihai-dinculescu/tapo";
changelog = "https://github.com/mihai-dinculescu/tapo/blob/${src.rev}/CHANGELOG.md";
license = lib.licenses.mit;
maintainers = with lib.maintainers; [ ];
mainProgram = "tapo";
};
}