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 /pkgs/misc | |
| 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 'pkgs/misc')
| -rw-r--r-- | pkgs/misc/create-koboroot.nix | 5 | ||||
| -rw-r--r-- | pkgs/misc/deploy.nix | 65 | ||||
| -rw-r--r-- | pkgs/misc/merge.nix | 10 |
3 files changed, 75 insertions, 5 deletions
diff --git a/pkgs/misc/create-koboroot.nix b/pkgs/misc/create-koboroot.nix new file mode 100644 index 0000000..7cf1bff --- /dev/null +++ b/pkgs/misc/create-koboroot.nix @@ -0,0 +1,5 @@ +{ runCommandLocal, ... }: p: +runCommand "mk-koboroot" {} '' + mkdir -p $out + tar czvf --mode=u+w $out/KoboRoot.tgz "${p}" +'' diff --git a/pkgs/misc/deploy.nix b/pkgs/misc/deploy.nix new file mode 100644 index 0000000..23973e9 --- /dev/null +++ b/pkgs/misc/deploy.nix @@ -0,0 +1,65 @@ +{ stdenvNoCC, writeShellApplication, makeWrapper, rsync, kobo-utils, lib, ... }: +src: +let + deployScript = writeShellApplication { + name = "deploy"; + runtimeInputs = [ + rsync + kobo-utils + ]; + text = '' + PAYLOAD="./payload" + + if [[ ! -d "$PAYLOAD" ]]; then + >&2 echo "./payload is not a directory I can copy..." + exit 1 + fi + + KOBOMNT="$(kobo-find -f -w)" + KOBODIR="$KOBOMNT/.kobo" + + if [[ -z "$KOBOMNT" ]]; then + >&2 echo "Cannot find mounted kobo" + exit 1 + elif [[ ! -d "$KOBODIR" ]]; then + >&2 echo "$KOBODIR does not appear to exist. Is this really a kobo?" + exit 1 + fi + + echo "Deploying payload" + + rsync -rv --executability --chmod=u+w "$PAYLOAD/" "$KOBODIR" + ''; + }; +in stdenvNoCC.mkDerivation (finalAttrs: { + name = "deploy-kobo"; + + inherit src; + + nativeBuildInputs = [ + makeWrapper + ]; + + buildInputs = [ + kobo-utils + rsync + ]; + + phases = "installPhase"; + + installPhase = '' + runHook preInstall + + mkdir -p $out + cp -r $src $out/payload + + mkdir -p $out/bin + makeWrapper "${lib.getExe deployScript}" $out/bin/deploy --chdir "$out" + + runHook postInstall + ''; + + meta = { + mainProgram = "deploy"; + }; +}) diff --git a/pkgs/misc/merge.nix b/pkgs/misc/merge.nix index 9d6eabb..b4b4892 100644 --- a/pkgs/misc/merge.nix +++ b/pkgs/misc/merge.nix @@ -1,7 +1,7 @@ { runCommand, writeShellApplication, rsync, lib, ... }: args@{ name, paths, preferLocalBuild ? true, allowSubstitutes ? false, postBuild ? "" }: let - env = builtins.removeAttrs args [ "name" "postBuild" ]] // { + env = builtins.removeAttrs args [ "name" "postBuild" ] // { inherit preferLocalBuild allowSubstitutes; nativeBuildInputs = (args.nativeBuildInputs or []) ++ [ rsync @@ -28,8 +28,7 @@ let case "$REALPATH" in "/nix/store/"* ) - echo "Replacing $FILE by $REALPATH" - cp -v --remove-destination "$REALPATH" "$FILE" + cp -vf --remove-destination "$REALPATH" "$FILE" ;; esac ''; @@ -39,10 +38,11 @@ in runCommand name env '' mkdir -p $out for i in $(cat $pathsPath); do - rsync -rv --copy-dirlinks --links --executability "$i/" "$out" + rsync -rv --copy-dirlinks --links --executability --chmod=u+w "$i/" "$out" done - find $out -type l -exec "replaceBadSymlink {}" \; + find $out/ -type l -exec replaceBadSymlink {} \; + ${postBuild} '' |
