1{
2 lib,
3 config,
4 pkgs,
5 ...
6}:
7
8let
9 cfg = config.programs.appimage;
10in
11
12{
13 options.programs.appimage = {
14 enable = lib.mkEnableOption "appimage-run wrapper script for executing appimages on NixOS";
15 binfmt = lib.mkEnableOption "binfmt registration to run appimages via appimage-run seamlessly";
16 package = lib.mkPackageOption pkgs "appimage-run" {
17 example = ''
18 pkgs.appimage-run.override {
19 extraPkgs = pkgs: [ pkgs.ffmpeg pkgs.imagemagick ];
20 }
21 '';
22 };
23 };
24
25 config = lib.mkIf cfg.enable {
26 boot.binfmt.registrations = lib.mkIf cfg.binfmt (
27 let
28 appimage_common = {
29 wrapInterpreterInShell = false;
30 interpreter = lib.getExe cfg.package;
31 recognitionType = "magic";
32 offset = 0;
33 mask = ''\xff\xff\xff\xff\x00\x00\x00\x00\xff\xff\xff'';
34 };
35 in
36 {
37 appimage_type_1 = appimage_common // {
38 magicOrExtension = ''\x7fELF....AI\x01'';
39 };
40 appimage_type_2 = appimage_common // {
41 magicOrExtension = ''\x7fELF....AI\x02'';
42 };
43 }
44 );
45 environment.systemPackages = [ cfg.package ];
46 };
47
48 meta.maintainers = with lib.maintainers; [
49 jopejoe1
50 atemu
51 aleksana
52 ];
53}