{ 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 || true ''; 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 ''; }