aboutsummaryrefslogtreecommitdiff
path: root/pkgs/misc
diff options
context:
space:
mode:
authorChris Wells <chris@mathematicaster.org>2024-09-10 11:21:08 -0500
committerChris Wells <chris@mathematicaster.org>2024-09-10 11:21:08 -0500
commit8eae39e8e670f228e9675fb3bc432ce512560396 (patch)
treed3736c2f236f0878c2d199b042deb6b4d25e9c6c /pkgs/misc
parent373d5246eb53ef1a13166b066248526f33f935db (diff)
downloadkobo-manager-8eae39e8e670f228e9675fb3bc432ce512560396.tar
kobo-manager-8eae39e8e670f228e9675fb3bc432ce512560396.tar.gz
kobo-manager-8eae39e8e670f228e9675fb3bc432ce512560396.tar.bz2
kobo-manager-8eae39e8e670f228e9675fb3bc432ce512560396.tar.lz
kobo-manager-8eae39e8e670f228e9675fb3bc432ce512560396.tar.xz
kobo-manager-8eae39e8e670f228e9675fb3bc432ce512560396.tar.zst
kobo-manager-8eae39e8e670f228e9675fb3bc432ce512560396.zip
Created a merge function which will probably be better than symlinkJoin. Also started writing the cli manager in haskell
Diffstat (limited to 'pkgs/misc')
-rw-r--r--pkgs/misc/firmware-check.nix8
-rw-r--r--pkgs/misc/merge.nix48
2 files changed, 54 insertions, 2 deletions
diff --git a/pkgs/misc/firmware-check.nix b/pkgs/misc/firmware-check.nix
index 53cd2c2..373ea36 100644
--- a/pkgs/misc/firmware-check.nix
+++ b/pkgs/misc/firmware-check.nix
@@ -1,5 +1,9 @@
{ writeShellApplication, jq, curl, ... }:
-{ deviceID, affiliate ? "kobo" }:
+{ deviceID
+, affiliate ? "kobo"
+, currentVersion ? "0.0"
+, serialNumber ? "N0"
+}:
writeShellApplication {
name = "kobo-check-firmware";
runtimeInputs = [
@@ -7,6 +11,6 @@ writeShellApplication {
jq
];
text = ''
- curl --silent "https://api.kobobooks.com/1.0/UpgradeCheck/Device/${deviceID}/${affiliate}/0.0/N0" | jq '.UpgradeURL'
+ curl --silent "https://api.kobobooks.com/1.0/UpgradeCheck/Device/${deviceID}/${affiliate}/${currentVersion}/${serialNumber}" | jq '.UpgradeURL'
'';
}
diff --git a/pkgs/misc/merge.nix b/pkgs/misc/merge.nix
new file mode 100644
index 0000000..9d6eabb
--- /dev/null
+++ b/pkgs/misc/merge.nix
@@ -0,0 +1,48 @@
+{ runCommand, writeShellApplication, rsync, lib, ... }:
+args@{ name, paths, preferLocalBuild ? true, allowSubstitutes ? false, postBuild ? "" }:
+let
+ env = builtins.removeAttrs args [ "name" "postBuild" ]] // {
+ inherit preferLocalBuild allowSubstitutes;
+ nativeBuildInputs = (args.nativeBuildInputs or []) ++ [
+ rsync
+ replaceBadSymlink
+ ];
+ passAsFile = [ "paths" ];
+ };
+
+ # copyDirs = p: ''
+ # ${lib.getExe rsync} -rv --copy-dirlinks --links --executability "${p}/" "$out"
+ # '';
+
+ replaceBadSymlink = writeShellApplication {
+ name = "replaceBadSymlink";
+ # runtimeInputs = [ coreutils ];
+ text = ''
+ FILE="''${1-}"
+
+ if [[ -z "$FILE" ]]; then
+ >&2 echo "Need a file input"
+ fi
+
+ REALPATH="$(readlink -f "$FILE")"
+
+ case "$REALPATH" in
+ "/nix/store/"* )
+ echo "Replacing $FILE by $REALPATH"
+ cp -v --remove-destination "$REALPATH" "$FILE"
+ ;;
+ esac
+ '';
+ };
+
+in runCommand name env ''
+ mkdir -p $out
+
+ for i in $(cat $pathsPath); do
+ rsync -rv --copy-dirlinks --links --executability "$i/" "$out"
+ done
+
+ find $out -type l -exec "replaceBadSymlink {}" \;
+
+ ${postBuild}
+''