summary refs log tree commit diff
path: root/pkgs/build-support/make-startupitem/default.nix
blob: fad6f00d82116f60382263734a5d35ca32a1d342 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# given a pakcage with a $name.desktop file, makes a copy
# as autostart item.

{stdenv, lib}:
{ name            # name of the desktop file (without .desktop)
, package         # package where the desktop file resides in
, srcPrefix ? ""  # additional prefix that the desktop file may have in the 'package'
, after ? null
, condition ? null
, phase ? "2"
}:

# the builder requires that
#   $package/share/applications/$name.desktop
# exists as file.

stdenv.mkDerivation {
  name = "autostart-${name}";
  priority = 5;

  buildCommand = ''
    mkdir -p $out/share/autostart
    target=${name}.desktop
    cp ${package}/share/applications/${srcPrefix}${name}.desktop $target
    chmod +rw $target
    echo "X-KDE-autostart-phase=${phase}" >> $target
    ${lib.optionalString (after != null) ''echo "${after}" >> $target''}
    ${lib.optionalString (condition != null) ''echo "${condition}" >> $target''}
    cp $target $out/share/autostart
  '';

  # this will automatically put 'package' in the environment when you
  # put its startup item in there.
  propagatedBuildInputs = [ package ];
}