feat: Create desktop item for appimage-run

Thanks @jtotnar for help with the tests
<https://discourse.nixos.org/t/how-to-test-desktop-item-mime-types/24510>!
This commit is contained in:
Victor Engmark 2023-01-08 11:31:32 +13:00
parent 0acc6df742
commit 73981dd9c2
2 changed files with 25 additions and 6 deletions

View File

@ -1,13 +1,29 @@
{ appimageTools, buildFHSUserEnv, extraPkgs ? pkgs: [], appimage-run-tests ? null }:
{ appimageTools, buildFHSUserEnv, makeDesktopItem, extraPkgs ? pkgs: [], appimage-run-tests ? null }:
let
fhsArgs = appimageTools.defaultFhsEnvArgs;
in buildFHSUserEnv (fhsArgs // {
name = "appimage-run";
fhsArgs = appimageTools.defaultFhsEnvArgs;
desktopItem = makeDesktopItem {
inherit name;
exec = name;
desktopName = name;
genericName = "AppImage runner";
noDisplay = true;
mimeTypes = ["application/vnd.appimage" "application/x-iso9660-appimage"];
categories = ["PackageManager" "Utility"];
};
in buildFHSUserEnv (fhsArgs // {
inherit name;
targetPkgs = pkgs: [ appimageTools.appimage-exec ]
++ fhsArgs.targetPkgs pkgs ++ extraPkgs pkgs;
runScript = "appimage-exec.sh";
extraInstallCommands = ''
cp --recursive "${desktopItem}/share" "$out/"
'';
passthru.tests.appimage-run = appimage-run-tests;
})

View File

@ -1,4 +1,4 @@
{ runCommand, fetchurl, appimage-run, glibcLocales, file }:
{ runCommand, fetchurl, appimage-run, glibcLocales, file, xdg-utils }:
let
# any AppImage usable on cli, really
sample-appImage = fetchurl {
@ -11,7 +11,7 @@ let
};
in
runCommand "appimage-run-tests" {
buildInputs = [ appimage-run glibcLocales file ];
buildInputs = [ appimage-run glibcLocales file xdg-utils ];
meta.platforms = [ "x86_64-linux" ];
}
''
@ -28,7 +28,10 @@ in
gunzip owdtest.AppImage.gz
appimage-run owdtest.AppImage
# Verify desktop entry
XDG_DATA_DIRS="${appimage-run}/share"
[[ "$(xdg-mime query default application/vnd.appimage)" == '${appimage-run.name}.desktop' ]]
set +x
touch $out
''