Jump to content

Appimage/ja: Difference between revisions

From Official NixOS Wiki
FuzzyBot (talk | contribs)
Updating to match new version of source page
FuzzyBot (talk | contribs)
Updating to match new version of source page
Tags: Mobile edit Mobile web edit
 
(13 intermediate revisions by 2 users not shown)
Line 2: Line 2:
<div lang="en" dir="ltr" class="mw-content-ltr">
<div lang="en" dir="ltr" class="mw-content-ltr">
[https://appimage.org/ AppImage] is a monolithic packaging format for linux applications. It contains all dependencies in one file that is composed of an executable with a tacked on filesystem.
[https://appimage.org/ AppImage] is a monolithic packaging format for linux applications. It contains all dependencies in one file that is composed of an executable with a tacked on filesystem.
</div>
<span id="Usage"></span>
== 使い方 ==
<span id="Run"></span>
=== 実行 ===
ほとんどのLinuxディストリビューションでは、<code>.AppImage</code>ファイルをダウンロードし、それを実行可能ファイル<code>chmod +x $AppImage</code>にして実行するだけです。ただし、AppImageファイルは通常(常にではないにしても)ハードコードされたパス内の特定のシステムライブラリに依存するため、NixOSではそのままでは機能しません。
<syntaxhighlight lang="shell">
$ nix-shell -p appimage-run
$ appimage-run path/to/application.AppImage
</syntaxhighlight>
<div lang="en" dir="ltr" class="mw-content-ltr">
===== Appimage apps cannot access host fonts, icons and themes =====
</div>
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
<div lang="en" dir="ltr" class="mw-content-ltr">
== Usage ==
See: [[Fixes for non-Nix applications#Flatpak, Distrobox, Appimage and other non-Nix applications can't find system fonts/icons/themes]]
</div>
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
<div lang="en" dir="ltr" class="mw-content-ltr">
=== Run ===
===== Additional Packages =====
</div>
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
<div lang="en" dir="ltr" class="mw-content-ltr">
On most distros, all one has to do is download the <code>.AppImage</code> file, make it executable <code>chmod +x $AppImage</code>, and execute it. This doesn't work in NixOS out of the box though, as AppImage files usually (if not always) depend on certain system libraries in hardcoded paths.
Some appimages still have issues, so you can override for additional pkgs such as
</div>
</div>


<syntaxhighlight lang="shell">
<syntaxhighlight lang="nix">programs.appimage.enable = true;
$ nix-shell -p appimage-run
programs.appimage.binfmt = true;
$ appimage-run $AppImageFile
programs.appimage.package = pkgs.appimage-run.override
{
  extraPkgs = pkgs:
  [
    pkgs.icu
    pkgs.libxcrypt-legacy
    pkgs.python312
    pkgs.python312Packages.torch
  ];
};
</syntaxhighlight>
</syntaxhighlight>
<div lang="en" dir="ltr" class="mw-content-ltr">
 
=== Packaging ===
<span id="Packaging"></span>
=== パッケージング ===
 
<div class="mw-translate-fuzzy">
[https://nixos.org/manual/nixpkgs/stable/#sec-pkgs-appimageTools nixpkgs manual on wrapping AppImage packages]を参照してください。要するに、AppImageが抽出され、依存関係がnixビルド依存関係として追加されます。
次の例は、AppImageとしても配布されているプログラム、Qubaの派生です。
</div>
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
<syntaxhighlight lang="nix">
See the [https://nixos.org/manual/nixpkgs/stable/#sec-pkgs-appimageTools nixpkgs manual on wrapping AppImage packages]. In short, the AppImage is extracted and any dependencies are added as nix build dependencies.
Following example is a derivation for the program Quba, which is also distributed as AppImage.<syntaxhighlight lang="nix">
{
{
   lib,
   lib,
Line 32: Line 61:
   fetchurl,
   fetchurl,
}:
}:
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
let
let
   version = "1.4.0";
   version = "1.4.0";
   pname = "quba";
   pname = "quba";
  name = "${pname}-${version}";
</div>


   <div lang="en" dir="ltr" class="mw-content-ltr">
   src = fetchurl {
src = fetchurl {
     url = "https://github.com/ZUGFeRD/quba-viewer/releases/download/v${version}/Quba-${version}.AppImage";
     url = "https://github.com/ZUGFeRD/quba-viewer/releases/download/v${version}/Quba-${version}.AppImage";
     hash = "sha256-EsTF7W1np5qbQQh3pdqsFe32olvGK3AowGWjqHPEfoM=";
     hash = "sha256-EsTF7W1np5qbQQh3pdqsFe32olvGK3AowGWjqHPEfoM=";
   };
   };
</div>


   <div lang="en" dir="ltr" class="mw-content-ltr">
   appimageContents = appimageTools.extractType1 { inherit name src; };
appimageContents = appimageTools.extractType1 { inherit name src; };
in
in
appimageTools.wrapType1 {
appimageTools.wrapType2 rec {
   inherit name src;
   inherit pname version src;
</div>


   <div lang="en" dir="ltr" class="mw-content-ltr">
   extraInstallCommands = ''
extraInstallCommands = ''
    mv $out/bin/${name} $out/bin/${pname}
    install -m 444 -D ${appimageContents}/${pname}.desktop -t $out/share/applications
     substituteInPlace $out/share/applications/${pname}.desktop \
     substituteInPlace $out/share/applications/${pname}.desktop \
       --replace-fail 'Exec=AppRun' 'Exec=${pname}'
       --replace-fail 'Exec=AppRun' 'Exec=${meta.mainProgram}'
    cp -r ${appimageContents}/usr/share/icons $out/share
   '';
   '';
</div>


   <div lang="en" dir="ltr" class="mw-content-ltr">
   meta = {
meta = {
     description = "Viewer for electronic invoices";
     description = "Viewer for electronic invoices";
     homepage = "https://github.com/ZUGFeRD/quba-viewer";
     homepage = "https://github.com/ZUGFeRD/quba-viewer";
Line 77: Line 92:
}
}
</syntaxhighlight>
</syntaxhighlight>
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
== Configuration ==
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
<span id="Configuration"></span>
=== Register AppImage files as a binary type to binfmt_misc ===
== 設定 ==
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
<span id="Register_AppImage_files_as_a_binary_type_to_binfmt_misc"></span>
You can tell the Linux kernel to use an interpreter (e.g. <code>appimage-run</code>) when executing certain binary files through the use of [https://en.wikipedia.org/wiki/Binfmt_misc#External_links binfmt_misc], either by filename extension or magic number matching. Below NixOS configuration registers AppImage files (ELF files with magic number "AI" + 0x02) to be run with <code>appimage-run</code> as interpreter.
=== AppImageファイルタイプをバイナリタイプとしてbinfmt_miscに登録する ===
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
<div lang="en" dir="ltr" class="mw-content-ltr">
Since [https://nixos.org/manual/nixos/stable/release-notes#sec-release-24.05-new-services NixOS 24.05], there is a binfmt option:
You can tell the [[Linux kernel]] to use an interpreter (e.g. <code>appimage-run</code>) when executing certain binary files through the use of [https://en.wikipedia.org/wiki/Binfmt_misc#External_links binfmt_misc], either by filename extension or magic number matching. Below NixOS configuration registers AppImage files (ELF files with magic number "AI" + 0x02) to be run with <code>appimage-run</code> as interpreter:
</div>
</div>


Line 102: Line 111:
</syntaxhighlight>
</syntaxhighlight>


<div lang="en" dir="ltr" class="mw-content-ltr">
<div class="mw-translate-fuzzy">
This way AppImage files can be invoked directly as if they were normal programs
この方法では、AppImageファイルを通常のプログラムのように直接呼び出すことができます。
</div>
</div>


[[Category:Software{{#translation:}}]]
[[Category:Software]]

Latest revision as of 18:51, 15 August 2026

AppImage is a monolithic packaging format for linux applications. It contains all dependencies in one file that is composed of an executable with a tacked on filesystem.

使い方

実行

ほとんどのLinuxディストリビューションでは、.AppImageファイルをダウンロードし、それを実行可能ファイルchmod +x $AppImageにして実行するだけです。ただし、AppImageファイルは通常(常にではないにしても)ハードコードされたパス内の特定のシステムライブラリに依存するため、NixOSではそのままでは機能しません。

$ nix-shell -p appimage-run
$ appimage-run path/to/application.AppImage
Appimage apps cannot access host fonts, icons and themes
Additional Packages

Some appimages still have issues, so you can override for additional pkgs such as

programs.appimage.enable = true;
programs.appimage.binfmt = true;
programs.appimage.package = pkgs.appimage-run.override 
{
  extraPkgs = pkgs: 
  [
    pkgs.icu
    pkgs.libxcrypt-legacy
    pkgs.python312
    pkgs.python312Packages.torch
  ]; 
};

パッケージング

nixpkgs manual on wrapping AppImage packagesを参照してください。要するに、AppImageが抽出され、依存関係がnixビルド依存関係として追加されます。 次の例は、AppImageとしても配布されているプログラム、Qubaの派生です。

{
  lib,
  appimageTools,
  fetchurl,
}:

let
  version = "1.4.0";
  pname = "quba";

  src = fetchurl {
    url = "https://github.com/ZUGFeRD/quba-viewer/releases/download/v${version}/Quba-${version}.AppImage";
    hash = "sha256-EsTF7W1np5qbQQh3pdqsFe32olvGK3AowGWjqHPEfoM=";
  };

  appimageContents = appimageTools.extractType1 { inherit name src; };
in
appimageTools.wrapType2 rec {
  inherit pname version src;

  extraInstallCommands = ''
    substituteInPlace $out/share/applications/${pname}.desktop \
      --replace-fail 'Exec=AppRun' 'Exec=${meta.mainProgram}'
  '';

  meta = {
    description = "Viewer for electronic invoices";
    homepage = "https://github.com/ZUGFeRD/quba-viewer";
    downloadPage = "https://github.com/ZUGFeRD/quba-viewer/releases";
    license = lib.licenses.asl20;
    sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
    maintainers = with lib.maintainers; [ onny ];
    platforms = [ "x86_64-linux" ];
  };
}


設定

AppImageファイルタイプをバイナリタイプとしてbinfmt_miscに登録する

You can tell the Linux kernel to use an interpreter (e.g. appimage-run) when executing certain binary files through the use of binfmt_misc, either by filename extension or magic number matching. Below NixOS configuration registers AppImage files (ELF files with magic number "AI" + 0x02) to be run with appimage-run as interpreter:

programs.appimage = {
  enable = true;
  binfmt = true;
};

この方法では、AppImageファイルを通常のプログラムのように直接呼び出すことができます。