-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathebook.nix
28 lines (28 loc) · 854 Bytes
/
ebook.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
final: prev: {
ebook_fixup = final.pog {
name = "ebook_fixup";
description = "a quick and easy way to try to fix an ebook for kindle";
arguments = [
{ name = "source"; }
];
flags = [
{
name = "output";
description = "the filename to output to [defaults to the current name with a 'fixed' between the name and extension]";
}
];
script =
let
e = "${final.calibre}/bin/ebook-convert";
mktemp = "${final.coreutils}/bin/mktemp --suffix=.mobi";
in
helpers: with helpers; ''
file="$1"
temp_ebook="$(${mktemp})"
${var.empty "file"} && die "you must specify a source ebook!" 1
${var.empty "output"} && output="''${file%.*}.fixed.''${file##*.}"
${e} "$file" "$temp_ebook"
${e} "$temp_ebook" "$output"
'';
};
}