summaryrefslogtreecommitdiffstats
path: root/nixos/modules/programs/appimage.nix
blob: 4662a6c3d8cc7478862c0913eabffb8b6226153c (plain)
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
{
  lib,
  config,
  pkgs,
  ...
}:

let
  cfg = config.programs.appimage;
in

{
  options.programs.appimage = {
    enable = lib.mkEnableOption "appimage-run wrapper script for executing appimages on NixOS";
    binfmt = lib.mkEnableOption "binfmt registration to run appimages via appimage-run seamlessly";
    package = lib.mkPackageOption pkgs "appimage-run" {
      example = ''
        pkgs.appimage-run.override {
          extraPkgs = pkgs: [ pkgs.ffmpeg pkgs.imagemagick ];
        }
      '';
    };
  };

  config = lib.mkIf cfg.enable {
    boot.binfmt.registrations = lib.mkIf cfg.binfmt (
      let
        appimage_common = {
          wrapInterpreterInShell = false;
          interpreter = lib.getExe cfg.package;
          recognitionType = "magic";
          offset = 0;
          mask = ''\xff\xff\xff\xff\x00\x00\x00\x00\xff\xff\xff'';
        };
      in
      {
        appimage_type_1 = appimage_common // {
          magicOrExtension = ''\x7fELF....AI\x01'';
        };
        appimage_type_2 = appimage_common // {
          magicOrExtension = ''\x7fELF....AI\x02'';
        };
      }
    );
    environment.systemPackages = [ cfg.package ];

    programs.fuse.enable = true;
  };

  meta.maintainers = with lib.maintainers; [
    jopejoe1
    atemu
    aleksana
  ];
}