aboutsummaryrefslogtreecommitdiff
path: root/modules/build/info.nix
diff options
context:
space:
mode:
Diffstat (limited to 'modules/build/info.nix')
-rw-r--r--modules/build/info.nix55
1 files changed, 55 insertions, 0 deletions
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;
+ };
+ };
+ };
+}