tangled
alpha
login
or
join now
pyrox.dev
/
nixpkgs
lol
0
fork
atom
overview
issues
pulls
pipelines
make-desktopitem: make genericName optional
Laverne Schrock
8 years ago
f099df3c
d1d9186b
+25
-13
1 changed file
expand all
collapse all
unified
split
pkgs
build-support
make-desktopitem
default.nix
+25
-13
pkgs/build-support/make-desktopitem/default.nix
···
1
-
{stdenv}:
2
{ name
3
, type ? "Application"
4
, exec
5
-
, icon ? ""
6
-
, comment ? ""
7
, terminal ? "false"
8
, desktopName
9
-
, genericName
10
-
, mimeType ? ""
11
, categories ? "Application;Other;"
12
, startupNotify ? null
13
-
, extraEntries ? ""
14
}:
15
16
stdenv.mkDerivation {
17
name = "${name}.desktop";
18
-
buildCommand = ''
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
19
mkdir -p $out/share/applications
20
cat > $out/share/applications/${name}.desktop <<EOF
21
[Desktop Entry]
22
Type=${type}
23
Exec=${exec}
24
-
Icon=${icon}
25
-
Comment=${comment}
26
Terminal=${terminal}
27
Name=${desktopName}
28
-
GenericName=${genericName}
29
-
MimeType=${mimeType}
30
Categories=${categories}
0
0
31
${extraEntries}
32
-
${if startupNotify == null then ''EOF'' else ''
33
-
StartupNotify=${startupNotify}
34
EOF''}
35
'';
36
}
···
1
+
{stdenv, lib}:
2
{ name
3
, type ? "Application"
4
, exec
5
+
, icon ? null
6
+
, comment ? null
7
, terminal ? "false"
8
, desktopName
9
+
, genericName ? null
10
+
, mimeType ? null
11
, categories ? "Application;Other;"
12
, startupNotify ? null
13
+
, extraEntries ? null
14
}:
15
16
stdenv.mkDerivation {
17
name = "${name}.desktop";
18
+
19
+
buildCommand = let
20
+
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
34
+
''
35
mkdir -p $out/share/applications
36
cat > $out/share/applications/${name}.desktop <<EOF
37
[Desktop Entry]
38
Type=${type}
39
Exec=${exec}
0
0
40
Terminal=${terminal}
41
Name=${desktopName}
0
0
42
Categories=${categories}
43
+
${optionalEntriesString}
44
+
${if extraEntries == null then ''EOF'' else ''
45
${extraEntries}
0
0
46
EOF''}
47
'';
48
}