Merge pull request #75729 from worldofpeace/validate-makeDesktopItem

makeDesktopItem: add desktop file validation
This commit is contained in:
worldofpeace 2020-03-30 14:27:40 -04:00 committed by GitHub
commit dcf6e71d73
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 3 deletions

View File

@ -1,4 +1,5 @@
{ lib, runCommandLocal }: { lib, runCommandLocal, desktop-file-utils }:
{ name { name
, type ? "Application" , type ? "Application"
, exec , exec
@ -11,6 +12,7 @@
, categories ? "Application;Other;" , categories ? "Application;Other;"
, startupNotify ? null , startupNotify ? null
, extraEntries ? null , extraEntries ? null
, fileValidation ? true # whether to validate resulting desktop file.
}: }:
let let
@ -28,8 +30,8 @@ let
in in
runCommandLocal "${name}.desktop" {} runCommandLocal "${name}.desktop" {}
'' ''
mkdir -p $out/share/applications mkdir -p "$out/share/applications"
cat > $out/share/applications/${name}.desktop <<EOF cat > "$out/share/applications/${name}.desktop" <<EOF
[Desktop Entry] [Desktop Entry]
Type=${type} Type=${type}
Exec=${exec} Exec=${exec}
@ -40,4 +42,9 @@ runCommandLocal "${name}.desktop" {}
${if extraEntries == null then ''EOF'' else '' ${if extraEntries == null then ''EOF'' else ''
${extraEntries} ${extraEntries}
EOF''} EOF''}
${lib.optionalString fileValidation ''
echo "Running desktop-file validation"
${desktop-file-utils}/bin/desktop-file-validate "$out/share/applications/${name}.desktop"
''}
'' ''