summary refs log tree commit diff
path: root/pkgs/build-support/make-desktopitem
diff options
context:
space:
mode:
authorLaverne Schrock <laverne@schrock.email>2016-11-21 18:43:03 -0600
committerLaverne Schrock <laverne@schrock.email>2017-06-05 21:55:23 -0500
commitf099df3c80e589cd68a000af2e5fdceaf670bdd4 (patch)
tree56329f6d14854ecce4f2c56a39412d38a0e18823 /pkgs/build-support/make-desktopitem
parentd1d9186b6bdca641592b8eb4594ce90cd8d1e0f4 (diff)
downloadnixpkgs-f099df3c80e589cd68a000af2e5fdceaf670bdd4.tar
nixpkgs-f099df3c80e589cd68a000af2e5fdceaf670bdd4.tar.gz
nixpkgs-f099df3c80e589cd68a000af2e5fdceaf670bdd4.tar.bz2
nixpkgs-f099df3c80e589cd68a000af2e5fdceaf670bdd4.tar.lz
nixpkgs-f099df3c80e589cd68a000af2e5fdceaf670bdd4.tar.xz
nixpkgs-f099df3c80e589cd68a000af2e5fdceaf670bdd4.tar.zst
nixpkgs-f099df3c80e589cd68a000af2e5fdceaf670bdd4.zip
make-desktopitem: make genericName optional
Diffstat (limited to 'pkgs/build-support/make-desktopitem')
-rw-r--r--pkgs/build-support/make-desktopitem/default.nix38
1 files 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 <<EOF
     [Desktop Entry]
     Type=${type}
     Exec=${exec}
-    Icon=${icon}
-    Comment=${comment}
     Terminal=${terminal}
     Name=${desktopName}
-    GenericName=${genericName}
-    MimeType=${mimeType}
     Categories=${categories}
+    ${optionalEntriesString}
+    ${if extraEntries == null then ''EOF'' else ''
     ${extraEntries}
-    ${if startupNotify == null then ''EOF'' else ''
-    StartupNotify=${startupNotify}
     EOF''}
   '';
 }