···11+# given a pakcage with a $name.desktop file, makes a copy
22+# as autostart item.
33+44+{stdenv, lib}:
55+{ name # name of the desktop file (without .desktop)
66+, package # package where the desktop file resides in
77+, after ? null
88+, condition ? null
99+, phase ? "2"
1010+}:
1111+1212+# the builder requires that
1313+# $package/share/applications/$name.desktop
1414+# exists as file.
1515+1616+stdenv.mkDerivation {
1717+ name = "autostart-${name}";
1818+ priority = 5;
1919+2020+ buildCommand = ''
2121+ ensureDir $out/share/autostart
2222+ target=${name}.desktop
2323+ cp ${package}/share/applications/${name}.desktop $target
2424+ chmod +rw $target
2525+ echo "X-KDE-autostart-phase=${phase}" >> $target
2626+ ${lib.optionalString (after != null) ''echo "${after}" >> $target''}
2727+ ${lib.optionalString (condition != null) ''echo "${condition}" >> $target''}
2828+ cp $target $out/share/autostart
2929+ '';
3030+3131+ # this will automatically put 'package' in the environment when you
3232+ # put its startup item in there.
3333+ propagatedBuildInputs = [ package ];
3434+}