Packaging/Icons: Difference between revisions

From NixOS Wiki
imported>Milahu
init
 
imported>Milahu
m use generic filename ${pname}.png
Line 26: Line 26:
     for i in 16 24 48 64 96 128 256 512; do
     for i in 16 24 48 64 96 128 256 512; do
       mkdir -p $out/share/icons/hicolor/''${i}x''${i}/apps
       mkdir -p $out/share/icons/hicolor/''${i}x''${i}/apps
       convert -background none -resize ''${i}x''${i} ${icon} $out/share/icons/hicolor/''${i}x''${i}/apps/scribus.png
       convert -background none -resize ''${i}x''${i} ${icon} $out/share/icons/hicolor/''${i}x''${i}/apps/${pname}.png
     done
     done
   '';
   '';
Line 32: Line 32:
}
}
</syntaxHighlight>
</syntaxHighlight>
Note: The icon filename contains the app name, here: <code>scribus.png</code>.


<code>-background none</code> will create transparent icons.
<code>-background none</code> will create transparent icons.
Alternative: <code>-background white</code>.
Alternative: <code>-background white</code>.

Revision as of 12:14, 11 June 2023

Application icons

Application icons should be installed to $out/share/icons/hicolor.

Example code for the scribus app:

{ lib
, stdenv
, fetchurl
}:

let
  icon = fetchurl {
    url = "https://gist.githubusercontent.com/ejpcmac/a74b762026c9bc4000be624c3d085517/raw/18edc497c5cb6fdeef1c8aede37a0ee68413f9d3/scribus-icon-centered.svg";
    sha256 = "0hq3i7c2l50445an9glhhg47kj26y16svfajc6naqn307ph9vzc3";
  };
in

stdenv.mkDerivation rec {
  pname = "scribus";

  # ...

  postInstall = ''
    for i in 16 24 48 64 96 128 256 512; do
      mkdir -p $out/share/icons/hicolor/''${i}x''${i}/apps
      convert -background none -resize ''${i}x''${i} ${icon} $out/share/icons/hicolor/''${i}x''${i}/apps/${pname}.png
    done
  '';

}

-background none will create transparent icons. Alternative: -background white.