git.iko.soy/typeable/nixpkgs
on master help sign in
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.

commite488670764c520394c0780c99dbaad15de143aae authorBjørn Forsman <bjorn.forsman@gmail.com> dateWed 4 Dec 2019, 22:19 (7 years ago) parent5b6e958
1 file changed+14−19
pkgs/build-support/make-desktopitem/default.nix+14−19
pkgs/build-support/make-desktopitem/default.nix+14−19
@@ -1,4 +1,4 @@
1−{stdenv, lib}:
1+{ lib, runCommandLocal }:
22{ name
33, type ? "Application"
44, exec
@@ -13,24 +13,20 @@
1313, extraEntries ? null
1414}:
1515
16−stdenv.mkDerivation {
17− name = "${name}.desktop";
16+let
17+ optionalEntriesList = [{k="Icon"; v=icon;}
18+ {k="Comment"; v=comment;}
19+ {k="GenericName"; v=genericName;}
20+ {k="MimeType"; v=mimeType;}
21+ {k="StartupNotify"; v=startupNotify;}];
1822
19− buildCommand = let
23+ valueNotNull = {k, v}: v != null;
24+ entriesToKeep = builtins.filter valueNotNull optionalEntriesList;
2025
21− optionalEntriesList = [{k="Icon"; v=icon;}
22− {k="Comment"; v=comment;}
23− {k="GenericName"; v=genericName;}
24− {k="MimeType"; v=mimeType;}
25− {k="StartupNotify"; v=startupNotify;}];
26−
27− valueNotNull = {k, v}: v != null;
28− entriesToKeep = builtins.filter valueNotNull optionalEntriesList;
29−
30− mkEntry = {k, v}: k + "=" + v;
31− optionalEntriesString = lib.concatMapStringsSep "\n" mkEntry entriesToKeep;
32−
33− in
26+ mkEntry = {k, v}: k + "=" + v;
27+ optionalEntriesString = lib.concatMapStringsSep "\n" mkEntry entriesToKeep;
28+in
29+runCommandLocal "${name}.desktop" {}
3430 ''
3531 mkdir -p $out/share/applications
3632 cat > $out/share/applications/${name}.desktop <<EOF
@@ -44,5 +40,4 @@ stdenv.mkDerivation {
4440 ${if extraEntries == null then ''EOF'' else ''
4541 ${extraEntries}
4642 EOF''}
47− '';
48−}
43+ ''