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:
parent
5b6e958b92
commit
e488670764
@ -1,4 +1,4 @@
|
|||||||
{stdenv, lib}:
|
{ lib, runCommandLocal }:
|
||||||
{ name
|
{ name
|
||||||
, type ? "Application"
|
, type ? "Application"
|
||||||
, exec
|
, exec
|
||||||
@ -13,24 +13,20 @@
|
|||||||
, extraEntries ? null
|
, extraEntries ? null
|
||||||
}:
|
}:
|
||||||
|
|
||||||
stdenv.mkDerivation {
|
let
|
||||||
name = "${name}.desktop";
|
optionalEntriesList = [{k="Icon"; v=icon;}
|
||||||
|
{k="Comment"; v=comment;}
|
||||||
|
{k="GenericName"; v=genericName;}
|
||||||
|
{k="MimeType"; v=mimeType;}
|
||||||
|
{k="StartupNotify"; v=startupNotify;}];
|
||||||
|
|
||||||
buildCommand = let
|
valueNotNull = {k, v}: v != null;
|
||||||
|
entriesToKeep = builtins.filter valueNotNull optionalEntriesList;
|
||||||
|
|
||||||
optionalEntriesList = [{k="Icon"; v=icon;}
|
mkEntry = {k, v}: k + "=" + v;
|
||||||
{k="Comment"; v=comment;}
|
optionalEntriesString = lib.concatMapStringsSep "\n" mkEntry entriesToKeep;
|
||||||
{k="GenericName"; v=genericName;}
|
in
|
||||||
{k="MimeType"; v=mimeType;}
|
runCommandLocal "${name}.desktop" {}
|
||||||
{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
|
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''}
|
||||||
'';
|
''
|
||||||
}
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user