{ config, pkgs, lib, ... }: with builtins // lib; let cfg = config.build; in { options.build = { firmware = { checkDevice = mkOption { internal = true; readOnly = true; type = types.package; default = pkgs.writeShellApplication { name = "check-firmware"; runtimeInputs = with pkgs; [ kobo-utils ]; text = '' echo "hi" ''; }; }; bundle = let b = pkgs.runCommandLocal "package-firmware" {} '' cp -r "${config.firmware.package.out}" $out tar czvf $out/KoboRoot.tgz --directory="${config.firmware.package.KoboRoot}" ''; in pkgs.runCommandLocal "bundle-firmware" {} '' tar czvf $out --directory "${b}" ''; deploy = pkgs.writeShellApplication { name = "deploy-firmware"; runtimeInputs = with pkgs; [ gnutar kobo-utils ]; text = '' echo "Looking for kobo" KOBOPATH="$(kobo-find -f -w)" if [ -z "$KOBOPATH" ]; then >&2 echo "Cannot locate kobo device" exit 1 fi echo "Found kobo device at $KOBOPATH" echo "Placing firmware on device" tar xzvf "${cfg.fimware.bundle}" --directory="$KOBOPATH/.kobo/" echo "Successfully installed kobo firmware. Please eject your device so it can install." ''; }; }; }; }