provide mobilizonPatchLogos as a nix flake library function
This commit is contained in:
parent
dad52ae432
commit
afe1cb57e3
118
flake.nix
118
flake.nix
|
@ -59,5 +59,123 @@
|
|||
inherit (self.packages.x86_64-linux) mobilizon update;
|
||||
};
|
||||
|
||||
lib = {
|
||||
# Patch the logos in a built Mobilizon package, so we don't have to do it in the source tree.
|
||||
mobilizonPatchLogos = pkg: icons:
|
||||
let
|
||||
inherit (icons) logo favicon;
|
||||
faviconDir = "./lib/mobilizon-${pkg.version}/priv/static";
|
||||
iconDir = "${faviconDir}/img/icons";
|
||||
in
|
||||
pkgs.stdenvNoCC.mkDerivation {
|
||||
inherit (pkg) name pname version;
|
||||
src = pkg;
|
||||
nativeBuildInputs = [ pkgs.imagemagick ];
|
||||
patchPhase = ''
|
||||
magick convert \
|
||||
-resize x16 \
|
||||
-gravity center \
|
||||
-crop 16x16+0+0 \
|
||||
-flatten \
|
||||
-colors 256 \
|
||||
'${favicon}' \
|
||||
${iconDir}/favicon-16x16.png
|
||||
|
||||
magick convert \
|
||||
-resize x32 \
|
||||
-gravity center \
|
||||
-crop 32x32+0+0 \
|
||||
-flatten \
|
||||
-colors 256 \
|
||||
'${favicon}' \
|
||||
${iconDir}/favicon-32x32.png
|
||||
|
||||
|
||||
magick convert \
|
||||
-resize x16 \
|
||||
-gravity center \
|
||||
-crop 16x16+0+0 \
|
||||
-flatten \
|
||||
-colors 256 \
|
||||
'${favicon}' \
|
||||
favicon-16x16.ico
|
||||
|
||||
magick convert \
|
||||
-resize x32 \
|
||||
-gravity center \
|
||||
-crop 32x32+0+0 \
|
||||
-flatten \
|
||||
-colors 256 \
|
||||
'${favicon}' \
|
||||
favicon-32x32.ico
|
||||
|
||||
magick convert \
|
||||
-resize x48 \
|
||||
-gravity center \
|
||||
-crop 48x48+0+0 \
|
||||
-flatten \
|
||||
-colors 256 \
|
||||
'${favicon}' \
|
||||
favicon-48x48.ico
|
||||
|
||||
magick convert favicon-16x16.ico favicon-32x32.ico favicon-48x48.ico ${faviconDir}/favicon.ico
|
||||
rm favicon-16x16.ico favicon-32x32.ico favicon-48x48.ico
|
||||
|
||||
cp '${favicon}' ${iconDir}/favicon.svg
|
||||
cp '${favicon}' ${iconDir}/safari-pinned-tab.svg
|
||||
|
||||
magick convert \
|
||||
'${favicon}' \
|
||||
-gravity center \
|
||||
-extent 630x350 \
|
||||
${faviconDir}/img/mobilizon_default_card.png
|
||||
|
||||
magick convert \
|
||||
-background '#e08c96' \
|
||||
'${logo}' \
|
||||
-resize 366x108 \
|
||||
${faviconDir}/img/mobilizon_logo.png
|
||||
|
||||
'' + nixpkgs.lib.concatMapStrings
|
||||
({ resize, filename }: ''
|
||||
magick convert \
|
||||
-resize x${resize} \
|
||||
'${favicon}' \
|
||||
${iconDir}/${filename}
|
||||
|
||||
'')
|
||||
[
|
||||
{ resize = "180"; filename = "apple-touch-icon.png"; }
|
||||
{ resize = "180"; filename = "apple-touch-icon-180x180.png"; }
|
||||
{ resize = "152"; filename = "apple-touch-icon-152x152.png"; }
|
||||
{ resize = "120"; filename = "apple-touch-icon-120x120.png"; }
|
||||
{ resize = "76"; filename = "apple-touch-icon-76x76.png"; }
|
||||
{ resize = "60"; filename = "apple-touch-icon-60x60.png"; }
|
||||
{ resize = "192"; filename = "android-chrome-192x192.png"; }
|
||||
{ resize = "512"; filename = "android-chrome-512x512.png"; }
|
||||
{ resize = "192"; filename = "android-chrome-maskable-192x192.png"; }
|
||||
{ resize = "512"; filename = "android-chrome-maskable-512x512.png"; }
|
||||
{ resize = "128"; filename = "badge-128x128.png"; }
|
||||
{ resize = "144"; filename = "icon-144x144.png"; }
|
||||
{ resize = "168"; filename = "icon-168x168.png"; }
|
||||
{ resize = "256"; filename = "icon-256x256.png"; }
|
||||
{ resize = "48"; filename = "icon-48x48.png"; }
|
||||
{ resize = "72"; filename = "icon-72x72.png"; }
|
||||
{ resize = "96"; filename = "icon-96x96.png"; }
|
||||
{ resize = "144"; filename = "msapplication-icon-144x144.png"; }
|
||||
{ resize = "150"; filename = "mstile-150x150.png"; }
|
||||
{ resize = "192"; filename = "android-chrome-192x192.png"; }
|
||||
{ resize = "512"; filename = "android-chrome-512x512.png"; }
|
||||
{ resize = "192"; filename = "android-chrome-maskable-192x192.png"; }
|
||||
{ resize = "512"; filename = "android-chrome-maskable-512x512.png"; }
|
||||
];
|
||||
|
||||
|
||||
installPhase = "cp -R ./ $out";
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue