rework mobilizonLogosOverride, patch logos at build time now
This commit is contained in:
parent
e31bb5d615
commit
2527ea7764
41
flake.nix
41
flake.nix
|
@ -60,19 +60,16 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
lib = {
|
lib = {
|
||||||
# Patch the logos in a built Mobilizon package, so we don't have to do it in the source tree.
|
# Patch the logos in the source tree of a mobilizon-frontend package before building.
|
||||||
mobilizonPatchLogos = pkg: icons:
|
# Can be used to construct the argument for .overrideAttrs on mobilizon-frontend.
|
||||||
|
mobilizonLogosOverride = icons:
|
||||||
let
|
let
|
||||||
inherit (icons) logo favicon;
|
inherit (icons) logo favicon;
|
||||||
faviconDir = "./lib/mobilizon-${pkg.version}/priv/static";
|
|
||||||
iconDir = "${faviconDir}/img/icons";
|
|
||||||
in
|
in
|
||||||
pkgs.stdenvNoCC.mkDerivation {
|
old: {
|
||||||
inherit (pkg) name pname version;
|
nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ [ pkgs.imagemagick ];
|
||||||
src = pkg;
|
postPatch = ''
|
||||||
nativeBuildInputs = [ pkgs.imagemagick ];
|
cp '${logo}' src/assets/logo.svg
|
||||||
patchPhase = ''
|
|
||||||
cp '${logo}' ${faviconDir}/img/logo.svg
|
|
||||||
|
|
||||||
magick convert \
|
magick convert \
|
||||||
-resize x16 \
|
-resize x16 \
|
||||||
|
@ -81,7 +78,7 @@
|
||||||
-flatten \
|
-flatten \
|
||||||
-colors 256 \
|
-colors 256 \
|
||||||
'${favicon}' \
|
'${favicon}' \
|
||||||
${iconDir}/favicon-16x16.png
|
public/img/icons/favicon-16x16.png
|
||||||
|
|
||||||
magick convert \
|
magick convert \
|
||||||
-resize x32 \
|
-resize x32 \
|
||||||
|
@ -90,7 +87,7 @@
|
||||||
-flatten \
|
-flatten \
|
||||||
-colors 256 \
|
-colors 256 \
|
||||||
'${favicon}' \
|
'${favicon}' \
|
||||||
${iconDir}/favicon-32x32.png
|
public/img/icons/favicon-32x32.png
|
||||||
|
|
||||||
|
|
||||||
magick convert \
|
magick convert \
|
||||||
|
@ -120,30 +117,35 @@
|
||||||
'${favicon}' \
|
'${favicon}' \
|
||||||
favicon-48x48.ico
|
favicon-48x48.ico
|
||||||
|
|
||||||
magick convert favicon-16x16.ico favicon-32x32.ico favicon-48x48.ico ${faviconDir}/favicon.ico
|
magick convert \
|
||||||
|
favicon-16x16.ico \
|
||||||
|
favicon-32x32.ico \
|
||||||
|
favicon-48x48.ico \
|
||||||
|
public/favicon.ico
|
||||||
|
|
||||||
rm favicon-16x16.ico favicon-32x32.ico favicon-48x48.ico
|
rm favicon-16x16.ico favicon-32x32.ico favicon-48x48.ico
|
||||||
|
|
||||||
cp '${favicon}' ${iconDir}/favicon.svg
|
cp '${favicon}' public/img/icons/favicon.svg
|
||||||
cp '${favicon}' ${iconDir}/safari-pinned-tab.svg
|
cp '${favicon}' public/img/icons/safari-pinned-tab.svg
|
||||||
|
|
||||||
magick convert \
|
magick convert \
|
||||||
'${favicon}' \
|
'${favicon}' \
|
||||||
-gravity center \
|
-gravity center \
|
||||||
-extent 630x350 \
|
-extent 630x350 \
|
||||||
${faviconDir}/img/mobilizon_default_card.png
|
public/img/mobilizon_default_card.png
|
||||||
|
|
||||||
magick convert \
|
magick convert \
|
||||||
-background '#e08c96' \
|
-background '#e08c96' \
|
||||||
'${logo}' \
|
'${logo}' \
|
||||||
-resize 366x108 \
|
-resize 366x108 \
|
||||||
${faviconDir}/img/mobilizon_logo.png
|
public/img/mobilizon_logo.png
|
||||||
|
|
||||||
'' + nixpkgs.lib.concatMapStrings
|
'' + nixpkgs.lib.concatMapStrings
|
||||||
({ resize, filename }: ''
|
({ resize, filename }: ''
|
||||||
magick convert \
|
magick convert \
|
||||||
-resize x${resize} \
|
-resize x${resize} \
|
||||||
'${favicon}' \
|
'${favicon}' \
|
||||||
${iconDir}/${filename}
|
public/img/icons/${filename}
|
||||||
|
|
||||||
'')
|
'')
|
||||||
[
|
[
|
||||||
|
@ -171,9 +173,6 @@
|
||||||
{ resize = "192"; filename = "android-chrome-maskable-192x192.png"; }
|
{ resize = "192"; filename = "android-chrome-maskable-192x192.png"; }
|
||||||
{ resize = "512"; filename = "android-chrome-maskable-512x512.png"; }
|
{ resize = "512"; filename = "android-chrome-maskable-512x512.png"; }
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
installPhase = "cp -R ./ $out";
|
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue