nixos/modules/scripts/default.nix

46 lines
1.1 KiB
Nix
Raw Normal View History

{ pkgs, ... }:
let
compress-pdf = pkgs.writeShellScriptBin "compress-pdf" ''
2022-08-08 11:44:00 +02:00
${pkgs.ghostscript}/bin/gs -sDEVICE=pdfwrite \
-dCompatibilityLevel=1.5 \
-dNOPAUSE \
-dQUIET \
-dBATCH \
-sOutputFile=compressed_$1 $1'';
2022-08-08 11:44:19 +02:00
files-to-lowercase = pkgs.writeScriptBin "files-to-lowercase"
"${builtins.readFile ./files-to-lowercase.sh}";
2022-08-08 12:04:57 +02:00
heif-to-jpeg = pkgs.writeShellScriptBin "heif-to-jpeg" ''
for f in *.heic
do
echo "Working on file $f"
${pkgs.libheif}/bin/heif-convert $f $f.jpg
done'';
2022-08-08 16:21:44 +02:00
remove-special-characters = pkgs.writeScriptBin
"remove-special-characters"
"${builtins.readFile ./remove_special_characters.sh}";
2022-08-08 16:23:30 +02:00
replace-listings = pkgs.writeScriptBin
"replace-listings"
"${builtins.readFile ./replace-listings.sh}";
2022-08-08 16:45:08 +02:00
thumbnails = pkgs.writeShellScriptBin "thumbnails" ''
for d in $1/*; do
${pkgs.ffmpeg}/bin/ffmpeg -i "$d" -t 2 -r 0.5 "$d".jpg
done'';
in
{
2022-08-08 11:44:00 +02:00
environment.systemPackages = [
compress-pdf
2022-08-08 11:44:19 +02:00
files-to-lowercase
2022-08-08 12:04:57 +02:00
heif-to-jpeg
2022-08-08 16:21:44 +02:00
remove-special-characters
2022-08-08 16:23:30 +02:00
replace-listings
2022-08-08 16:45:08 +02:00
thumbnails
2022-08-08 11:44:00 +02:00
];
}
2022-08-08 11:44:00 +02:00