diff options
| author | Chris Wells <chris@mathematicaster.org> | 2024-09-10 14:51:28 -0500 |
|---|---|---|
| committer | Chris Wells <chris@mathematicaster.org> | 2024-09-10 14:51:28 -0500 |
| commit | 4f471484b3a1e16230979a8406503a220b9101f4 (patch) | |
| tree | dc3f5256f275f34d3bcc9573462ed34c7fd97f77 /modules/installScript.nix | |
| parent | 5cb16c34a8c5b803ec723934c1dc828c0e8e3bad (diff) | |
| download | kobo-manager-4f471484b3a1e16230979a8406503a220b9101f4.tar kobo-manager-4f471484b3a1e16230979a8406503a220b9101f4.tar.gz kobo-manager-4f471484b3a1e16230979a8406503a220b9101f4.tar.bz2 kobo-manager-4f471484b3a1e16230979a8406503a220b9101f4.tar.lz kobo-manager-4f471484b3a1e16230979a8406503a220b9101f4.tar.xz kobo-manager-4f471484b3a1e16230979a8406503a220b9101f4.tar.zst kobo-manager-4f471484b3a1e16230979a8406503a220b9101f4.zip | |
I think this is almost working!
Diffstat (limited to 'modules/installScript.nix')
| -rw-r--r-- | modules/installScript.nix | 75 |
1 files changed, 0 insertions, 75 deletions
diff --git a/modules/installScript.nix b/modules/installScript.nix deleted file mode 100644 index 1e5e355..0000000 --- a/modules/installScript.nix +++ /dev/null @@ -1,75 +0,0 @@ -{ writeShellApplication -, coreutils -, util-linux -, lib - -, koboInput -, koboLabel ? "KOBOeReader" -, koboManifest ? {} -, ... }: -with builtins // lib; -let - manValues = attrValues koboManifest; - createMergeTool = local: remote: name: mergeTool: { - inherit name; - value = mergeTool "${local}/${name}" "${remote}/${name}"; - }; - collectMergeTools = local: remote: xs: listToAttrs (concatMap (v: map (name: createMergeTool local remote name v.mergeTool) v.targets) xs); - onDevManifest = local: remote: collectMergeTools local remote (filter (v: v.remoteOnly) manValues; - manifest = local: remote: collectMergeTools local remote (filter (v: ! v.remoteOnly) manValues); - - execApp = writeShellApplication { - name = "kobo-exec"; - runtimeInputs = [ - coreutils - ]; - text = '' - REMOTE_OR_LOCAL="''${1-}" - KOBO_DIR="''${2-}" - FILE="''${3-}" - - if [[ "$REMOTE_OR_LOCAL" == "REMOTE" ]]; then - ${toShellVar "MANIFEST" (onDevManifest ${koboInput} "$KOBO_DIR")} - FILEBASE="''${FILE/#$KOBO_DIR}" - else - ${toShellVar "MANIFEST" (manifest ${koboInput} "$KOBO_DIR")} - FILEBASE="''${FILE/#${koboInput}}" - fi - - ACTION="''${MANIFEST["$FILEBASE"]}" - - if [[ -n "$ACTION" ]]; then - eval "$ACTION" - elif [[ "$REMOTE_OR_LOCAL" == "LOCAL" ]]; then - if [[ -d "$FILE" ]]; then - mkdir -p "$KOBO_DIR/$FILEBASE" - else - cp -v "$FILE" "$KOBO_DIR/$FILEBASE" - fi - fi - ''; - }; -in writeShellApplication { - name = "KoboInstaller"; - runtimeInputs = [ - coreutils - util-linux - ]; - text = '' - KOBO_MOUNTPOINT="$(findmnt -nlo TARGET LABEL="${koboLabel}")" - if [[ -z "$KOBO_MOUNTPOINT" ]]; then - echo "Couldn't find a Kobo eReader volume with label ${koboLabel}. Are you sure one is actually mounted?" - exit 255 - fi - - KOBO_DIR="$KOBO_MOUNTPOINT/.kobo" - if [[ ! -d "$KOBO_DIR" ]]; then - echo "It doesn't seem like $KOBO_MOUNTPOINT actually points to a Kobo eReader since it doesn't contain a .kobo directory . . . " - exit 255 - fi - - find "$KOBO_DIR/" -not -path "$KOBO_DIR/" -exec ${execApp}/bin/kobo-exec "REMOTE" "$KOBO_DIR" {} \; - - find "${koboInput}/" -not -path "${koboInput}/" -exec ${execApp}/bin/kobo-exec "LOCAL" "$KOBO_DIR" {} \; - ''; -} |
