From f1019f971971bdf392ac5eb59a3a6854309a1007 Mon Sep 17 00:00:00 2001 From: jopejoe1 Date: Tue, 12 Mar 2024 23:13:01 +0100 Subject: [PATCH] nixos/appimage: init --- .../manual/release-notes/rl-2405.section.md | 2 ++ nixos/modules/module-list.nix | 1 + nixos/modules/programs/appimage.nix | 33 +++++++++++++++++++ 3 files changed, 36 insertions(+) create mode 100644 nixos/modules/programs/appimage.nix diff --git a/nixos/doc/manual/release-notes/rl-2405.section.md b/nixos/doc/manual/release-notes/rl-2405.section.md index 0905337de94d..035d5db7d021 100644 --- a/nixos/doc/manual/release-notes/rl-2405.section.md +++ b/nixos/doc/manual/release-notes/rl-2405.section.md @@ -103,6 +103,8 @@ The pre-existing [services.ankisyncd](#opt-services.ankisyncd.enable) has been m - [TuxClocker](https://github.com/Lurkki14/tuxclocker), a hardware control and monitoring program. Available as [programs.tuxclocker](#opt-programs.tuxclocker.enable). +- binfmt option for AppImage-run to support running [AppImage](https://appimage.org/)'s seamlessly on NixOS.. Available as [programs.appimage.binfmt](#opt-programs.appimage.binfmt). + - [ALVR](https://github.com/alvr-org/alvr), a VR desktop streamer. Available as [programs.alvr](#opt-programs.alvr.enable) - [RustDesk](https://rustdesk.com), a full-featured open source remote control alternative for self-hosting and security with minimal configuration. Alternative to TeamViewer. diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index 41e369ac1c65..0e6e125bdef9 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -142,6 +142,7 @@ ./programs/adb.nix ./programs/alvr.nix ./programs/appgate-sdp.nix + ./programs/appimage.nix ./programs/atop.nix ./programs/ausweisapp.nix ./programs/autojump.nix diff --git a/nixos/modules/programs/appimage.nix b/nixos/modules/programs/appimage.nix new file mode 100644 index 000000000000..0011c2ff578d --- /dev/null +++ b/nixos/modules/programs/appimage.nix @@ -0,0 +1,33 @@ +{ 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.appimage = lib.mkIf cfg.binfmt { + wrapInterpreterInShell = false; + interpreter = lib.getExe cfg.package; + recognitionType = "magic"; + offset = 0; + mask = ''\xff\xff\xff\xff\x00\x00\x00\x00\xff\xff\xff''; + magicOrExtension = ''\x7fELF....AI\x02''; + }; + environment.systemPackages = [ cfg.package ]; + }; + + meta.maintainers = with lib.maintainers; [ jopejoe1 atemu ]; +}