diff options
author | Gregor Kleen <gkleen@yggdrasil.li> | 2023-02-25 13:27:37 +0100 |
---|---|---|
committer | Gregor Kleen <gkleen@yggdrasil.li> | 2023-02-25 13:27:37 +0100 |
commit | f122223243cbb50fa65d96646bc06f53567fd815 (patch) | |
tree | c14a2c875e2c56131857fa98f13a7e26581a3782 | |
parent | 07f9ba7096d0db355d87147468990bc30b732a00 (diff) | |
download | nixos-f122223243cbb50fa65d96646bc06f53567fd815.tar nixos-f122223243cbb50fa65d96646bc06f53567fd815.tar.gz nixos-f122223243cbb50fa65d96646bc06f53567fd815.tar.bz2 nixos-f122223243cbb50fa65d96646bc06f53567fd815.tar.xz nixos-f122223243cbb50fa65d96646bc06f53567fd815.zip |
...
-rw-r--r-- | accounts/gkleen@sif/default.nix | 2 | ||||
-rw-r--r-- | accounts/gkleen@sif/zshrc | 18 | ||||
-rw-r--r-- | overlays/pdf-redact-tools.nix | 28 |
3 files changed, 18 insertions, 30 deletions
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 { | |||
364 | weechat wrappedElementDesktop # helvum | 364 | weechat wrappedElementDesktop # helvum |
365 | matrix-synapse-tools.synadm wrappedRocketChatDesktop | 365 | matrix-synapse-tools.synadm wrappedRocketChatDesktop |
366 | flakeInputs.deploy-rs.packages.${config.nixpkgs.system}.deploy-rs | 366 | flakeInputs.deploy-rs.packages.${config.nixpkgs.system}.deploy-rs |
367 | sieve-connect pdf-redact-tools gimp inkscape udiskie glab | 367 | sieve-connect gimp inkscape udiskie glab |
368 | ]; | 368 | ]; |
369 | 369 | ||
370 | file = { | 370 | 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() { | |||
113 | gitWorktree="" | 113 | gitWorktree="" |
114 | # notmuchMsg="" | 114 | # notmuchMsg="" |
115 | quickserve=false | 115 | quickserve=false |
116 | modifyPDF="" | ||
116 | 117 | ||
117 | while getopts ':t:a:s:Sd:ir:wqg:n:' arg; do | 118 | while getopts ':t:a:s:Sd:ir:wqg:n:p:' arg; do |
118 | case $arg in | 119 | case $arg in |
119 | "t") ;; | 120 | "t") ;; |
120 | "a") | 121 | "a") |
@@ -134,6 +135,7 @@ dir() { | |||
134 | "g") gitWorktree=${OPTARG} ;; | 135 | "g") gitWorktree=${OPTARG} ;; |
135 | # "n") notmuchMsg=${OPTARG} ;; | 136 | # "n") notmuchMsg=${OPTARG} ;; |
136 | "q") quickserve=true ;; | 137 | "q") quickserve=true ;; |
138 | "p") modifyPDF=${OPTARG} ;; | ||
137 | *) printf "Invalid option: %s\n" $arg >&2; exit 2 ;; | 139 | *) printf "Invalid option: %s\n" $arg >&2; exit 2 ;; |
138 | esac | 140 | esac |
139 | done | 141 | done |
@@ -157,7 +159,15 @@ dir() { | |||
157 | gitWorktree="" | 159 | gitWorktree="" |
158 | fi | 160 | fi |
159 | 161 | ||
162 | cleanup() | ||
163 | { | ||
164 | cd ${modifyPDF:h} | ||
165 | [[ -n ${modifyPDF} ]] && nix shell nixos#imagemagick -c convert ${dir}/page-*.png ${modifyPDF} | ||
166 | } | ||
167 | |||
160 | ( | 168 | ( |
169 | trap cleanup EXIT | ||
170 | |||
161 | cd ${dir} | 171 | cd ${dir} |
162 | export dir; | 172 | export dir; |
163 | 173 | ||
@@ -165,6 +175,8 @@ dir() { | |||
165 | 175 | ||
166 | [[ -n ${repoUrl} ]] && git clone -- ${repoUrl} . | 176 | [[ -n ${repoUrl} ]] && git clone -- ${repoUrl} . |
167 | 177 | ||
178 | [[ -n ${modifyPDF} ]] && templateArchive=${modifyPDF} | ||
179 | |||
168 | if [[ -n ${templateArchive} ]]; then | 180 | if [[ -n ${templateArchive} ]]; then |
169 | ( | 181 | ( |
170 | archiveFile="" | 182 | archiveFile="" |
@@ -205,6 +217,10 @@ dir() { | |||
205 | cpio --extract --make-directories --no-absolute-filenames -F ${templateArchive} | 217 | cpio --extract --make-directories --no-absolute-filenames -F ${templateArchive} |
206 | unpack=false | 218 | unpack=false |
207 | ;; | 219 | ;; |
220 | application/pdf) | ||
221 | nix shell nixos#ghostscript nixos#imagemagick -c convert -verbose -density 400 ${templateArchive} page-%0d.png | ||
222 | unpack=false | ||
223 | ;; | ||
208 | *) | 224 | *) |
209 | tar -xvaf ${templateArchive} | 225 | tar -xvaf ${templateArchive} |
210 | unpack=false | 226 | 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 @@ | |||
1 | { final, prev, ... }: { | ||
2 | pdf-redact-tools = prev.stdenv.mkDerivation { | ||
3 | pname = "pdf-redact-tools"; | ||
4 | version = "0.1.2"; | ||
5 | |||
6 | src = prev.fetchFromGitHub { | ||
7 | owner = "firstlookmedia"; | ||
8 | repo = "pdf-redact-tools"; | ||
9 | rev = "e407942fa19027718b706033d460a1dec2097094"; | ||
10 | sha256 = "sha256-mnz43HLau4PQ2xYqTx67I0BD+fVe0lRxQz2uAeCsaX0="; | ||
11 | }; | ||
12 | |||
13 | buildInputs = [ | ||
14 | (final.python3.withPackages (ps: with ps; [])) | ||
15 | final.makeWrapper | ||
16 | ]; | ||
17 | |||
18 | buildPhase = "true"; | ||
19 | |||
20 | installPhase = '' | ||
21 | mkdir -p $out/bin | ||
22 | install -m 0755 -t $out/bin \ | ||
23 | pdf-redact-tools | ||
24 | wrapProgram $out/bin/pdf-redact-tools \ | ||
25 | --prefix PATH : ${prev.lib.makeBinPath (with final; [ imagemagick ghostscriptX exiftool ])} | ||
26 | ''; | ||
27 | }; | ||
28 | } | ||