From 4f471484b3a1e16230979a8406503a220b9101f4 Mon Sep 17 00:00:00 2001 From: Chris Wells Date: Tue, 10 Sep 2024 14:51:28 -0500 Subject: I think this is almost working! --- modules/build/info.nix | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 modules/build/info.nix (limited to 'modules/build/info.nix') diff --git a/modules/build/info.nix b/modules/build/info.nix new file mode 100644 index 0000000..95ef664 --- /dev/null +++ b/modules/build/info.nix @@ -0,0 +1,55 @@ +{ config, pkgs, lib, ... }: +with builtins // lib; +let + json = pkgs.formats.json {}; + cfg = config.build.info; +in { + options = { + info = mkOption { + internal = true; + type = json.type; + default = {}; + }; + build = { + info = mkOption { + internal = true; + readOnly = true; + type = types.package; + default = pkgs.writeShellApplication { + name = "kobo-info"; + runtimeInputs = with pkgs; [ + jq + kobo-utils + ]; + text = '' + echo "Local information:" + echo '${toJSON config.info}' | jq . + + + echo "Remote information:" + + KOBOPATH="$(kobo-find -f || echo "")" + + if [[ -z "$KOBOPATH" ]]; then + echo "No remote found" + exit 0 + fi + + kobo-info --json "$KOBOPATH" | jq . + ''; + }; + }; + }; + }; + + config = { + info = { + device = { + inherit (config.device) name affiliate hardware deviceID serialNumber; + }; + firmware = { + inherit (config.firmware) version date; + }; + }; + }; +} -- cgit v1.2.3