aboutsummaryrefslogtreecommitdiff
path: root/modules/build
diff options
context:
space:
mode:
Diffstat (limited to 'modules/build')
-rw-r--r--modules/build/default.nix5
-rw-r--r--modules/build/firmware.nix60
2 files changed, 65 insertions, 0 deletions
diff --git a/modules/build/default.nix b/modules/build/default.nix
new file mode 100644
index 0000000..be3f3b0
--- /dev/null
+++ b/modules/build/default.nix
@@ -0,0 +1,5 @@
+{
+ imports = [
+ ./firmware.nix
+ ];
+}
diff --git a/modules/build/firmware.nix b/modules/build/firmware.nix
new file mode 100644
index 0000000..673c379
--- /dev/null
+++ b/modules/build/firmware.nix
@@ -0,0 +1,60 @@
+{ 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."
+ '';
+ };
+ };
+ };
+}