From f122223243cbb50fa65d96646bc06f53567fd815 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Sat, 25 Feb 2023 13:27:37 +0100 Subject: ... --- accounts/gkleen@sif/default.nix | 2 +- accounts/gkleen@sif/zshrc | 18 +++++++++++++++++- overlays/pdf-redact-tools.nix | 28 ---------------------------- 3 files changed, 18 insertions(+), 30 deletions(-) delete mode 100644 overlays/pdf-redact-tools.nix diff --git a/accounts/gkleen@sif/default.nix b/accounts/gkleen@sif/default.nix index ed3ba7d8..14e2c9a7 100644 --- a/accounts/gkleen@sif/default.nix +++ b/accounts/gkleen@sif/default.nix @@ -364,7 +364,7 @@ in { weechat wrappedElementDesktop # helvum matrix-synapse-tools.synadm wrappedRocketChatDesktop flakeInputs.deploy-rs.packages.${config.nixpkgs.system}.deploy-rs - sieve-connect pdf-redact-tools gimp inkscape udiskie glab + sieve-connect gimp inkscape udiskie glab ]; file = { diff --git a/accounts/gkleen@sif/zshrc b/accounts/gkleen@sif/zshrc index 8b29b2d3..3136a8f6 100644 --- a/accounts/gkleen@sif/zshrc +++ b/accounts/gkleen@sif/zshrc @@ -113,8 +113,9 @@ dir() { gitWorktree="" # notmuchMsg="" quickserve=false + modifyPDF="" - while getopts ':t:a:s:Sd:ir:wqg:n:' arg; do + while getopts ':t:a:s:Sd:ir:wqg:n:p:' arg; do case $arg in "t") ;; "a") @@ -134,6 +135,7 @@ dir() { "g") gitWorktree=${OPTARG} ;; # "n") notmuchMsg=${OPTARG} ;; "q") quickserve=true ;; + "p") modifyPDF=${OPTARG} ;; *) printf "Invalid option: %s\n" $arg >&2; exit 2 ;; esac done @@ -157,7 +159,15 @@ dir() { gitWorktree="" fi + cleanup() + { + cd ${modifyPDF:h} + [[ -n ${modifyPDF} ]] && nix shell nixos#imagemagick -c convert ${dir}/page-*.png ${modifyPDF} + } + ( + trap cleanup EXIT + cd ${dir} export dir; @@ -165,6 +175,8 @@ dir() { [[ -n ${repoUrl} ]] && git clone -- ${repoUrl} . + [[ -n ${modifyPDF} ]] && templateArchive=${modifyPDF} + if [[ -n ${templateArchive} ]]; then ( archiveFile="" @@ -205,6 +217,10 @@ dir() { cpio --extract --make-directories --no-absolute-filenames -F ${templateArchive} unpack=false ;; + application/pdf) + nix shell nixos#ghostscript nixos#imagemagick -c convert -verbose -density 400 ${templateArchive} page-%0d.png + unpack=false + ;; *) tar -xvaf ${templateArchive} unpack=false diff --git a/overlays/pdf-redact-tools.nix b/overlays/pdf-redact-tools.nix deleted file mode 100644 index d7879787..00000000 --- a/overlays/pdf-redact-tools.nix +++ /dev/null @@ -1,28 +0,0 @@ -{ final, prev, ... }: { - pdf-redact-tools = prev.stdenv.mkDerivation { - pname = "pdf-redact-tools"; - version = "0.1.2"; - - src = prev.fetchFromGitHub { - owner = "firstlookmedia"; - repo = "pdf-redact-tools"; - rev = "e407942fa19027718b706033d460a1dec2097094"; - sha256 = "sha256-mnz43HLau4PQ2xYqTx67I0BD+fVe0lRxQz2uAeCsaX0="; - }; - - buildInputs = [ - (final.python3.withPackages (ps: with ps; [])) - final.makeWrapper - ]; - - buildPhase = "true"; - - installPhase = '' - mkdir -p $out/bin - install -m 0755 -t $out/bin \ - pdf-redact-tools - wrapProgram $out/bin/pdf-redact-tools \ - --prefix PATH : ${prev.lib.makeBinPath (with final; [ imagemagick ghostscriptX exiftool ])} - ''; - }; -} -- cgit v1.2.3