about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEmile <git@emile.space>2023-10-31 20:03:19 +0100
committerEmile <git@emile.space>2023-10-31 20:03:19 +0100
commit392a7db129387fb2ca8846f7486cfb1b08e721d7 (patch)
tree31440941474e2c4152eef378df00f11926cbd9d7
initial commit
-rw-r--r--.gitignore1
-rw-r--r--README.md31
-rw-r--r--flake.lock27
-rw-r--r--flake.nix80
-rw-r--r--wyze.nix40
5 files changed, 179 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..bdb7f97
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+./result
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..5d8e107
--- /dev/null
+++ b/README.md
@@ -0,0 +1,31 @@
+# firmware
+
+## Usage
+
+View all available "packaged" (prepared) firmware versions
+
+```
+; nix flake show
+git+file:///Users/emile/firmware
+└───packages
+    └───aarch64-darwin
+        ├───wyze-4_16_4_496: package 'Wyze-Cam-Outdoor-Base-Station-Firmware-wco_station_sd_4.16.4.496'
+        ├───wyze-4_17_3_93: package 'Wyze-Cam-Outdoor-v1-Firmware-wco_cam_sd_4.17.3.93'
+        ├───wyze-4_17_4_124: package 'Wyze-Cam-Outdoor-v1-Firmware-wco_cam_sd_4.17.4.124'
+        ├───wyze-4_17_4_394: package 'Wyze-Cam-Outdoor-v1-Firmware-wco_cam_4.17.4.394'
+        ├───wyze-4_17_4_418: package 'Wyze-Cam-Outdoor-v1-Firmware-wco_cam_4.17.4.418'
+        ├───wyze-4_48_4_124: package 'Wyze-Cam-Outdoor-v2-Firmware-wco_cam_v2_sd_4.48.4.124'
+        ├───wyze-4_48_4_394: package 'Wyze-Cam-Outdoor-v2-Firmware-wco_cam_4.48.4.394'
+        └───wyze-4_48_4_418: package 'Wyze-Cam-Outdoor-v2-Firmware-wco_cam_4.48.4.418'
+```
+
+"Build" an image in order to get some information (this is just an example)
+
+```
+; nix build .#wyze-4_17_3_93
+; cat result/info.txt                                                                    /Users/emile/firmware
+/nix/store/89mazfka2xi0560v50ci2rirliz3l78n-Wyze-Cam-Outdoor-v1-Firmware-wco_cam_sd_4.17.3.93/sd_update/app.ver: ASCII text
+/nix/store/89mazfka2xi0560v50ci2rirliz3l78n-Wyze-Cam-Outdoor-v1-Firmware-wco_cam_sd_4.17.3.93/sd_update/rootfs_camera.cpio.lzo: data
+/nix/store/89mazfka2xi0560v50ci2rirliz3l78n-Wyze-Cam-Outdoor-v1-Firmware-wco_cam_sd_4.17.3.93/sd_update/system.bin: Squashfs filesystem, little endian, version 4.0, xz compressed, 1778706 bytes, 23 inodes, blocksize: 131072 bytes, created: Fri Jan 21 04:12:31 2022
+```
+
diff --git a/flake.lock b/flake.lock
new file mode 100644
index 0000000..0ac55be
--- /dev/null
+++ b/flake.lock
@@ -0,0 +1,27 @@
+{
+  "nodes": {
+    "nixpkgs": {
+      "locked": {
+        "lastModified": 1698756658,
+        "narHash": "sha256-+8PVTKQx7wRVDWYfTGgUGCuymXpLjla0Hy3uvHKndaA=",
+        "owner": "nixos",
+        "repo": "nixpkgs",
+        "rev": "fe74d948b59f71ac2c535d795b0d56b0dec0d0ff",
+        "type": "github"
+      },
+      "original": {
+        "owner": "nixos",
+        "ref": "release-23.05",
+        "repo": "nixpkgs",
+        "type": "github"
+      }
+    },
+    "root": {
+      "inputs": {
+        "nixpkgs": "nixpkgs"
+      }
+    }
+  },
+  "root": "root",
+  "version": 7
+}
diff --git a/flake.nix b/flake.nix
new file mode 100644
index 0000000..56f65b9
--- /dev/null
+++ b/flake.nix
@@ -0,0 +1,80 @@
+{
+  inputs = {
+    nixpkgs.url = "github:nixos/nixpkgs/release-23.05";
+  };
+
+  outputs = { nixpkgs, ... }: let
+    pkgs = import nixpkgs {
+      system = "aarch64-darwin";
+    };
+
+    packageVersions = {
+      # Wyze Cam Outdoor v1 Firmware
+      # https://support.wyze.com/hc/en-us/articles/360024852172-Release-Notes-Firmware
+
+      # v1 normal
+      "wyze-4_17_4_418" = rec {
+        name = "Wyze Cam Outdoor v1 Firmware ${version}";
+        basePath = "wcov";
+        version = "wco_cam_4.17.4.418";
+        hash = "sha256-bbHawgxUYfLotayyomQMFMsMjXT+2azab6Ey6yGe+No=";
+       };
+      "wyze-4_17_4_394" = rec {
+        name = "Wyze Cam Outdoor v1 Firmware ${version}";
+        basePath = "wcov";
+        version = "wco_cam_4.17.4.394";
+        hash = "sha256-x0hnWHhkFu8jIPcQjJaIIIiz6lLsC1A+2uDErhNLmKQ=";
+       };
+
+      # v1 sd
+      "wyze-4_17_4_124" = rec {
+        name = "Wyze Cam Outdoor v1 Firmware ${version}";
+        basePath = "wcov";
+        version = "wco_cam_sd_4.17.4.124";
+        hash = "sha256-GJRUEB7NBnaoWXhGpi7ZF50V1U3w5lQuIMUWV0WMXA0=";
+       };
+      "wyze-4_17_3_93" = rec {
+        name = "Wyze Cam Outdoor v1 Firmware ${version}";
+        basePath = "wcov";
+        version = "wco_cam_sd_4.17.3.93";
+        hash = "sha256-9iS8rR9ncKQUMcf17lwHFYBD3GbDhLYvZEUopcZfoPY=";
+       };
+
+      # v2
+      "wyze-4_48_4_418" = rec {
+        name = "Wyze Cam Outdoor v2 Firmware ${version}";
+        basePath = "wcov2";
+        version = "wco_cam_4.48.4.418";
+        hash = "sha256-1KAo8E77XI+4PcrjdDRtNDTB/g24I6rffprshuQgcbs=";
+      };
+      "wyze-4_48_4_394" = rec {
+        name = "Wyze Cam Outdoor v2 Firmware ${version}";
+        basePath = "wcov2";
+        version = "wco_cam_4.48.4.394";
+        hash = "sha256-yVsQ9EIxazsOLn9NuCOn7RMC7ACdbTlEi7CueReNJm4=";
+      };
+      "wyze-4_48_4_124" = rec {
+        name = "Wyze Cam Outdoor v2 Firmware ${version}";
+        basePath = "wcov2";
+        version = "wco_cam_v2_sd_4.48.4.124";
+        hash = "sha256-RqIpNR5DVDloTtjf0K+93VNfv74o2p01c0ekh8YZtJw=";
+      };
+
+      # Wyze Cam Outdoor Base Station Firmware
+      "wyze-4_16_4_496" = rec {
+        name = "Wyze Cam Outdoor Base Station Firmware ${version}";
+        basePath = "base";
+        version = "wco_station_sd_4.16.4.496";
+        hash = "sha256-pw0KLYrQlaKm/AnS0Qr18IQIDCgQcQnhwMfQ7C+Junk=";
+      };
+    };
+  in {
+    packages."aarch64-darwin" = nixpkgs.lib.mapAttrs
+      (name: attrs:
+        import ./wyze.nix {
+          inherit pkgs;
+          inherit attrs;
+        }
+      ) packageVersions;
+  };
+}
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
+  '';
+}