nixos下使用appimage软件包

nixos 不能直接运行appimage,需要封装以下 使用 appimageTools 来运行 以hiddify和balenaEtcher为例

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
{ pkgs, ... }:
# ./hiddify: error while loading shared libraries: libepoxy.so.0: cannot open shared object file: No such file or directory

{ config, pkgs,nur, ... }:
let
  hiddify_pkg = with pkgs; appimageTools.wrapType2
    ({
      # or wrapType1 wrapType2  : file -k  XXXXX.AppImage
      name = "hiddify";
      src = fetchurl {
        sha256 = "sha256-T4BWxhJ7q13KE1rvvFsnXhs2XVEmNkFTJbJ4e8PCg+0=";
        url = "https://mirror.ghproxy.com/https://github.com/hiddify/hiddify-next/releases/download/v1.1.1/Hiddify-Linux-x64.AppImage";
      };
      extraPkgs = pkgs: with pkgs; [ libepoxy ];
    });
  icons=../../staticFile/icons/hiddify.png;
in
{
  home.packages = with pkgs; [
    hiddify_pkg 
  ];

  home.file = {
    ".local/share/applications/Hiddify-next.desktop".text = ''
    [Desktop Entry]
    Version=1.1.1
    Type=Application
    Name=Hiddify
    Exec=hiddify
    Icon=${icons}
    StartupWMClass=hiddify
    StartupNotify=true
    '';
  };
}
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# https://discourse.nixos.org/t/how-ro-run-a-appimage-with-electron/41756?u=joyanhui
{ config, pkgs, nur, ... }:
let
  balenaEtcher_pkg = with pkgs; appimageTools.wrapType2
    ({
      name = "balenaEtcher";
      src = fetchurl {
        sha256 = "sha256-+Hu70UOcmLX4dPOYEBA2adBdX/C8Ryp/17bvi+jUfVA=";
        url = "https://mirror.ghproxy.com/https://github.com/balena-io/etcher/releases/download/v1.18.11/balenaEtcher-1.18.11-x64.AppImage";
      };
      extraPkgs = pkgs: with pkgs; [ ];
    });
  icons = ../../staticFile/icons/balenaEtcher.png;
in
{
  home.packages = with pkgs; [
    balenaEtcher_pkg
  ];
  # --in-process-gpu to fix it. --no-sandbox disable every sandbox security
  # https://www.reddit.com/r/archlinux/comments/xf5pkt/comment/j3wf4gq/
  home.file = {
    ".local/share/applications/balenaEtcher.desktop".text = ''
      [Desktop Entry]
      Version=1.18.11
      Type=Application
      Name=balenaEtcher
      Exec=balenaEtcher --in-process-gpu
      Icon=${icons}
      StartupWMClass=AppRun
    '';
  };

}
Licensed under CC BY-NC-SA 4.0
comments powered by Disqus
使用 Hugo 构建
主题 StackJimmy 设计