From 0acc6df7423fc042f29a0df8a3c39249b2e901e9 Mon Sep 17 00:00:00 2001 From: Victor Engmark Date: Sun, 8 Jan 2023 11:14:31 +1300 Subject: [PATCH 1/2] refactor: Add spacing around tests --- pkgs/tools/package-management/appimage-run/test.nix | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkgs/tools/package-management/appimage-run/test.nix b/pkgs/tools/package-management/appimage-run/test.nix index 34c5ab777268..ff511a53f5e1 100644 --- a/pkgs/tools/package-management/appimage-run/test.nix +++ b/pkgs/tools/package-management/appimage-run/test.nix @@ -17,14 +17,17 @@ in '' export HOME=$(mktemp -d) set -x + # regression test for #101137, must come first LANG=fr_FR appimage-run ${sample-appImage} --list ${sample-appImage} + # regression test for #108426 cp ${sample-appImage} foo.appImage LANG=fr_FR appimage-run ${sample-appImage} --list foo.appImage cp ${owdtest} owdtest.AppImage.gz gunzip owdtest.AppImage.gz appimage-run owdtest.AppImage + set +x touch $out '' From 73981dd9c24d3b7529c12ea83c4d59c1377a2b99 Mon Sep 17 00:00:00 2001 From: Victor Engmark Date: Sun, 8 Jan 2023 11:31:32 +1300 Subject: [PATCH 2/2] feat: Create desktop item for `appimage-run` Thanks @jtotnar for help with the tests ! --- .../appimage-run/default.nix | 22 ++++++++++++++++--- .../package-management/appimage-run/test.nix | 9 +++++--- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/pkgs/tools/package-management/appimage-run/default.nix b/pkgs/tools/package-management/appimage-run/default.nix index 98a04dff8f89..0595f2ea99f8 100644 --- a/pkgs/tools/package-management/appimage-run/default.nix +++ b/pkgs/tools/package-management/appimage-run/default.nix @@ -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; }) diff --git a/pkgs/tools/package-management/appimage-run/test.nix b/pkgs/tools/package-management/appimage-run/test.nix index ff511a53f5e1..8a6e27095123 100644 --- a/pkgs/tools/package-management/appimage-run/test.nix +++ b/pkgs/tools/package-management/appimage-run/test.nix @@ -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 '' -