make-desktopitem: desktop-file-utils is a nativeBuildInput

This fixes cross-compilation of a NixOS with the manual enabled.
This commit is contained in:
Florian Klink 2020-11-27 01:16:24 +01:00
parent bd1de18f6c
commit ae5764621d

View file

@ -12,16 +12,16 @@
, mimeType ? null , mimeType ? null
, categories ? null , categories ? null
, startupNotify ? null , startupNotify ? null
, extraDesktopEntries ? {} # Extra key-value pairs to add to the [Desktop Entry] section. This may override other values , extraDesktopEntries ? { } # Extra key-value pairs to add to the [Desktop Entry] section. This may override other values
, extraEntries ? "" # Extra configuration. Will be appended to the end of the file and may thus contain extra sections , extraEntries ? "" # Extra configuration. Will be appended to the end of the file and may thus contain extra sections
, fileValidation ? true # whether to validate resulting desktop file. , fileValidation ? true # whether to validate resulting desktop file.
}: }:
let let
# like builtins.toString, but null -> null instead of null -> "" # like builtins.toString, but null -> null instead of null -> ""
nullableToString = value: if value == null then null nullableToString = value:
else if builtins.isBool value then lib.boolToString value if value == null then null
else builtins.toString value; else if builtins.isBool value then lib.boolToString value
else builtins.toString value;
# The [Desktop entry] section of the desktop file, as attribute set. # The [Desktop entry] section of the desktop file, as attribute set.
mainSection = { mainSection = {
@ -39,16 +39,19 @@ let
# Map all entries to a list of lines # Map all entries to a list of lines
desktopFileStrings = desktopFileStrings =
["[Desktop Entry]"] [ "[Desktop Entry]" ]
++ builtins.filter ++ builtins.filter
(v: v != null) (v: v != null)
(lib.mapAttrsToList (lib.mapAttrsToList
(name: value: if value != null then "${name}=${value}" else null) (name: value: if value != null then "${name}=${value}" else null)
mainSection mainSection
) )
++ (if extraEntries == "" then [] else ["${extraEntries}"]); ++ (if extraEntries == "" then [ ] else [ "${extraEntries}" ]);
in in
runCommandLocal "${name}.desktop" {} runCommandLocal "${name}.desktop"
{
nativeBuildInputs = [ desktop-file-utils ];
}
('' (''
mkdir -p "$out/share/applications" mkdir -p "$out/share/applications"
cat > "$out/share/applications/${name}.desktop" <<EOF cat > "$out/share/applications/${name}.desktop" <<EOF
@ -56,5 +59,5 @@ runCommandLocal "${name}.desktop" {}
EOF EOF
'' + lib.optionalString fileValidation '' '' + lib.optionalString fileValidation ''
echo "Running desktop-file validation" echo "Running desktop-file validation"
${desktop-file-utils}/bin/desktop-file-validate "$out/share/applications/${name}.desktop" desktop-file-validate "$out/share/applications/${name}.desktop"
'') '')