mirror of
https://github.com/ilyakooo0/nixpkgs.git
synced 2024-12-27 05:43:50 +03:00
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
|
||||
, type ? "Application"
|
||||
, exec
|
||||
@ -13,24 +13,20 @@
|
||||
, extraEntries ? null
|
||||
}:
|
||||
|
||||
stdenv.mkDerivation {
|
||||
name = "${name}.desktop";
|
||||
let
|
||||
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;}
|
||||
{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
|
||||
mkEntry = {k, v}: k + "=" + v;
|
||||
optionalEntriesString = lib.concatMapStringsSep "\n" mkEntry entriesToKeep;
|
||||
in
|
||||
runCommandLocal "${name}.desktop" {}
|
||||
''
|
||||
mkdir -p $out/share/applications
|
||||
cat > $out/share/applications/${name}.desktop <<EOF
|
||||
@ -44,5 +40,4 @@ stdenv.mkDerivation {
|
||||
${if extraEntries == null then ''EOF'' else ''
|
||||
${extraEntries}
|
||||
EOF''}
|
||||
'';
|
||||
}
|
||||
''
|
||||
|
Loading…
Reference in New Issue
Block a user