makeDesktopItem: use runCommandLocal

This derivation only creates a simple text file, so it makes sense to do
it locally.

On my setup this reduces build time from 2.2s to 1.2s.
This commit is contained in:
Bjørn Forsman 2019-12-04 22:19:21 +01:00
parent 5b6e958b92
commit e488670764

View File

@ -1,4 +1,4 @@
{stdenv, lib}: { lib, runCommandLocal }:
{ name { name
, type ? "Application" , type ? "Application"
, exec , exec
@ -13,11 +13,7 @@
, extraEntries ? null , extraEntries ? null
}: }:
stdenv.mkDerivation { let
name = "${name}.desktop";
buildCommand = let
optionalEntriesList = [{k="Icon"; v=icon;} optionalEntriesList = [{k="Icon"; v=icon;}
{k="Comment"; v=comment;} {k="Comment"; v=comment;}
{k="GenericName"; v=genericName;} {k="GenericName"; v=genericName;}
@ -29,8 +25,8 @@ stdenv.mkDerivation {
mkEntry = {k, v}: k + "=" + v; mkEntry = {k, v}: k + "=" + v;
optionalEntriesString = lib.concatMapStringsSep "\n" mkEntry entriesToKeep; optionalEntriesString = lib.concatMapStringsSep "\n" mkEntry entriesToKeep;
in
in 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
@ -44,5 +40,4 @@ stdenv.mkDerivation {
${if extraEntries == null then ''EOF'' else '' ${if extraEntries == null then ''EOF'' else ''
${extraEntries} ${extraEntries}
EOF''} EOF''}
''; ''
}