forked from potsda.mn/mobilizon
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 = {
|
||||
# Patch the logos in a built Mobilizon package, so we don't have to do it in the source tree.
|
||||
mobilizonPatchLogos = pkg: icons:
|
||||
# Patch the logos in the source tree of a mobilizon-frontend package before building.
|
||||
# Can be used to construct the argument for .overrideAttrs on mobilizon-frontend.
|
||||
mobilizonLogosOverride = 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 = ''
|
||||
cp '${logo}' ${faviconDir}/img/logo.svg
|
||||
old: {
|
||||
nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ [ pkgs.imagemagick ];
|
||||
postPatch = ''
|
||||
cp '${logo}' src/assets/logo.svg
|
||||
|
||||
magick convert \
|
||||
-resize x16 \
|
||||
|
@ -81,7 +78,7 @@
|
|||
-flatten \
|
||||
-colors 256 \
|
||||
'${favicon}' \
|
||||
${iconDir}/favicon-16x16.png
|
||||
public/img/icons/favicon-16x16.png
|
||||
|
||||
magick convert \
|
||||
-resize x32 \
|
||||
|
@ -90,7 +87,7 @@
|
|||
-flatten \
|
||||
-colors 256 \
|
||||
'${favicon}' \
|
||||
${iconDir}/favicon-32x32.png
|
||||
public/img/icons/favicon-32x32.png
|
||||
|
||||
|
||||
magick convert \
|
||||
|
@ -120,30 +117,35 @@
|
|||
'${favicon}' \
|
||||
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
|
||||
|
||||
cp '${favicon}' ${iconDir}/favicon.svg
|
||||
cp '${favicon}' ${iconDir}/safari-pinned-tab.svg
|
||||
cp '${favicon}' public/img/icons/favicon.svg
|
||||
cp '${favicon}' public/img/icons/safari-pinned-tab.svg
|
||||
|
||||
magick convert \
|
||||
'${favicon}' \
|
||||
-gravity center \
|
||||
-extent 630x350 \
|
||||
${faviconDir}/img/mobilizon_default_card.png
|
||||
public/img/mobilizon_default_card.png
|
||||
|
||||
magick convert \
|
||||
-background '#e08c96' \
|
||||
'${logo}' \
|
||||
-resize 366x108 \
|
||||
${faviconDir}/img/mobilizon_logo.png
|
||||
public/img/mobilizon_logo.png
|
||||
|
||||
'' + nixpkgs.lib.concatMapStrings
|
||||
({ resize, filename }: ''
|
||||
magick convert \
|
||||
-resize x${resize} \
|
||||
'${favicon}' \
|
||||
${iconDir}/${filename}
|
||||
public/img/icons/${filename}
|
||||
|
||||
'')
|
||||
[
|
||||
|
@ -171,9 +173,6 @@
|
|||
{ 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