2019-12-04 21:19:21 +00:00
|
|
|
{ lib, runCommandLocal }:
|
2009-05-10 13:03:53 +01:00
|
|
|
{ name
|
|
|
|
, type ? "Application"
|
|
|
|
, exec
|
2016-11-22 00:43:03 +00:00
|
|
|
, icon ? null
|
|
|
|
, comment ? null
|
2009-05-10 13:03:53 +01:00
|
|
|
, terminal ? "false"
|
|
|
|
, desktopName
|
2016-11-22 00:43:03 +00:00
|
|
|
, genericName ? null
|
|
|
|
, mimeType ? null
|
2009-05-10 13:03:53 +01:00
|
|
|
, categories ? "Application;Other;"
|
2015-12-12 23:25:56 +00:00
|
|
|
, startupNotify ? null
|
2016-11-22 00:43:03 +00:00
|
|
|
, extraEntries ? null
|
2009-05-10 13:03:53 +01:00
|
|
|
}:
|
|
|
|
|
2019-12-04 21:19:21 +00:00
|
|
|
let
|
|
|
|
optionalEntriesList = [{k="Icon"; v=icon;}
|
|
|
|
{k="Comment"; v=comment;}
|
|
|
|
{k="GenericName"; v=genericName;}
|
|
|
|
{k="MimeType"; v=mimeType;}
|
|
|
|
{k="StartupNotify"; v=startupNotify;}];
|
2016-11-22 00:43:03 +00:00
|
|
|
|
2019-12-04 21:19:21 +00:00
|
|
|
valueNotNull = {k, v}: v != null;
|
|
|
|
entriesToKeep = builtins.filter valueNotNull optionalEntriesList;
|
2016-11-22 00:43:03 +00:00
|
|
|
|
2019-12-04 21:19:21 +00:00
|
|
|
mkEntry = {k, v}: k + "=" + v;
|
|
|
|
optionalEntriesString = lib.concatMapStringsSep "\n" mkEntry entriesToKeep;
|
|
|
|
in
|
|
|
|
runCommandLocal "${name}.desktop" {}
|
2016-11-22 00:43:03 +00:00
|
|
|
''
|
2012-01-18 20:16:00 +00:00
|
|
|
mkdir -p $out/share/applications
|
2016-01-10 14:17:33 +00:00
|
|
|
cat > $out/share/applications/${name}.desktop <<EOF
|
2009-05-10 13:03:53 +01:00
|
|
|
[Desktop Entry]
|
|
|
|
Type=${type}
|
|
|
|
Exec=${exec}
|
|
|
|
Terminal=${terminal}
|
|
|
|
Name=${desktopName}
|
|
|
|
Categories=${categories}
|
2016-11-22 00:43:03 +00:00
|
|
|
${optionalEntriesString}
|
|
|
|
${if extraEntries == null then ''EOF'' else ''
|
2016-02-29 19:42:58 +00:00
|
|
|
${extraEntries}
|
2015-12-12 23:25:56 +00:00
|
|
|
EOF''}
|
2019-12-04 21:19:21 +00:00
|
|
|
''
|