about summary refs log tree commit diff
path: root/wyze.nix
diff options
context:
space:
mode:
Diffstat (limited to 'wyze.nix')
-rw-r--r--wyze.nix40
1 files changed, 40 insertions, 0 deletions
diff --git a/wyze.nix b/wyze.nix
new file mode 100644
index 0000000..830e873
--- /dev/null
+++ b/wyze.nix
@@ -0,0 +1,40 @@
+{ attrs, pkgs, ... }:
+
+pkgs.stdenv.mkDerivation {
+  name = attrs.name;
+  version = attrs.version;
+
+  src = pkgs.fetchurl {
+    url = "https://download.wyzecam.com/firmware/${attrs.basePath}/${attrs.version}.zip";
+    hash = attrs.hash;
+  };
+
+  phases = [
+    "unpackPhase"
+    "buildPhase"
+  ];
+
+  nativeBuildInputs = with pkgs; [ unzip ];
+
+  unpackPhase = if
+    pkgs.lib.hasPrefix "wco_cam_sd" attrs.version
+    || pkgs.lib.hasPrefix "wco_cam_v2_sd" attrs.version
+  then ''
+    unzip -d $out $src
+  '' else ''
+    unzip -d $out $src
+    gzip -d $out/*.tar.gz
+  '';
+
+  buildPhase = if
+    pkgs.lib.hasPrefix "wco_cam_sd" attrs.version
+    || pkgs.lib.hasPrefix "wco_cam_v2_sd" attrs.version
+  then ''
+    ls -l $out/sd_update
+    ls -1 $out/sd_update| xargs -I {} file $out/sd_update/{} > $out/info.txt
+  '' else ''
+    tar -xvf $out/*.tar --directory $out
+    ls -l $out/fw_file
+    find $out/| xargs -I {} file $out/fw_file/{} > $out/info.txt
+  '';
+}