Jump to content

Packaging/Icons/zh: Difference between revisions

From NixOS Wiki
Weijia (talk | contribs)
Created page with "<code>-background none</code> 将创建透明图标。替代方案<code>-background white</code>。"
Weijia (talk | contribs)
Created page with "=== 另见 ==="
Tags: Mobile edit Mobile web edit
Line 41: Line 41:
<code>-background none</code> 将创建透明图标。替代方案<code>-background white</code>。
<code>-background none</code> 将创建透明图标。替代方案<code>-background white</code>。


<div lang="en" dir="ltr" class="mw-content-ltr">
<span id="See_also"></span>
=== See also ===
=== 另见 ===
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
<div lang="en" dir="ltr" class="mw-content-ltr">
Another example handling icons [https://github.com/NixOS/nixpkgs/blob/6d8e9b4f6197f7ce5106069f13debfc8e9b1fa8b/pkgs/applications/misc/obsidian/default.nix#L62 obsidian].
Another example handling icons [https://github.com/NixOS/nixpkgs/blob/6d8e9b4f6197f7ce5106069f13debfc8e9b1fa8b/pkgs/applications/misc/obsidian/default.nix#L62 obsidian].
</div>
</div>

Revision as of 18:57, 28 August 2025

应用图标

应用图标应该被安装于 $out/share/icons/hicolor

现已过时的 scribus v1.4 应用程序的示例代码:

{ lib
, stdenv
, fetchurl
, imagemagick
}:

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

stdenv.mkDerivation rec {
  pname = "scribus";

  nativeBuildInputs = [
    imagemagick # convert
  ];

  # ...

  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 将创建透明图标。替代方案-background white

另见

Another example handling icons obsidian.