From f099df3c80e589cd68a000af2e5fdceaf670bdd4 Mon Sep 17 00:00:00 2001 From: Laverne Schrock Date: Mon, 21 Nov 2016 18:43:03 -0600 Subject: [PATCH] make-desktopitem: make genericName optional --- .../make-desktopitem/default.nix | 38 ++++++++++++------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/pkgs/build-support/make-desktopitem/default.nix b/pkgs/build-support/make-desktopitem/default.nix index f5b4e5af93a..f8c31ed5c1d 100644 --- a/pkgs/build-support/make-desktopitem/default.nix +++ b/pkgs/build-support/make-desktopitem/default.nix @@ -1,36 +1,48 @@ -{stdenv}: +{stdenv, lib}: { name , type ? "Application" , exec -, icon ? "" -, comment ? "" +, icon ? null +, comment ? null , terminal ? "false" , desktopName -, genericName -, mimeType ? "" +, genericName ? null +, mimeType ? null , categories ? "Application;Other;" , startupNotify ? null -, extraEntries ? "" +, extraEntries ? null }: stdenv.mkDerivation { name = "${name}.desktop"; - buildCommand = '' + + buildCommand = let + + optionalEntriesList = [{k="Icon"; v=icon;} + {k="Comment"; v=comment;} + {k="GenericName"; v=genericName;} + {k="MimeType"; v=mimeType;} + {k="StartupNotify"; v=startupNotify;}]; + + valueNotNull = {k, v}: v != null; + entriesToKeep = builtins.filter valueNotNull optionalEntriesList; + + mkEntry = {k, v}: k + "=" + v; + optionalEntriesString = lib.concatMapStringsSep "\n" mkEntry entriesToKeep; + + in + '' mkdir -p $out/share/applications cat > $out/share/applications/${name}.desktop <